[CRIU] [PATCH v4 5/6] p.haul: handle older criu RPC interfaces
Adrian Reber
adrian at lisas.de
Mon Oct 12 07:24:31 PDT 2015
From: Adrian Reber <areber at redhat.com>
Wrap the calls to the new feature-check RPC interface into try: except:
to continue gracefully without stack traces. If the installed criu
supports feature-check it will be used to detect if memory tracking
should be enabled. If the installed criu is too old to support
feature-check no pre-dumping will be performed. Pre-dumps can still be
manually enabled via p.haul's command-line.
v2: rebased
v3: rebased
v4: avoid code duplication using Nikita Spiridonov's example
Signed-off-by: Adrian Reber <areber at redhat.com>
---
phaul/criu_req.py | 25 +++++++++++++++++--------
phaul/p_haul_iters.py | 40 ++++++++++++++++++++++++++++------------
2 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/phaul/criu_req.py b/phaul/criu_req.py
index d97d4cf..3cc1721 100644
--- a/phaul/criu_req.py
+++ b/phaul/criu_req.py
@@ -4,16 +4,25 @@
import pycriu.rpc
-_names = {
- pycriu.rpc.DUMP: "dump",
- pycriu.rpc.PRE_DUMP: "pre_dump",
- pycriu.rpc.PAGE_SERVER: "page_server",
- pycriu.rpc.RESTORE: "restore",
- pycriu.rpc.CPUINFO_DUMP: "cpuinfo-dump",
- pycriu.rpc.CPUINFO_CHECK: "cpuinfo-check",
- pycriu.rpc.FEATURE_CHECK: "feature-check",
+def _build_names(name_strings):
+ names = {}
+ for key, value in name_strings.items():
+ if hasattr(pycriu.rpc, key):
+ names[getattr(pycriu.rpc, key)] = value
+ return names
+
+_name_strings = {
+ "DUMP": "dump",
+ "PRE_DUMP": "pre_dump",
+ "PAGE_SERVER": "page_server",
+ "RESTORE": "restore",
+ "CPUINFO_DUMP": "cpuinfo-dump",
+ "CPUINFO_CHECK": "cpuinfo-check",
+ "FEATURE_CHECK": "feature-check",
}
+_names = _build_names(_name_strings)
+
def get_name(req_type):
"""Return printable request name"""
return _names[req_type]
diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index 971a68e..91d4392 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -94,25 +94,41 @@ class phaul_iter_worker:
self.fs.set_work_dir(self.img.work_dir())
self.fs.start_migration()
+ logging.info("Checking for Dirty Tracking")
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
+ 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
+ else:
+ logging.info("\t`- Auto Disabled")
+
+ except:
+ # The available criu seems to not
+ # support memory tracking auto detection.
+ self.pre_dump = False
+ 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 resp.success:
- if resp.HasField('features'):
- if resp.features.HasField('mem_track'):
- if resp.features.mem_track:
- logging.info("Starting iterations")
- self.pre_dump = True
- else:
- self.criu_connection.memory_tracking(False)
+ if self.pre_dump:
+ logging.info("Starting iterations")
else:
self.criu_connection.memory_tracking(False)
--
1.8.3.1
More information about the CRIU
mailing list