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

Adrian Reber adrian at lisas.de
Mon Oct 12 07:24:32 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 | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index 91d4392..7be73bb 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -79,6 +79,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()
@@ -98,33 +114,22 @@ class phaul_iter_worker:
 		if self.pre_dump == PRE_DUMP_AUTO_DETECT:
 			# pre-dump auto-detection
 			try:
-				req = criu_req.make_dirty_tracking_req(
-						self.htype, self.img)
-				resp = self.criu_connection.send_req(req)
-				self.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")
-							self.pre_dump = True
+				self.pre_dump = self.pre_dump_check()
+				if self.pre_dump:
+					logging.info("\t`- Auto Enabled")
 				else:
 					logging.info("\t`- Auto Disabled")
 
 			except:
 				# The available criu seems to not
 				# support memory tracking auto detection.
-				self.pre_dump = False
+				self.pre_dump = PRE_DUMP_DISABLE
 				logging.info("\t`- Auto detection not possible "
 						"- Disabled")
 
 		elif self.pre_dump == PRE_DUMP_DISABLE:
-			self.pre_dump = False
 			logging.info("\t`- Command-line disabled")
 		else:
-			self.pre_dump = True
 			logging.info("\t`- Command-line enabled")
 
 		if self.pre_dump:
-- 
1.8.3.1



More information about the CRIU mailing list