[CRIU] [PATCH 4/4] p.haul: improve subprocess output logging

Nikita Spiridonov nspiridonov at virtuozzo.com
Thu Apr 21 05:46:32 PDT 2016


Add log_subprocess_output function which add offset and prefix to
subprocess output.

Signed-off-by: Nikita Spiridonov <nspiridonov at virtuozzo.com>
---
 phaul/p_haul_vz.py |   10 +++++-----
 phaul/util.py      |    5 +++++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index 578e5e8..0f1d251 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -178,7 +178,7 @@ class p_haul_type:
 				self._ctid, "--skip_arpdetect", "--dumpfile", img.image_dir()],
 				stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 			proc_output = proc.communicate()[0]
-			logging.info(proc_output)
+			util.log_subprocess_output(proc_output)
 			if proc.returncode != 0:
 				raise Exception("Restore failed ({0})".format(proc.returncode))
 		finally:
@@ -196,7 +196,7 @@ class p_haul_type:
 			[vzctl_bin, "--skipowner", "--skiplock", "mount", self._ctid],
 			stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 		proc_output = proc.communicate()[0]
-		logging.info(proc_output)
+		util.log_subprocess_output(proc_output)
 		self._fs_mounted = True
 		return self._ct_root
 
@@ -208,7 +208,7 @@ class p_haul_type:
 				[vzctl_bin, "--skipowner", "--skiplock", "umount", self._ctid],
 				stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 			proc_output = proc.communicate()[0]
-			logging.info(proc_output)
+			util.log_subprocess_output(proc_output)
 			self._fs_mounted = False
 
 	def migration_complete(self, fs, target_host):
@@ -231,7 +231,7 @@ class p_haul_type:
 			[vzctl_bin, "--skipowner", "--skiplock", "start", self._ctid],
 			stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 		proc_output = proc.communicate()[0]
-		logging.info(proc_output)
+		util.log_subprocess_output(proc_output)
 		self._fs_mounted = True
 
 	def stop(self, umount):
@@ -243,7 +243,7 @@ class p_haul_type:
 		proc = subprocess.Popen(
 			args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 		proc_output = proc.communicate()[0]
-		logging.info(proc_output)
+		util.log_subprocess_output(proc_output)
 		self._fs_mounted = not umount
 
 	def get_fs(self, fdfs=None):
diff --git a/phaul/util.py b/phaul/util.py
index 1f17e5b..3776c52 100644
--- a/phaul/util.py
+++ b/phaul/util.py
@@ -88,3 +88,8 @@ def log_header():
 	OFFSET_LINES_COUNT = 3
 	for i in range(OFFSET_LINES_COUNT):
 		logging.info("")
+
+
+def log_subprocess_output(output):
+	for line in output.splitlines():
+		logging.info("\t> %s", line)
-- 
1.7.1



More information about the CRIU mailing list