[CRIU] [PATCH v2 1/5] p.haul: automatically detect dirty memory tracking
Adrian Reber
adrian at lisas.de
Tue Oct 6 09:49:24 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.
Signed-off-by: Adrian Reber <areber at redhat.com>
---
phaul/criu_api.py | 5 +++++
phaul/criu_req.py | 11 ++++++++++-
phaul/p_haul_iters.py | 16 ++++++++++++++--
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 725b2db..702dbe4 100644
--- a/phaul/criu_api.py
+++ b/phaul/criu_api.py
@@ -26,6 +26,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())
@@ -56,6 +57,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
@@ -73,6 +75,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..cdf1d1e 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.feat_chk = 1 << pycriu.rpc.MEM_TRACK
+ 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 f23e799..d5767b3 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -82,9 +82,21 @@ 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.send_req(req)
- while True:
+ pre_dump = False
+ if resp.success:
+ if (resp.feat_res & (1 << cr_rpc.MEM_TRACK)):
+ logging.info("Starting iterations")
+ pre_dump = True
+ else:
+ self.criu.memory_tracking(False)
+ else:
+ self.criu.memory_tracking(False)
+
+ while pre_dump:
logging.info("* Iteration %d", self.iteration)
self.th.start_iter()
--
1.8.3.1
More information about the CRIU
mailing list