From f951a3cc926e4a5110dfa2a9df3fdae92917028d Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Wed, 21 Jun 2017 08:16:46 +0300 Subject: [PATCH] zdtm: restore ns_last_pid before executing restore in a second time Otherwise a criu process can get a pid of one of restored processes. Signed-off-by: Andrei Vagin --- test/zdtm.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/zdtm.py b/test/zdtm.py index 3e21b9184..30cca17f4 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -337,12 +337,6 @@ def test_flag(tdesc, flag): return flag in tdesc.get('flags', '').split() -def reset_pid(pid = 1): - fd = open('/proc/sys/kernel/ns_last_pid', 'w') - fd.write('%s' % pid) - fd.close() - - # # Exception thrown when something inside the test goes wrong, # e.g. test doesn't start, criu returns with non zero code or @@ -943,6 +937,9 @@ class criu: os.close(status_fds[0]) return ret + if '--check-only' in opts and action == "restore": + open("/proc/sys/kernel/ns_last_pid", "w+").write(ns_last_pid) + grep_errors(os.path.join(__ddir, log)) if ret != 0: if self.__fault and int(self.__fault) < 128: @@ -1092,8 +1089,6 @@ class criu: if self.__check_only: self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only']) - # sometimes the real restore fails with PID conflicts without this - reset_pid() self.__criu_act("restore", opts = r_opts + ["--restore-detached"]) self.show_stats("restore")