[CRIU] [PATCH v2 5/5] p.haul: handle older criu RPC interfaces

Adrian Reber adrian at lisas.de
Tue Oct 6 09:49:28 PDT 2015


From: Adrian Reber <areber at redhat.com>

Wrap the calls to the new feature-check RPC interface into try: except:
to continue gracefully without stack traces. If the installed criu
supports feature-check it will be used to detect if memory tracking
should be enabled. If the installed criu is too old to support
feature-check no pre-dumping will be performed. Pre-dumps can still be
manually enabled via p.haul's command-line.

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 phaul/criu_req.py     | 30 +++++++++++++++++++++---------
 phaul/p_haul_iters.py | 34 +++++++++++++++++++++++++---------
 2 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/phaul/criu_req.py b/phaul/criu_req.py
index cdf1d1e..aeced6e 100644
--- a/phaul/criu_req.py
+++ b/phaul/criu_req.py
@@ -4,15 +4,27 @@
 
 import pycriu.rpc
 
-_names = {
-	pycriu.rpc.DUMP: "dump",
-	pycriu.rpc.PRE_DUMP: "pre_dump",
-	pycriu.rpc.PAGE_SERVER: "page_server",
-	pycriu.rpc.RESTORE: "restore",
-	pycriu.rpc.CPUINFO_DUMP: "cpuinfo-dump",
-	pycriu.rpc.CPUINFO_CHECK: "cpuinfo-check",
-	pycriu.rpc.FEATURE_CHECK: "feature-check",
-}
+try:
+	_names = {
+		pycriu.rpc.DUMP: "dump",
+		pycriu.rpc.PRE_DUMP: "pre_dump",
+		pycriu.rpc.PAGE_SERVER: "page_server",
+		pycriu.rpc.RESTORE: "restore",
+		pycriu.rpc.CPUINFO_DUMP: "cpuinfo-dump",
+		pycriu.rpc.CPUINFO_CHECK: "cpuinfo-check",
+		pycriu.rpc.FEATURE_CHECK: "feature-check",
+	}
+except:
+	# Do not fail if installed criu does not support
+	# RPC call DIRTY_TRACKING
+	_names = {
+		pycriu.rpc.DUMP: "dump",
+		pycriu.rpc.PRE_DUMP: "pre_dump",
+		pycriu.rpc.PAGE_SERVER: "page_server",
+		pycriu.rpc.RESTORE: "restore",
+		pycriu.rpc.CPUINFO_DUMP: "cpuinfo-dump",
+		pycriu.rpc.CPUINFO_CHECK: "cpuinfo-check",
+	}
 
 def get_name(req_type):
 	"""Return printable request name"""
diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index c33e9df..a5be7e4 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -86,23 +86,39 @@ class phaul_iter_worker:
 		self.fs.set_work_dir(self.img.work_dir())
 		self.fs.start_migration()
 
+		logging.info("Checking for Dirty Tracking")
 		if self.pre_dump == 0:
 			# pre-dump auto-detection
-			logging.info("Checking for Dirty Tracking")
-			req = criu_req.make_dirty_tracking_req(self.htype, self.img)
-			resp = self.criu.send_req(req)
-			pre_dump = resp.success
+			try:
+				req = criu_req.make_dirty_tracking_req(
+						self.htype, self.img)
+				resp = self.criu.send_req(req)
+				pre_dump = False
+				if not resp.success:
+					# Not able to do auto-detection, disable memory tracking
+					raise Exception()
+				if (resp.feat_res & (1 << cr_rpc.MEM_TRACK)):
+					logging.info("\t`- Auto Enabled")
+					pre_dump = True
+				else:
+					logging.info("\t`- Auto Disabled")
+
+			except:
+				# The available criu seems to not
+				# support memory tracking auto detection.
+				pre_dump = False
+				logging.info("\t`- Auto detection not possible "
+						"- Disabled")
+
 		elif self.pre_dump == 1:
 			pre_dump = False
+			logging.info("\t`- Command-line disabled")
 		else:
 			pre_dump = True
+			logging.info("\t`- Command-line enabled")
 
 		if pre_dump:
-			if (resp.feat_res & (1 << cr_rpc.MEM_TRACK)):
-				logging.info("Starting iterations")
-				pre_dump = True
-			else:
-				self.criu.memory_tracking(False)
+			logging.info("Starting iterations")
 		else:
 			self.criu.memory_tracking(False)
 
-- 
1.8.3.1



More information about the CRIU mailing list