Beispiel #1
0
	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
Beispiel #2
0
    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
Beispiel #3
0
    def check(self):
        """
		Checks whether the kernel support is up-to-date.
		"""
        req = rpc.criu_req()
        req.type = rpc.CHECK

        resp = self._send_req_and_recv_resp(req)

        if not resp.success:
            raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)
Beispiel #4
0
Datei: criu.py Projekt: hqhq/criu
	def check(self):
		"""
		Checks whether the kernel support is up-to-date.
		"""
		req		= rpc.criu_req()
		req.type	= rpc.CHECK

		resp = self._send_req_and_recv_resp(req)

		if not resp.success:
			raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)
Beispiel #5
0
	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
Beispiel #6
0
    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
Beispiel #7
0
def setup_criu_dump_request():
    # Create criu msg, set it's type to dump request
    # and set dump options. Checkout more options in protobuf/rpc.proto
    req = rpc.criu_req()
    req.type = rpc.DUMP
    req.opts.leave_running = True
    req.opts.log_level = 4
    req.opts.log_file = log_file
    req.opts.images_dir_fd = os.open(args['dir'], os.O_DIRECTORY)
    # Not necessary, just for testing
    req.opts.tcp_established = True
    req.opts.shell_job = True
    return req
Beispiel #8
0
def setup_criu_dump_request():
	# Create criu msg, set it's type to dump request
	# and set dump options. Checkout more options in protobuf/rpc.proto
	req = rpc.criu_req()
	req.type = rpc.DUMP
	req.opts.leave_running = True
	req.opts.log_level = 4
	req.opts.log_file = log_file
	req.opts.images_dir_fd = os.open(args['dir'], os.O_DIRECTORY)
	# Not necessary, just for testing
	req.opts.tcp_established = True
	req.opts.shell_job = True
	return req
Beispiel #9
0
    def dump(self):
        """
		Checkpoint a process/tree identified by opts.pid.
		"""
        req = rpc.criu_req()
        req.type = rpc.DUMP
        req.opts.MergeFrom(self.opts)

        resp = self._send_req_and_recv_resp(req)

        if not resp.success:
            raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)

        return resp.dump
Beispiel #10
0
Datei: criu.py Projekt: hqhq/criu
	def restore(self):
		"""
		Restore a process/tree.
		"""
		req		= rpc.criu_req()
		req.type	= rpc.RESTORE
		req.opts.MergeFrom(self.opts)

		resp = self._send_req_and_recv_resp(req)

		if not resp.success:
			raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)

		return resp.restore
Beispiel #11
0
Datei: criu.py Projekt: hqhq/criu
	def dump(self):
		"""
		Checkpoint a process/tree identified by opts.pid.
		"""
		req 		= rpc.criu_req()
		req.type	= rpc.DUMP
		req.opts.MergeFrom(self.opts)

		resp = self._send_req_and_recv_resp(req)

		if not resp.success:
			raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)

		return resp.dump
Beispiel #12
0
    def restore(self):
        """
		Restore a process/tree.
		"""
        req = rpc.criu_req()
        req.type = rpc.RESTORE
        req.opts.MergeFrom(self.opts)

        resp = self._send_req_and_recv_resp(req)

        if not resp.success:
            raise CRIUExceptionExternal(req.type, resp.type, resp.cr_errno)

        return resp.restore
Beispiel #13
0
	def make_dump_req(self, typ):
		#
		# Prepare generic request for (pre)dump
		#

		req = cr_rpc.criu_req()
		req.type = typ
		req.opts.pid = self.pid
		req.opts.ps.address = self.target_host
		req.opts.ps.port = self.th.get_ps_port()
		req.opts.track_mem = True

		req.opts.images_dir_fd = self.img.image_dir_fd()
		req.opts.work_dir_fd = self.img.work_dir_fd()
		p_img = self.img.prev_image_dir()
		if p_img:
			req.opts.parent_img = p_img
		if not self.fs.persistent_inodes():
			req.opts.force_irmap = True
		req.opts.force_irmap = True

		return req
Beispiel #14
0
import rpc_pb2 as rpc
import argparse

parser = argparse.ArgumentParser(description="Test ability to restore a process from images using CRIU RPC")
parser.add_argument('socket', type = str, help = "CRIU service socket")
parser.add_argument('dir', type = str, help = "Directory where CRIU images could be found")

args = vars(parser.parse_args())

# Connect to service socket
s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
s.connect(args['socket'])

# Create criu msg, set it's type to dump request
# and set dump options. Checkout more options in protobuf/rpc.proto
req			= rpc.criu_req()
req.type		= rpc.RESTORE
req.opts.images_dir_fd	= os.open(args['dir'], os.O_DIRECTORY)
# As the dumped process is running with setsid this should not
# be necessary. There seems to be a problem for this testcase
# in combination with alpine's setsid.
# The dump is now done with -j and the restore also.
req.opts.shell_job      = True

# Send request
s.send(req.SerializeToString())

# Recv response
resp		= rpc.criu_resp()
MAX_MSG_SIZE	= 1024
resp.ParseFromString(s.recv(MAX_MSG_SIZE))
Beispiel #15
0
 def get_base_req(self):
     req = rpc.criu_req()
     req.opts.log_level = 4
     req.opts.images_dir_fd = self.imgs_fd
     return req
Beispiel #16
0
	def ack_notify(self):
		req = cr_rpc.criu_req()
		req.type = cr_rpc.NOTIFY
		req.notify_success = True
		self.cs.send(req.SerializeToString())
Beispiel #17
0
	def get_base_req(self):
		req			= rpc.criu_req()
		req.opts.log_level	= 4
		req.opts.images_dir_fd	= self.imgs_fd
		return req