[CRIU] [PATCH 03/12] p.haul: Implement class shared_ploop
Nikita Spiridonov
nspiridonov at virtuozzo.com
Tue Apr 5 02:42:59 PDT 2016
Acked-by: Nikita Spiridonov <nspiridonov at virtuozzo.com>
On Fri, 2016-04-01 at 18:45 +0300, Alexander Burluka wrote:
> This class is required to do migration on ploops located
> on pstorage or other shared filesystems. That migration
> is performed via two snapshot scheme.
>
> Signed-off-by: Alexander Burluka <aburluka at virtuozzo.com>
> ---
> phaul/fs_haul_ploop.py | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/phaul/fs_haul_ploop.py b/phaul/fs_haul_ploop.py
> index b436d19..61c7465 100644
> --- a/phaul/fs_haul_ploop.py
> +++ b/phaul/fs_haul_ploop.py
> @@ -3,6 +3,7 @@
> #
>
> import os
> +import shutil
> import logging
> import threading
> import libploop
> @@ -31,6 +32,32 @@ def get_ploop_delta_abspath(delta_path, ct_priv):
> return os.path.join(ct_priv, delta_path)
>
>
> +def merge_ploop_snapshot(ddxml, guid):
> + libploop.snapshot(ddxml).delete(guid)
> +
> +
> +class shared_ploop:
> + def __init__(self, path):
> + self.backup_ddxml = get_ddxml_path(path) + ".copy"
> + self.orig_ddxml = get_ddxml_path(path)
> +
Minor - it is better to make backup_ddxml and orig_ddxml private
(self.__backup_ddxml and self.__orig_ddxml); up to you fix or not.
> + def prepare(self):
> + shutil.copyfile(self.orig_ddxml, self.backup_ddxml)
> + self.orig_guid = libploop.snapshot(self.orig_ddxml).create_offline()
> + self.backup_guid = libploop.snapshot(self.backup_ddxml).create()
> +
> + def restore(self):
> + if self.backup_guid:
> + os.rename(self.backup_ddxml, self.orig_ddxml)
> + merge_ploop_snapshot(self.orig_ddxml, self.backup_guid)
> +
> + def cleanup(self):
> + if self.orig_guid:
> + # TODO add delta removing when igor add it to libploop
> + os.remove(self.backup_ddxml)
> + os.remove(self.backup_ddxml + ".lck")
> +
> +
> class p_haul_fs:
> def __init__(self, deltas, ct_priv):
> """Initialize ploop disks hauler
More information about the CRIU
mailing list