[CRIU] [PATCH] test: restore ns_last_pid before executing restore in a second time

Andrei Vagin avagin at openvz.org
Fri Apr 21 15:02:37 PDT 2017


From: Andrei Vagin <avagin at virtuozzo.com>

It is required for cases when we inject a fault in criu restore.
In this case we execute "criu restore" and check that it fails,
then we execute "criu restore" without a fault and check that it passes.

If the first "criu restore" restores only a part of processes,
the second criu can get PID of one of restored processes.

https://github.com/xemul/criu/issues/282
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test/zdtm.py b/test/zdtm.py
index d35731b..26b8939 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -865,6 +865,8 @@ class criu:
 			status_fds = os.pipe()
 			s_args += ["--status-fd", str(status_fds[1])]
 
+		ns_last_pid = open("/proc/sys/kernel/ns_last_pid").read()
+
 		ret = self.__criu.run(action, s_args, self.__fault, strace, preexec, nowait)
 
 		if nowait:
@@ -887,6 +889,9 @@ class criu:
 				else:
 					# on restore we move only a log file, because we need images
 					os.rename(os.path.join(__ddir, log), os.path.join(__ddir, log + ".fail"))
+				# restore ns_last_pid to avoid a case when criu gets
+				# PID of one of restored processes.
+				open("/proc/sys/kernel/ns_last_pid", "w+").write(ns_last_pid)
 				# try again without faults
 				print "Run criu " + action
 				ret = self.__criu.run(action, s_args, False, strace, preexec)
-- 
2.9.3



More information about the CRIU mailing list