[CRIU] [PATCH v3 6/6] p.haul: move check for memory tracking

Adrian Reber adrian at lisas.de
Thu Oct 8 07:06:49 PDT 2015


From: Adrian Reber <areber at redhat.com>

For better readability and code structure the memory tracking check
has been moved to its own function.

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 phaul/p_haul_iters.py | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index 85efc8b..3b8139f 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -76,6 +76,22 @@ class phaul_iter_worker:
 		if not self.target_host.check_cpuinfo():
 			raise Exception("CPUs mismatch")
 
+	def pre_dump_check(self):
+		# pre-dump auto-detection
+		req = criu_req.make_dirty_tracking_req(
+			self.htype,self.img)
+		resp = self.criu_connection.send_req(req)
+		if not resp.success:
+			# Not able to do auto-detection, disable memory tracking
+			raise Exception()
+		if resp.HasField('features'):
+			return False
+		if resp.features.HasField('mem_track'):
+			return False
+		if resp.features.mem_track:
+			return True
+		return False
+
 	def start_migration(self):
 
 		migration_stats = mstats.migration_stats()
@@ -95,18 +111,9 @@ class phaul_iter_worker:
 		if self.pre_dump == 0:
 			# pre-dump auto-detection
 			try:
-				req = criu_req.make_dirty_tracking_req(
-						self.htype, self.img)
-				resp = self.criu_connection.send_req(req)
-				pre_dump = False
-				if not resp.success:
-					# Not able to do auto-detection, disable memory tracking
-					raise Exception()
-				if resp.HasField('features'):
-					if resp.features.HasField('mem_track'):
-						if resp.features.mem_track:
-							logging.info("\t`- Auto Enabled")
-							pre_dump = True
+				pre_dump = self.pre_dump_check()
+				if pre_dump:
+					logging.info("\t`- Auto Enabled")
 				else:
 					logging.info("\t`- Auto Disabled")
 
-- 
1.8.3.1



More information about the CRIU mailing list