[CRIU] [PATCH 3/3] zdtm: run page-server via rpc
Andrei Vagin
avagin at openvz.org
Mon Apr 24 14:37:51 PDT 2017
From: Andrei Vagin <avagin at virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
scripts/travis/travis-tests | 1 +
test/zdtm.py | 41 +++++++++++++++++++++++++++++++++++------
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/scripts/travis/travis-tests b/scripts/travis/travis-tests
index 93306ce..f488748 100755
--- a/scripts/travis/travis-tests
+++ b/scripts/travis/travis-tests
@@ -79,6 +79,7 @@ make -C test/others/make/ run
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --noauto-dedup
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --page-server
./test/zdtm.py run -t zdtm/transition/maps007 --pre 2 --page-server --dedup
+./test/zdtm.py run -t zdtm/static/env00 --swrk --pre 2 --page-server
./test/zdtm.py run -t zdtm/static/socket-tcp-local --norst
diff --git a/test/zdtm.py b/test/zdtm.py
index d35731b..e202b8b 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -695,6 +695,14 @@ class criu_cli:
return cr.wait()
+class criu_rpc_process:
+ def wait(self):
+ return self.criu.wait_pid(self.pid)
+
+ def terminate(self):
+ os.kill(self.pid, signal.SIGTERM)
+
+
class criu_rpc:
@staticmethod
def __set_opts(criu, args, ctx):
@@ -729,6 +737,17 @@ class criu_rpc:
if arg == '--external':
criu.opts.external.append(args.pop(0))
continue
+ if arg == '--status-fd':
+ criu.opts.status_fd = int(args.pop(0))
+ continue
+ if arg == '--port':
+ criu.opts.ps.port = int(args.pop(0))
+ continue
+ if arg == '--address':
+ criu.opts.ps.address = args.pop(0)
+ continue
+ if arg == '--page-server':
+ continue
raise test_fail_exc('RPC for %s required' % arg)
@@ -740,17 +759,18 @@ class criu_rpc:
raise test_fail_exc('RPC and SAT not supported')
if preexec:
raise test_fail_exc('RPC and PREEXEC not supported')
- if nowait:
- raise test_fail_exc("RPC and status-fd not supported")
ctx = {} # Object used to keep info untill action is done
criu = crpc.criu()
criu.use_binary(criu_bin)
criu_rpc.__set_opts(criu, args, ctx)
+ p = None
try:
if action == 'dump':
criu.dump()
+ elif action == 'pre-dump':
+ criu.pre_dump()
elif action == 'restore':
if 'rd' not in ctx:
raise test_fail_exc('RPC Non-detached restore is impossible')
@@ -759,10 +779,15 @@ class criu_rpc:
pidf = ctx.get('pidf')
if pidf:
open(pidf, 'w').write('%d\n' % res.pid)
+ elif action == "page-server":
+ res = criu.page_server_chld()
+ p = criu_rpc_process()
+ p.pid = res.pid
+ p.criu = criu
else:
raise test_fail_exc('RPC for %s required' % action)
- except crpc.CRIUExceptionExternal:
- print "Fail"
+ except crpc.CRIUExceptionExternal, e:
+ print "Fail", e
ret = -1
else:
ret = 0
@@ -770,6 +795,10 @@ class criu_rpc:
imgd = ctx.get('imgd')
if imgd:
os.close(imgd)
+
+ if nowait and ret == 0:
+ return p
+
return ret
@@ -1036,11 +1065,11 @@ class criu:
def kill(self):
if self.__lazy_pages_p:
self.__lazy_pages_p.terminate()
- print "criu lazy-pages exited with %s" & self.wait()
+ print "criu lazy-pages exited with %s" % self.__lazy_pages_p.wait()
self.__lazy_pages_p = None
if self.__page_server_p:
self.__page_server_p.terminate()
- print "criu page-server exited with %s" & self.wait()
+ print "criu page-server exited with %s" % self.__page_server_p.wait()
self.__page_server_p = None
--
2.9.3
More information about the CRIU
mailing list