[CRIU] [PATCH 2/6] p.haul: add helper methods to fs hauler/receiver needed to handle multiple disks

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


Equip ploop fs hauler and receiver with helper methods needed to handle
multiple disks migration.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 phaul/fs_haul_ploop.py |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/phaul/fs_haul_ploop.py b/phaul/fs_haul_ploop.py
index 728a029..bf58374 100644
--- a/phaul/fs_haul_ploop.py
+++ b/phaul/fs_haul_ploop.py
@@ -2,11 +2,15 @@
 # ploop disk hauler
 #
 
+import os
 import logging
 import threading
 import libploop
 
 
+DDXML_FILENAME = "DiskDescriptor.xml"
+
+
 class p_haul_fs:
 	def __init__(self, ddxml_path, fs_sk):
 		"""Initialize ploop disk hauler
@@ -37,6 +41,20 @@ class p_haul_fs:
 		"""Inode numbers do not change during ploop disk migration"""
 		return True
 
+	def __log_init_hauler(self, deltas):
+		logging.info("Initialize ploop hauler")
+		for delta in deltas:
+			logging.info("\t`- %s", delta[0])
+
+	def __get_ddxml_path(self, delta_path):
+		"""Get path to disk descriptor file by path to disk delta"""
+		return os.path.join(os.path.dirname(delta_path), DDXML_FILENAME)
+
+	def __check_ddxml(self, ddxml_path):
+		"""Check disk descriptor file exist"""
+		if not os.path.isfile(ddxml_path):
+			raise Exception("{0} file missing".format(ddxml_path))
+
 
 class p_haul_fs_receiver:
 	def __init__(self, fname_path, fs_sk):
@@ -54,6 +72,21 @@ class p_haul_fs_receiver:
 	def stop_receive(self):
 		self.__delta_receiver.join()
 
+	def __log_init_receiver(self, deltas):
+		logging.info("Initialize ploop receiver")
+		for delta in deltas:
+			logging.info("\t`- %s", delta[0])
+
+	def __check_delta(self, delta_path):
+		"""Check delta file don't exist and parent directory exist"""
+
+		delta_dir = os.path.dirname(delta_path)
+		if not os.path.isdir(delta_dir):
+			raise Exception("{0} directory missing".format(delta_dir))
+
+		if os.path.isfile(delta_path):
+			raise Exception("{0} already exist".format(delta_path))
+
 
 class delta_receiver(threading.Thread):
 	def __init__(self, delta_path, delta_fd):
-- 
1.7.1



More information about the CRIU mailing list