[CRIU] [PATCH 2/2] p.haul: allow specify module-specific criu options

Nikita Spiridonov nspiridonov at odin.com
Thu Jun 25 02:00:02 PDT 2015


We have to specify --ext-mount-map auto, --enable-external-sharing
and --enable-external-masters options in criu dump and restore
requests during Virtuozzo container migration to make it work. To
make it real add possibility that allow specify module-specific
criu request options.

Now every phaul module (e.g. Virtuozzo or LXC) have method
adjust_criu_req; any module-specific request options can be
specified in this method.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 phaul/p_haul_iters.py   |    1 +
 phaul/p_haul_lxc.py     |    4 ++++
 phaul/p_haul_pid.py     |    4 ++++
 phaul/p_haul_service.py |    1 +
 phaul/p_haul_vz.py      |    9 +++++++++
 5 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index 5932bef..3a2585a 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -203,6 +203,7 @@ class phaul_iter_worker:
 		"""Prepare generic criu request"""
 		req = cr_rpc.criu_req()
 		req.type = typ
+		self.htype.adjust_criu_req(req)
 		return req
 
 	def __make_common_dump_req(self, typ):
diff --git a/phaul/p_haul_lxc.py b/phaul/p_haul_lxc.py
index 27df698..13640d2 100644
--- a/phaul/p_haul_lxc.py
+++ b/phaul/p_haul_lxc.py
@@ -76,6 +76,10 @@ class p_haul_type:
 	def set_options(self, opts):
 		pass
 
+	def adjust_criu_req(self, req):
+		"""Add module-specific options to criu request"""
+		pass
+
 	def root_task_pid(self):
 		pid = -1;
 
diff --git a/phaul/p_haul_pid.py b/phaul/p_haul_pid.py
index f0051b0..5bd2d5d 100644
--- a/phaul/p_haul_pid.py
+++ b/phaul/p_haul_pid.py
@@ -24,6 +24,10 @@ class p_haul_type:
 		self._pidfile = opts["dst_rpid"]
 		self._fs_root = opts["pid_root"]
 
+	def adjust_criu_req(self, req):
+		"""Add module-specific options to criu request"""
+		pass
+
 	# Report the pid of the root task of what we're
 	# goung to migrate
 	def root_task_pid(self):
diff --git a/phaul/p_haul_service.py b/phaul/p_haul_service.py
index e37e7fc..50eab03 100644
--- a/phaul/p_haul_service.py
+++ b/phaul/p_haul_service.py
@@ -125,6 +125,7 @@ class phaul_service:
 		"""Prepare generic criu request"""
 		req = cr_rpc.criu_req()
 		req.type = typ
+		self.htype.adjust_criu_req(req)
 		return req
 
 	def __make_page_server_req(self):
diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index 40dc943..7f41816 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -8,6 +8,7 @@ import p_haul_cgroup
 import util
 import fs_haul_shared
 import fs_haul_subtree
+import pycriu.rpc
 
 name = "vz"
 vz_dir = "/vz"
@@ -72,6 +73,14 @@ class p_haul_type:
 	def set_options(self, opts):
 		pass
 
+	def adjust_criu_req(self, req):
+		"""Add module-specific options to criu request"""
+		if req.type == pycriu.rpc.DUMP or req.type == pycriu.rpc.RESTORE:
+			# Setup options for external mounts resolution
+			req.opts.auto_ext_mnt = True
+			req.opts.ext_sharing = True
+			req.opts.ext_masters = True
+
 	def root_task_pid(self):
 		# Expect first line of tasks file contain root pid of CT
 		path = "/sys/fs/cgroup/memory/{0}/tasks".format(self._ctid)
-- 
1.7.1



More information about the CRIU mailing list