[CRIU] [PATCH v4 4/6] p.haul: add option to enable/disable pre-dumps

Adrian Reber adrian at lisas.de
Mon Oct 12 07:24:30 PDT 2015


From: Adrian Reber <areber at redhat.com>

Although p.haul can now auto-detect if the used criu supports
memory tracking this adds a command-line option to force
pre-dumping on or off:

  --no-pre-dump        Force disable pre-dumps
  --pre-dump           Force enable pre-dumps

v4: using named constants for p_haul_iters.pre_dump values

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 p.haul                | 13 +++++++++++++
 phaul/p_haul_iters.py | 25 +++++++++++++++++++------
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/p.haul b/p.haul
index c828a26..d0ab24c 100755
--- a/p.haul
+++ b/p.haul
@@ -40,6 +40,19 @@ parser.add_argument("--log-file", help="Write logging messages to specified file
 parser.add_argument("-j", "--shell-job",help ="Allow migration of shell jobs",
 		    default=False, action='store_true')
 
+
+parser.add_argument('--no-pre-dump', dest='pre_dump', action='store_const',
+		    const=phaul.p_haul_iters.PRE_DUMP_DISABLE,
+		    help='Force disable pre-dumps')
+parser.add_argument('--pre-dump', dest='pre_dump', action='store_const',
+		    const=phaul.p_haul_iters.PRE_DUMP_ENABLE,
+		    help='Force enable pre-dumps')
+
+# If pre dumping is not explicitly enabled or disabled
+# it is phaul.p_haul_iters.PRE_DUMP_AUTO_DETECT
+
+parser.set_defaults(pre_dump=phaul.p_haul_iters.PRE_DUMP_AUTO_DETECT)
+
 args = parser.parse_args()
 
 # Configure logging
diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index 06049d3..971a68e 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -11,6 +11,10 @@ import criu_api
 import criu_req
 import p_haul_type
 
+PRE_DUMP_AUTO_DETECT = None
+PRE_DUMP_DISABLE = False
+PRE_DUMP_ENABLE = True
+
 # Constants for iterations management
 #
 # Maximum number of iterations
@@ -41,6 +45,8 @@ class phaul_iter_worker:
 
 		self.pid = self.htype.root_task_pid()
 
+		self.pre_dump = PRE_DUMP_AUTO_DETECT
+
 		logging.info("Setting up remote")
 		self.target_host.setup(p_type)
 
@@ -55,6 +61,7 @@ class phaul_iter_worker:
 		self.htype.set_options(opts)
 		self.fs.set_options(opts)
 		self.__force = opts["force"]
+		self.pre_dump = opts["pre_dump"]
 
 	def validate_cpu(self):
 		logging.info("Checking CPU compatibility")
@@ -87,23 +94,29 @@ class phaul_iter_worker:
 		self.fs.set_work_dir(self.img.work_dir())
 		self.fs.start_migration()
 
-		logging.info("Checking for Dirty Tracking")
-		req = criu_req.make_dirty_tracking_req(self.htype, self.img)
-		resp = self.criu_connection.send_req(req)
+		if self.pre_dump == PRE_DUMP_AUTO_DETECT:
+			# pre-dump auto-detection
+			logging.info("Checking for Dirty Tracking")
+			req = criu_req.make_dirty_tracking_req(self.htype, self.img)
+			resp = self.criu_connection.send_req(req)
+			self.pre_dump = resp.success
+		elif self.pre_dump == PRE_DUMP_DISABLE:
+			self.pre_dump = False
+		else:
+			self.pre_dump = True
 
-		pre_dump = False
 		if resp.success:
 			if resp.HasField('features'):
 				if resp.features.HasField('mem_track'):
 					if resp.features.mem_track:
 						logging.info("Starting iterations")
-						pre_dump = True
+						self.pre_dump = True
 			else:
 				self.criu_connection.memory_tracking(False)
 		else:
 			self.criu_connection.memory_tracking(False)
 
-		while pre_dump:
+		while self.pre_dump:
 			logging.info("* Iteration %d", iter_index)
 
 			self.target_host.start_iter()
-- 
1.8.3.1



More information about the CRIU mailing list