[CRIU] [PATCH 3/7] criu_req: Remove unneeded htype for some reqs

Pavel Emelyanov xemul at parallels.com
Thu Oct 22 05:45:45 PDT 2015


It only makes sense for the htype to adjust dump and restore
reqs, all the others are p.haul-criu internal stuff and htype
shouldn't mess with it.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 phaul/criu_req.py       | 21 +++++++++++----------
 phaul/p_haul_iters.py   |  5 ++---
 phaul/p_haul_service.py |  5 ++---
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/phaul/criu_req.py b/phaul/criu_req.py
index 3cc1721..2bf53cd 100644
--- a/phaul/criu_req.py
+++ b/phaul/criu_req.py
@@ -27,16 +27,17 @@ def get_name(req_type):
 	"""Return printable request name"""
 	return _names[req_type]
 
-def _make_req(typ, htype):
+def _make_req(typ, htype = None):
 	"""Prepare generic criu request"""
 	req = pycriu.rpc.criu_req()
 	req.type = typ
-	htype.adjust_criu_req(req)
+	if htype:
+		htype.adjust_criu_req(req)
 	return req
 
-def make_cpuinfo_dump_req(htype, img):
+def make_cpuinfo_dump_req(img):
 	"""Prepare cpuinfo dump criu request (source side)"""
-	req = _make_req(pycriu.rpc.CPUINFO_DUMP, htype)
+	req = _make_req(pycriu.rpc.CPUINFO_DUMP)
 	req.opts.images_dir_fd = img.work_dir_fd()
 	req.keep_open = True
 	return req
@@ -75,10 +76,10 @@ def make_dump_req(pid, htype, img, connection, fs):
 		req.opts.tcp_established = True
 	return req
 
-def make_page_server_req(htype, img, connection):
+def make_page_server_req(img, connection):
 	"""Prepare page server criu request (destination side)"""
 
-	req = _make_req(pycriu.rpc.PAGE_SERVER, htype)
+	req = _make_req(pycriu.rpc.PAGE_SERVER)
 	req.keep_open = True
 	req.opts.ps.fd = connection.mem_sk_fileno()
 	req.opts.images_dir_fd = img.image_dir_fd()
@@ -90,9 +91,9 @@ def make_page_server_req(htype, img, connection):
 
 	return req
 
-def make_cpuinfo_check_req(htype, img):
+def make_cpuinfo_check_req(img):
 	"""Prepare cpuinfo check criu request (destination side)"""
-	req = _make_req(pycriu.rpc.CPUINFO_CHECK, htype)
+	req = _make_req(pycriu.rpc.CPUINFO_CHECK)
 	req.keep_open = True
 	req.opts.images_dir_fd = img.work_dir_fd()
 	return req
@@ -116,9 +117,9 @@ def make_restore_req(htype, img, nroot):
 
 	return req
 
-def make_dirty_tracking_req(htype, img):
+def make_dirty_tracking_req(img):
 	"""Check if dirty memory tracking is supported."""
-	req = _make_req(pycriu.rpc.FEATURE_CHECK, htype)
+	req = _make_req(pycriu.rpc.FEATURE_CHECK)
 	req.features.mem_track = True
 	req.keep_open = True
 	req.opts.images_dir_fd = img.work_dir_fd()
diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index 0dd56cc..8e3afbd 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -67,7 +67,7 @@ class phaul_iter_worker:
 		logging.info("Checking CPU compatibility")
 
 		logging.info("\t`- Dumping CPU info")
-		req = criu_req.make_cpuinfo_dump_req(self.htype, self.img)
+		req = criu_req.make_cpuinfo_dump_req(self.img)
 		resp = self.criu_connection.send_req(req)
 		if not resp.success:
 			raise Exception("Can't dump cpuinfo")
@@ -81,8 +81,7 @@ class phaul_iter_worker:
 
 	def pre_dump_check(self):
 		# pre-dump auto-detection
-		req = criu_req.make_dirty_tracking_req(
-			self.htype,self.img)
+		req = criu_req.make_dirty_tracking_req(self.img)
 		resp = self.criu_connection.send_req(req)
 		if not resp.success:
 			# Not able to do auto-detection, disable memory tracking
diff --git a/phaul/p_haul_service.py b/phaul/p_haul_service.py
index b90f1d7..46b40e5 100644
--- a/phaul/p_haul_service.py
+++ b/phaul/p_haul_service.py
@@ -63,8 +63,7 @@ class phaul_service:
 		logging.info("Starting page server for iter %d", self.dump_iter_index)
 
 		logging.info("\tSending criu rpc req")
-		req = criu_req.make_page_server_req(self.htype, self.img,
-			self.criu_connection)
+		req = criu_req.make_page_server_req(self.img, self.criu_connection)
 		resp = self.criu_connection.send_req(req)
 		if not resp.success:
 			raise Exception("Failed to start page server")
@@ -87,7 +86,7 @@ class phaul_service:
 
 	def rpc_check_cpuinfo(self):
 		logging.info("Checking cpuinfo")
-		req = criu_req.make_cpuinfo_check_req(self.htype, self.img)
+		req = criu_req.make_cpuinfo_check_req(self.img)
 		resp = self.criu_connection.send_req(req)
 		logging.info("\t`- %s", resp.success)
 		return resp.success
-- 
1.9.3




More information about the CRIU mailing list