[CRIU] [PATCH 3/6] p.haul: handle multiple disks in ploop fs hauler

Nikita Spiridonov nspiridonov at odin.com
Mon Dec 14 02:15:28 PST 2015


Add multiple disks migration support to ploop fs hauler. Now
p_haul_fs and p_haul_fs_receiver accept list of active deltas
with corresponding sockets.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 phaul/fs_haul_ploop.py |   50 ++++++++++++++++++++++++++++++++---------------
 phaul/p_haul_vz.py     |   29 +++------------------------
 2 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/phaul/fs_haul_ploop.py b/phaul/fs_haul_ploop.py
index bf58374..dc115d3 100644
--- a/phaul/fs_haul_ploop.py
+++ b/phaul/fs_haul_ploop.py
@@ -12,15 +12,21 @@ DDXML_FILENAME = "DiskDescriptor.xml"
 
 
 class p_haul_fs:
-	def __init__(self, ddxml_path, fs_sk):
-		"""Initialize ploop disk hauler
+	def __init__(self, deltas):
+		"""Initialize ploop disks hauler
 
-		Initialize ploop disk hauler with specified path to DiskDescriptor.xml
-		file and socket.
+		For each disk create libploop.ploopcopy object using path to disk
+		descriptor file and corresponding socket.
 		"""
 
-		logging.info("Initilized ploop hauler (%s)", ddxml_path)
-		self.__ploopcopy = libploop.ploopcopy(ddxml_path, fs_sk.fileno())
+		# Create libploop.ploopcopy objects, one per active ploop delta
+		self.__log_init_hauler(deltas)
+		self.__ploop_copies = []
+		for delta_path, delta_fd in deltas:
+			ddxml_path = self.__get_ddxml_path(delta_path)
+			self.__check_ddxml(ddxml_path)
+			self.__ploop_copies.append(
+				libploop.ploopcopy(ddxml_path, delta_fd))
 
 	def set_options(self, opts):
 		pass
@@ -29,13 +35,16 @@ class p_haul_fs:
 		pass
 
 	def start_migration(self):
-		self.__ploopcopy.copy_start()
+		for ploopcopy in self.__ploop_copies:
+			ploopcopy.copy_start()
 
 	def next_iteration(self):
-		self.__ploopcopy.copy_next_iteration()
+		for ploopcopy in self.__ploop_copies:
+			ploopcopy.copy_next_iteration()
 
 	def stop_migration(self):
-		self.__ploopcopy.copy_stop()
+		for ploopcopy in self.__ploop_copies:
+			ploopcopy.copy_stop()
 
 	def persistent_inodes(self):
 		"""Inode numbers do not change during ploop disk migration"""
@@ -57,20 +66,29 @@ class p_haul_fs:
 
 
 class p_haul_fs_receiver:
-	def __init__(self, fname_path, fs_sk):
-		"""Initialize ploop disk receiver
+	def __init__(self, deltas):
+		"""Initialize ploop disks receiver
 
-		Initialize ploop disk receiver with specified path to root.hds file
-		and socket.
+		For each disk create delta receiver object using path to active delta
+		of the ploop disk and corresponding socket.
 		"""
 
-		self.__delta_receiver = delta_receiver(fname_path, fs_sk)
+		# Create delta_receiver objects, one per active ploop delta
+		self.__log_init_receiver(deltas)
+		self.__delta_receivers = []
+		for delta_path, delta_fd in deltas:
+			self.__check_delta(delta_path)
+			self.__delta_receivers.append(delta_receiver(delta_path, delta_fd))
 
 	def start_receive(self):
-		self.__delta_receiver.start()
+		"""Start all delta receiver threads"""
+		for receiver in self.__delta_receivers:
+			receiver.start()
 
 	def stop_receive(self):
-		self.__delta_receiver.join()
+		"""Join all delta receiver threads"""
+		for receiver in self.__delta_receivers:
+			receiver.join()
 
 	def __log_init_receiver(self, deltas):
 		logging.info("Initialize ploop receiver")
diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index da62d2b..db13f2d 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -8,7 +8,6 @@ import shlex
 import logging
 import criu_cr
 import util
-import fs_haul_shared
 import fs_haul_ploop
 import pycriu.rpc
 
@@ -190,32 +189,12 @@ class p_haul_type:
 			self._fs_mounted = False
 
 	def get_fs(self, fs_sk=None):
-		rootfs = self.__get_priv_fs_name()
-		logging.info("CT is on %s", rootfs)
-		if rootfs == "nfs":
-			return fs_haul_shared.p_haul_fs()
-		elif rootfs == "ext3" or rootfs == "ext4":
-			ddxml_path = os.path.join(self._ct_priv, "root.hdd",
-				"DiskDescriptor.xml")
-			return fs_haul_ploop.p_haul_fs(ddxml_path, fs_sk)
-		else:
-			logging.error("Unknown CT FS")
-			return None
+		deltas = [(os.path.join(self._ct_priv, "root.hdd", "root.hds"), fs_sk)]
+		return fs_haul_ploop.p_haul_fs(deltas)
 
 	def get_fs_receiver(self, fs_sk=None):
-		rootfs = self.__get_priv_fs_name()
-		logging.info("CT is on %s", rootfs)
-		if rootfs == "ext3" or rootfs == "ext4":
-			fname_path = os.path.join(self._ct_priv, "root.hdd", "root.hds")
-			return fs_haul_ploop.p_haul_fs_receiver(fname_path, fs_sk)
-		else:
-			return None
-
-	def __get_priv_fs_name(self):
-		rootfs = util.path_to_fs(self._ct_priv)
-		if not rootfs:
-			raise Exception("CT is on unknown FS")
-		return rootfs
+		deltas = [(os.path.join(self._ct_priv, "root.hdd", "root.hds"), fs_sk)]
+		return fs_haul_ploop.p_haul_fs_receiver(deltas)
 
 	def restored(self, pid):
 		pass
-- 
1.7.1



More information about the CRIU mailing list