[CRIU] [PATCH v3 1/6] p.haul: automatically detect dirty memory tracking
Adrian Reber
adrian at lisas.de
Thu Oct 8 07:06:44 PDT 2015
From: Adrian Reber <areber at redhat.com>
Use the newly added feature-check RPC to automatically detect
if pre-dumping should be enabled or disabled.
v2: rebased and using reworked FEATURE_CHECK interface
v3: rebased and using the 'features' protobuf message
Signed-off-by: Adrian Reber <areber at redhat.com>
---
phaul/criu_api.py | 5 +++++
phaul/criu_req.py | 11 ++++++++++-
phaul/p_haul_iters.py | 18 ++++++++++++++++--
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 81d22b1..9b2f369 100644
--- a/phaul/criu_api.py
+++ b/phaul/criu_api.py
@@ -25,6 +25,7 @@ class criu_conn:
def __init__(self, mem_sk):
self._iter = 0
self.verb = def_verb
+ self._track_mem = True
css = socket.socketpair(socket.AF_UNIX, socket.SOCK_SEQPACKET)
util.set_cloexec(css[1])
logging.info("`- Passing (ctl:%d, data:%d) pair to CRIU", css[0].fileno(), mem_sk.fileno())
@@ -55,6 +56,7 @@ class criu_conn:
def send_req(self, req):
req.opts.log_level = self.verb
req.opts.log_file = self.get_log_name(req.type)
+ req.opts.track_mem = self._track_mem
self._cs.send(req.SerializeToString())
self._iter += 1
self._last_req = req.type
@@ -72,6 +74,9 @@ class criu_conn:
def get_log_name(self, req_type):
return "criu_%s.%d.log" % (criu_req.get_name(req_type), self._iter)
+ def memory_tracking(self, value):
+ self._track_mem = value
+
#
# Helper to read CRIU-generated statistics
#
diff --git a/phaul/criu_req.py b/phaul/criu_req.py
index 42225aa..d97d4cf 100644
--- a/phaul/criu_req.py
+++ b/phaul/criu_req.py
@@ -11,6 +11,7 @@ _names = {
pycriu.rpc.RESTORE: "restore",
pycriu.rpc.CPUINFO_DUMP: "cpuinfo-dump",
pycriu.rpc.CPUINFO_CHECK: "cpuinfo-check",
+ pycriu.rpc.FEATURE_CHECK: "feature-check",
}
def get_name(req_type):
@@ -37,7 +38,6 @@ def _make_common_dump_req(typ, pid, htype, img, connection, fs):
req = _make_req(typ, htype)
req.opts.pid = pid
req.opts.ps.fd = connection.mem_sk_fileno()
- req.opts.track_mem = True
req.opts.images_dir_fd = img.image_dir_fd()
req.opts.work_dir_fd = img.work_dir_fd()
@@ -106,3 +106,12 @@ def make_restore_req(htype, img, nroot):
req.opts.root = nroot
return req
+
+def make_dirty_tracking_req(htype, img):
+ """Check if dirty memory tracking is supported."""
+ req = _make_req(pycriu.rpc.FEATURE_CHECK, htype)
+ req.features.mem_track = True
+ req.keep_open = True
+ req.opts.images_dir_fd = img.work_dir_fd()
+ return req
+
diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index 6050236..55dd819 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -86,9 +86,23 @@ class phaul_iter_worker:
self.fs.set_work_dir(self.img.work_dir())
self.fs.start_migration()
- logging.info("Starting iterations")
+ logging.info("Checking for Dirty Tracking")
+ req = criu_req.make_dirty_tracking_req(self.htype, self.img)
+ resp = self.criu_connection.send_req(req)
- while 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
+ else:
+ self.criu_connection.memory_tracking(False)
+ else:
+ self.criu_connection.memory_tracking(False)
+
+ while pre_dump:
logging.info("* Iteration %d", iter_index)
self.target_host.start_iter()
--
1.8.3.1
More information about the CRIU
mailing list