[CRIU] [PATCH v3 02/12] p.haul: move get_ploop_delta_abspath

Alexander Burluka aburluka at virtuozzo.com
Mon Apr 11 09:28:58 PDT 2016


move get_ploop_delta_abspath from p_haul_vz class to
outstanding function get_delta_abspath in fs_haul_ploop

Signed-off-by: Alexander Burluka <aburluka at virtuozzo.com>
---
 phaul/fs_haul_ploop.py | 17 ++++++++++++++++-
 phaul/p_haul_vz.py     | 17 ++---------------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/phaul/fs_haul_ploop.py b/phaul/fs_haul_ploop.py
index 89463c3..7c8a84e 100644
--- a/phaul/fs_haul_ploop.py
+++ b/phaul/fs_haul_ploop.py
@@ -18,8 +18,22 @@ def get_ddxml_path(path):
 	return os.path.join(p, DDXML_FILENAME)
 
 
+def get_delta_abspath(delta_path, ct_priv):
+	"""
+	Transform delta path to absolute form
+
+	If delta path starts with a slash it is already in absolute form,
+	otherwise it is relative to containers private.
+	"""
+
+	if delta_path.startswith("/"):
+		return delta_path
+	else:
+		return os.path.join(ct_priv, delta_path)
+
+
 class p_haul_fs:
-	def __init__(self, deltas):
+	def __init__(self, deltas, ct_priv):
 		"""Initialize ploop disks hauler
 
 		For each disk create libploop.ploopcopy object using path to disk
@@ -28,6 +42,7 @@ class p_haul_fs:
 
 		# Create libploop.ploopcopy objects, one per active ploop delta
 		self.__log_init_hauler(deltas)
+		self.__ct_priv = ct_priv
 		self.__ploop_copies = []
 		for delta_path, delta_fd in deltas:
 			ddxml_path = get_ddxml_path(delta_path)
diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index a7dedae..663d474 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -235,7 +235,7 @@ class p_haul_type:
 
 	def get_fs(self, fdfs=None):
 		deltas = self.__parse_fdfs_arg(fdfs)
-		return fs_haul_ploop.p_haul_fs(deltas)
+		return fs_haul_ploop.p_haul_fs(deltas, self._ct_priv)
 
 	def get_fs_receiver(self, fdfs=None):
 		deltas = self.__parse_fdfs_arg(fdfs)
@@ -259,23 +259,10 @@ class p_haul_type:
 		deltas = []
 		for delta in fdfs.split(FDFS_DELTAS_SEPARATOR):
 			path, dummy, fd = delta.rpartition(FDFS_PAIR_SEPARATOR)
-			deltas.append((self.__get_ploop_delta_abspath(path), int(fd)))
+			deltas.append((fs_haul_ploop.get_delta_abspath(path, self._ct_priv), int(fd)))
 
 		return deltas
 
-	def __get_ploop_delta_abspath(self, delta_path):
-		"""
-		Transform delta path to absolute form
-
-		If delta path starts with a slash it is already in absolute form,
-		otherwise it is relative to containers private.
-		"""
-
-		if delta_path.startswith("/"):
-			return delta_path
-		else:
-			return os.path.join(self._ct_priv, delta_path)
-
 	def restored(self, pid):
 		pass
 
-- 
1.8.3.1



More information about the CRIU mailing list