[CRIU,3/3] p.haul: specify secondary ploop disks as external in dump request options

Submitted by Nikita Spiridonov on June 21, 2016, 9:29 a.m.

Details

Message ID 1466501354-655212-4-git-send-email-nspiridonov@virtuozzo.com
State New
Series "Fix migration of Virtuozzo containers with multiple ploop disks"
Headers show

Commit Message

Nikita Spiridonov June 21, 2016, 9:29 a.m.
Specify secondary ploop disks (second, third and so on) as external
in dump request options for Virtuzzo containers.

Signed-off-by: Nikita Spiridonov <nspiridonov@virtuozzo.com>
---
 phaul/p_haul_vz.py |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

Patch hide | download patch | download mbox

diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index 8a5b296..50e4ba7 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -138,6 +138,12 @@  class p_haul_type:
 			for key, value in vz_cgroup_mount_map.items():
 				req.opts.ext_mnt.add(key=key, val=value)
 
+			# Specify secondary ploop disks as external
+			disks = self.__parse_secondary_disks_arg(self.__secondary_disks)
+			for uuid, major, minor in disks:
+				req.opts.external.append(
+					"dev[{0}/{1}]:{2}".format(major, minor + 1, uuid))
+
 			# Increase ghost-limit up to 50Mb
 			req.opts.ghost_limit = 50 << 20
 
@@ -313,6 +319,29 @@  class p_haul_type:
 
 		return deltas
 
+	def __parse_secondary_disks_arg(self, disks_arg):
+		"""
+		Parse string containing list of secondary disks in specific format
+
+		String contain list of secondary ploop disks in format
+		%uuid%:%major%:%minor%[,...]. Consider all additional disks of
+		container (second, third and so on) are secondary. Parse it and return
+		list of tuples.
+		"""
+
+		DISKS_SEPARATOR = ","
+		TUPLE_SEPARATOR = ":"
+
+		if not disks_arg:
+			return []
+
+		disks = []
+		for disk in disks_arg.split(DISKS_SEPARATOR):
+			uuid, major, minor = disk.split(TUPLE_SEPARATOR)
+			disks.append((uuid, int(major), int(minor)))
+
+		return disks
+
 
 def add_hauler_args(parser):
 	"""Add Virtuozzo specific command line arguments"""