[CRIU] [PATCH 2/5] [v2] zdtm: add an option to show criu statistics

Andrei Vagin avagin at openvz.org
Wed Nov 8 03:36:02 MSK 2017


From: Andrei Vagin <avagin at virtuozzo.com>

v2: defining crit_bin and using it for Popen() // Mike
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index 145959c71..2a834d8f1 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -682,6 +682,7 @@ test_classes = {'zdtm': zdtm_test, 'inhfd': inhfd_test, 'groups': groups_test}
 #
 
 criu_bin = "../criu/criu"
+crit_bin = "../crit/crit"
 join_ns_file = '/run/netns/zdtm_netns'
 
 
@@ -838,6 +839,7 @@ class criu:
 		self.__remote = (opts['remote'] and True or False)
 		self.__criu = (opts['rpc'] and criu_rpc or criu_cli)
 		self.__check_only = (opts['check_only'] and True or False)
+		self.__show_stats = (opts['show_stats'] and True or False)
 		self.__lazy_pages_p = None
 		self.__page_server_p = None
 
@@ -971,6 +973,14 @@ class criu:
 			else:
 				raise test_fail_exc("CRIU %s" % action)
 
+	def show_stats(self, action):
+		if not self.__show_stats:
+			return
+
+		subprocess.Popen([crit_bin, "show",
+				os.path.join(self.__dump_path,
+				str(self.__iter), "stats-%s" % action)]).wait()
+
 	def dump(self, action, opts = []):
 		self.__iter += 1
 		os.mkdir(self.__ddir())
@@ -1039,6 +1049,8 @@ class criu:
 		if self.__mdedup and self.__iter > 1:
 			self.__criu_act("dedup", opts = [])
 
+		self.show_stats("dump")
+
 		if self.__leave_stopped:
 			pstree_check_stopped(self.__test.getpid())
 			pstree_signal(self.__test.getpid(), signal.SIGKILL)
@@ -1089,6 +1101,7 @@ class criu:
 			self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
 
 		self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
+		self.show_stats("restore")
 
 		if self.__leave_stopped:
 			pstree_check_stopped(self.__test.getpid())
@@ -1567,7 +1580,7 @@ class Launcher:
 		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'stop', 'empty_ns',
 				'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', 'rpc', 'lazy_pages',
 				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
-				'remote_lazy_pages', 'remote', 'check_only')
+				'remote_lazy_pages', 'remote', 'check_only', 'show_stats')
 		arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
 
 		if self.__use_log:
@@ -2122,6 +2135,7 @@ rp.add_argument("--lazy-pages", help = "restore pages on demand", action = 'stor
 rp.add_argument("--remote-lazy-pages", help = "simulate lazy migration", action = 'store_true')
 rp.add_argument("--title", help = "A test suite title", default = "criu")
 rp.add_argument("--check-only", help = "Additionally try to dump/restore in --check-only mode", action = 'store_true')
+rp.add_argument("--show-stats", help = "Show criu statistics", action = 'store_true')
 
 lp = sp.add_parser("list", help = "List tests")
 lp.set_defaults(action = list_tests)
-- 
2.13.6



More information about the CRIU mailing list