[CRIU] [PATCH v2 03/12] p.haul: Implement class shared_ploop
Nikita Spiridonov
nspiridonov at virtuozzo.com
Mon Apr 11 04:58:59 PDT 2016
Acked-by: Nikita Spiridonov <nspiridonov at virtuozzo.com>
On Sat, 2016-04-09 at 16:41 +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 7c8a84e..3fde112 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
> @@ -32,6 +33,32 @@ def get_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)
> +
> + 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