[CRIU] [PATCH] [POC] zdtm: check lazy-pages

Andrey Vagin avagin at openvz.org
Tue Jun 14 17:47:21 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

[root at fc22-vm criu]# python test/zdtm.py run -t zdtm/static/unlink_fstat04 --lazy-pages
=== Run 1/1 ================

===================== Run zdtm/static/unlink_fstat04 in h ======================
Makefile:299: target 'mnt_enablefs.pid' given more than once in the same rule
Start test
Test is SUID
Makefile:299: target 'mnt_enablefs.pid' given more than once in the same rule
./unlink_fstat04 --pidfile=unlink_fstat04.pid --outfile=unlink_fstat04.out --dirname=unlink_fstat04.test
Run criu dump
Run criu lazy-pages
Run criu restore
Wait for zdtm/static/unlink_fstat04 to die for 0.100000
Removing dump/zdtm/static/unlink_fstat04/24
===================== Test zdtm/static/unlink_fstat04 PASS =====================

===================== Run zdtm/static/unlink_fstat04 in ns =====================
Makefile:299: target 'mnt_enablefs.pid' given more than once in the same rule
Start test
Test is SUID
Makefile:299: target 'mnt_enablefs.pid' given more than once in the same rule
./unlink_fstat04 --pidfile=unlink_fstat04.pid --outfile=unlink_fstat04.out --dirname=unlink_fstat04.test
Run criu dump
Run criu lazy-pages
Run criu restore
=[log]=> dump/zdtm/static/unlink_fstat04/54/1/restore.log
------------------------ grep Error ------------------------
(00.183478)      1: Error (uffd.c:142): lazy-pages: connect to userfault.socket failed: No such file or directory
(00.183623)      4: Error (uffd.c:142): lazy-pages: connect to userfault.socket failed: No such file or directory
(00.191785) Error (cr-restore.c:992): 77 killed by signal 9: Killed
(00.191807) Error (cr-restore.c:1877): Restoring FAILED.
------------------------ ERROR OVER ------------------------

Cc: Adrian Reber <areber at redhat.com>
Cc: Mike Rapoport <rppt at linux.vnet.ibm.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm.py | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index d24429a..98345a4 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -645,6 +645,7 @@ class criu_cli:
 		self.__iter = 0
 		self.__prev_dump_iter = None
 		self.__page_server = (opts['page_server'] and True or False)
+		self.__lazy_pages = (opts['lazy_pages'] and True or False)
 		self.__restore_sibling = (opts['sibling'] and True or False)
 		self.__join_ns = (opts['join_ns'] and True or False)
 		self.__unshare = (opts['unshare'] and True or False)
@@ -687,6 +688,8 @@ class criu_cli:
 			print "Forcing %s fault" % fault
 			env = dict(os.environ, CRIU_FAULT = fault)
 		cr = subprocess.Popen(strace + [criu_bin, action] + args, env = env, preexec_fn = preexec)
+		if action == "lazy-pages":
+			return cr
 		return cr.wait()
 
 	def set_user_id(self):
@@ -721,6 +724,8 @@ class criu_cli:
 		__ddir = self.__ddir()
 
 		ret = self.__criu(action, s_args, self.__fault, strace, preexec)
+		if action == "lazy-pages":
+			return ret
 		grep_errors(os.path.join(__ddir, log))
 		if ret != 0:
 			if self.__fault and int(self.__fault) < 128:
@@ -801,8 +806,19 @@ class criu_cli:
 		if os.getenv("GCOV"):
 			r_opts.append("--ext-mount-map")
 			r_opts.append("zdtm:%s" % criu_dir)
+
+		lazy_pages_p = None
+		if self.__lazy_pages:
+			addr = "userfault.socket"
+			self.lazy_pages_p = self.__criu_act("lazy-pages", opts = ["--address", addr])
+			r_opts += ["--lazy-pages", "--address", addr]
+			time.sleep(1)  # FIXME wait user fault fd socket
+
 		self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
 
+		if lazy_pages_p and lazy_pages_p.wait():
+			raise test_fail_exc("CRIU lazy-pages")
+
 	@staticmethod
 	def check(feature):
 		return criu_cli.__criu("check", ["-v0", "--feature", feature]) == 0
@@ -1146,7 +1162,7 @@ class launcher:
 
 		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'unshare',
 				'fault', 'keep_img', 'report', 'snaps', 'sat', 'script',
-				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup')
+				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup', 'lazy_pages')
 		arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
 
 		if self.__use_log:
@@ -1603,6 +1619,7 @@ rp.add_argument("-k", "--keep-img", help = "Whether or not to keep images after
 		choices = ['always', 'never', 'failed'], default = 'failed')
 rp.add_argument("--report", help = "Generate summary report in directory")
 rp.add_argument("--keep-going", help = "Keep running tests in spite of failures", action = 'store_true')
+rp.add_argument("--lazy-pages", help = "restore pages on demand", action = 'store_true')
 
 lp = sp.add_parser("list", help = "List tests")
 lp.set_defaults(action = list_tests)
-- 
2.7.4



More information about the CRIU mailing list