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

Nikita Spiridonov nspiridonov at virtuozzo.com
Tue Apr 5 02:40:44 PDT 2016


Acked-by: Nikita Spiridonov <nspiridonov at virtuozzo.com>

On Fri, 2016-04-01 at 18:45 +0300, Alexander Burluka wrote:
> move get_ploop_delta_abspath from p_haul_vz class to
> outstanding function 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 fb6ed0b..b436d19 100644
> --- a/phaul/fs_haul_ploop.py
> +++ b/phaul/fs_haul_ploop.py
> @@ -17,8 +17,22 @@ def get_ddxml_path(delta_path):
>  	return os.path.join(os.path.dirname(delta_path), DDXML_FILENAME)
>  
> 
> +def get_ploop_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)
> +

Minor - get_delta_abspath is a better name since we already in
fs_faul_ploop module; up to you fix it or not.

> +
>  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
> @@ -27,6 +41,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..c20ed5b 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_ploop_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
>  




More information about the CRIU mailing list