Commit 397df9c0 authored by Andrei Vagin's avatar Andrei Vagin

lib/py: allow to execute page-server as a child process

Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent ebd64bdd
......@@ -195,6 +195,7 @@ class criu:
def __init__(self):
self.use_binary('criu')
self.opts = rpc.criu_opts()
self.sk = None
def use_sk(self, sk_name):
"""
......@@ -227,13 +228,20 @@ class criu:
daemon = True
try:
s = self._comm.connect(daemon)
if not self.sk:
s = self._comm.connect(daemon)
else:
s = self.sk
if req.keep_open:
self.sk = s
s.send(req.SerializeToString())
buf = s.recv(len(s.recv(1, socket.MSG_TRUNC | socket.MSG_PEEK)))
self._comm.disconnect()
if not req.keep_open:
self._comm.disconnect()
resp = rpc.criu_resp()
resp.ParseFromString(buf)
......@@ -283,3 +291,28 @@ class criu:
raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)
return resp.restore
def page_server_chld(self):
req = rpc.criu_req()
req.type = rpc.PAGE_SERVER_CHLD
req.opts.MergeFrom(self.opts)
req.keep_open = True
resp = self._send_req_and_recv_resp(req)
if not resp.success:
raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)
return resp.ps
def wait_pid(self, pid):
req = rpc.criu_req()
req.type = rpc.WAIT_PID
req.pid = pid
resp = self._send_req_and_recv_resp(req)
if not resp.success:
raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)
return resp.status
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment