[CRIU] [PATCH 5/7] htype: Make final dump be htype method
Hui Kang
hkang.sunysb at gmail.com
Thu Oct 22 13:05:23 PDT 2015
On Thu, Oct 22, 2015 at 8:46 AM, Pavel Emelyanov <xemul at parallels.com> wrote:
> For Docker (and actually for everybody, but pid, else) it makes
> perfect sense to make final dump request via htype's API, not
> via CRIU directly.
>
> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
> ---
> phaul/p_haul_iters.py | 24 +-----------------------
> phaul/p_haul_lxc.py | 3 +++
> phaul/p_haul_module.py | 24 ++++++++++++++++++++++++
> phaul/p_haul_pid.py | 3 +++
> phaul/p_haul_vz.py | 3 +++
> 5 files changed, 34 insertions(+), 23 deletions(-)
>
> diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
> index 8e3afbd..6ad0a91 100644
> --- a/phaul/p_haul_iters.py
> +++ b/phaul/p_haul_iters.py
> @@ -190,29 +190,7 @@ class phaul_iter_worker:
> self.img.new_image_dir()
>
> logging.info("\tIssuing dump command to service")
> -
> - req = criu_req.make_dump_req(
> - self.pid, self.htype, self.img, self.criu_connection, self.fs)
> - resp = self.criu_connection.send_req(req)
> - while True:
> - if resp.type != pycriu.rpc.NOTIFY:
> - raise Exception("Dump failed")
> -
> - if resp.notify.script == "post-dump":
> - #
> - # Dump is effectively over. Now CRIU
> - # waits for us to do whatever we want
> - # and keeps the tasks frozen.
> - #
> - break
> -
> - elif resp.notify.script == "network-lock":
> - self.htype.net_lock()
> - elif resp.notify.script == "network-unlock":
> - self.htype.net_unlock()
> -
> - logging.info("\t\tNotify (%s)", resp.notify.script)
> - resp = self.criu_connection.ack_notify()
> + self.htype.final_dump(self.pid, self.img, self.criu_connection, self.fs)
>
> logging.info("Dump complete")
> self.target_host.end_iter()
> diff --git a/phaul/p_haul_lxc.py b/phaul/p_haul_lxc.py
> index 702ade2..0f685d9 100644
> --- a/phaul/p_haul_lxc.py
> +++ b/phaul/p_haul_lxc.py
> @@ -114,6 +114,9 @@ class p_haul_type:
> logging.info("Putting config file into %s", lxc_dir)
> shutil.copy(os.path.join(dir, "config"), self.__ct_config())
>
> + def final_dump(self, pid, img, ccon, fs):
> + p_haul_module.criu_dump(self, pid, img, ccon, fs)
> +
> def final_restore(self, img, connection):
> p_haul_module.criu_restore(self, img, connection)
>
> diff --git a/phaul/p_haul_module.py b/phaul/p_haul_module.py
> index fdd4ca6..b97f8e1 100644
> --- a/phaul/p_haul_module.py
> +++ b/phaul/p_haul_module.py
> @@ -6,6 +6,30 @@ import logging
> import pycriu.rpc
> import criu_req
>
> +def criu_dump(htype, pid, img, criu_connection, fs):
> + req = criu_req.make_dump_req(pid, htype, img, criu_connection, fs)
> + resp = criu_connection.send_req(req)
> + while True:
> + if resp.type != pycriu.rpc.NOTIFY:
> + raise Exception("Dump failed")
> +
> + if resp.notify.script == "post-dump":
> + #
> + # Dump is effectively over. Now CRIU
> + # waits for us to do whatever we want
> + # and keeps the tasks frozen.
> + #
> + break
> +
> + elif resp.notify.script == "network-lock":
> + htype.net_lock()
> + elif resp.notify.script == "network-unlock":
> + htype.net_unlock()
> +
> + logging.info("\t\tNotify (%s)", resp.notify.script)
> + resp = criu_connection.ack_notify()
> +
> +
> def criu_restore(htype, img, connection):
> """Perform final restore"""
>
> diff --git a/phaul/p_haul_pid.py b/phaul/p_haul_pid.py
> index 7b381a9..19e3b21 100644
> --- a/phaul/p_haul_pid.py
> +++ b/phaul/p_haul_pid.py
> @@ -62,6 +62,9 @@ class p_haul_type:
> def put_meta_images(self, dir):
> pass
>
> + def final_dump(self, pid, img, ccon, fs):
> + p_haul_module.criu_dump(self, pid, img, ccon, fs)
> +
> def final_restore(self, img, connection):
> p_haul_module.criu_restore(self, img, connection)
>
> diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
> index 13f3fd1..7148663 100644
> --- a/phaul/p_haul_vz.py
> +++ b/phaul/p_haul_vz.py
> @@ -147,6 +147,9 @@ class p_haul_type:
> if os.path.isfile(path):
> os.remove(path)
>
> + def final_dump(self, pid, img, ccon, fs):
> + p_haul_module.criu_dump(self, pid, img, ccon, fs)
Should final_dump() call vz specific API, like "vzctl dump"? Thanks.
- Hui
> +
> def final_restore(self, img, connection):
> """Perform Virtuozzo-specific final restore"""
> try:
> --
> 1.9.3
>
>
More information about the CRIU
mailing list