[CRIU] [PATCH 1/3] Automatically detect dirty memory tracking
Adrian Reber
adrian at lisas.de
Tue Sep 29 03:32:08 PDT 2015
From: Adrian Reber <areber at redhat.com>
Use the newly added dirty-tracking RPC detection to automatically
enable or disable pre-dumps.
Signed-off-by: Adrian Reber <areber at redhat.com>
---
phaul/criu_api.py | 5 +++++
phaul/criu_req.py | 10 +++++++++-
phaul/p_haul_iters.py | 11 +++++++++--
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 2946e6d..3251ccb 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])
print "`- 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..2d2a10f 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.DIRTY_TRACKING: "dirty-tracking",
}
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,11 @@ 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.DIRTY_TRACKING, htype)
+ 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 bca28de..46ddf42 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -81,9 +81,16 @@ class phaul_iter_worker:
self.fs.set_work_dir(self.img.work_dir())
self.fs.start_migration()
- print "Starting iterations"
+ print "Checking for Dirty Tracking"
+ req = criu_req.make_dirty_tracking_req(self.htype, self.img)
+ resp = self.criu.send_req(req)
- while True:
+ if resp.success:
+ print "Starting iterations"
+ else:
+ self.criu.memory_tracking(False)
+
+ while resp.success:
print "* Iteration %d" % self.iteration
self.th.start_iter()
--
1.8.3.1
More information about the CRIU
mailing list