[CRIU] [PATCH 06/12] p.haul: modify p_haul_fs initialization

Nikita Spiridonov nspiridonov at virtuozzo.com
Tue Apr 5 03:11:53 PDT 2016


On Fri, 2016-04-01 at 18:45 +0300, Alexander Burluka wrote:
> Add migration mode variable and parsing of shared disks
> 
> Signed-off-by: Alexander Burluka <aburluka at virtuozzo.com>
> ---
>  phaul/fs_haul_ploop.py | 11 +++++++++--
>  phaul/iters.py         | 10 ++++++----
>  phaul/p_haul_vz.py     |  4 ++--
>  3 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/phaul/fs_haul_ploop.py b/phaul/fs_haul_ploop.py
> index 63c2a64..f59f831 100644
> --- a/phaul/fs_haul_ploop.py
> +++ b/phaul/fs_haul_ploop.py
> @@ -8,6 +8,7 @@ import logging
>  import threading
>  import libploop
>  import mstats
> +import iters
>  
> 
>  DDXML_FILENAME = "DiskDescriptor.xml"
> @@ -59,7 +60,7 @@ class shared_ploop:
>  
> 
>  class p_haul_fs:
> -	def __init__(self, deltas, ct_priv):
> +	def __init__(self, deltas, ct_priv, mode):
>  		"""Initialize ploop disks hauler
>  
>  		For each disk create libploop.ploopcopy object using path to disk
> @@ -69,6 +70,8 @@ class p_haul_fs:
>  		# Create libploop.ploopcopy objects, one per active ploop delta
>  		self.__log_init_hauler(deltas)
>  		self.__ct_priv = ct_priv
> +		self.__mode = mode

I think it is better to remove self.__mode variable from p_haul_fs at
all. You can access it directly in set_options and depending on its
value decide to create shared_ploop objects. Further,
prepare_shared_backups, restore_shared_backups, cleanup_shared_backups
functions actually don't need to know this mode - they can just iterate
self.__shared_ploops which will be empty for improper modes.

> +		self.__shared_ploops = []
>  		self.__ploop_copies = []
>  		for delta_path, delta_fd in deltas:
>  			ddxml_path = get_ddxml_path(delta_path)
> @@ -82,7 +85,11 @@ class p_haul_fs:
>  		return (get_ploop_delta_abspath(s, self.__ct_priv) for s in shareds.split(","))
>  
>  	def set_options(self, opts):
> -		pass
> +		if iters.is_live_mode(self.__mode):
> +			if "shared" in opts:
> +				shareds = self.__parse_shared_ploops(opts["shared"])

Please replace with opts.get("shared") call and remove nested if
statement. get return None if specified key missing in dictionary and as
far as I can see __parse_shared_ploops handle this case.

> +				for shared in shareds:
> +					self.__shared_ploops.append(shared_ploop(shared))
>  
>  	def set_work_dir(self, wdir):
>  		pass
> diff --git a/phaul/iters.py b/phaul/iters.py
> index cbac565..9a2f325 100644
> --- a/phaul/iters.py
> +++ b/phaul/iters.py
> @@ -59,15 +59,17 @@ class phaul_iter_worker:
>  		if not self.htype:
>  			raise Exception("No htype driver found")
>  
> -		self.fs = self.htype.get_fs(self.connection.fdfs)
> -		if not self.fs:
> -			raise Exception("No FS driver found")
> -
>  		self.img = None
>  		self.criu_connection = None
> +		m = None
>  		if is_live_mode(self.__mode):
>  			self.img = images.phaul_images("dmp")
>  			self.criu_connection = criu_api.criu_conn(self.connection.mem_sk)
> +			m = self.__mode

Please remove m local variable and use self.__mode instead. self.__mode
variable always initialized so m redundant here.

> +
> +		self.fs = self.htype.get_fs(self.connection.fdfs, m)

It is incorrect to pass mode to get_fs. This signature correct for vz
module only, processing of mode in pid, lxc and docket modules is
missing. I suggest to remove this argument from get_fs, see comments
above.

> +		if not self.fs:
> +			raise Exception("No FS driver found")
>  
>  		logging.info("Setting up remote")
>  		self.target_host.setup(p_type, mode)
> diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
> index 49c756a..8055f69 100644
> --- a/phaul/p_haul_vz.py
> +++ b/phaul/p_haul_vz.py
> @@ -233,9 +233,9 @@ class p_haul_type:
>  		logging.info(proc_output)
>  		self._fs_mounted = not umount
>  
> -	def get_fs(self, fdfs=None):
> +	def get_fs(self, fdfs=None, mode=None):
>  		deltas = self.__parse_fdfs_arg(fdfs)
> -		return fs_haul_ploop.p_haul_fs(deltas, self._ct_priv)
> +		return fs_haul_ploop.p_haul_fs(deltas, self._ct_priv, mode)
>  
>  	def get_fs_receiver(self, fdfs=None):
>  		deltas = self.__parse_fdfs_arg(fdfs)




More information about the CRIU mailing list