[CRIU] [PATCH 2/3] p.haul: create base class for all p.haul modules
Pavel Emelyanov
xemul at parallels.com
Thu Sep 3 00:41:40 PDT 2015
> @@ -0,0 +1,44 @@
> +#
> +# Base for p.haul modules with generic functionality
> +#
> +
> +import pycriu.rpc
> +import criu_req
> +
> +class phaul_module:
> + """Basic module with generic functionality"""
> +
> + def final_restore(self, img, connection):
Overall I like the base class for htypes, but this final_restore is not
going to be used by ANY of them. For vz we already have vz-specific one,
LXC people will want to use their own (for the same reason), so will be
the Docker guys.
That said, sorry for late response, but let's do this set w/o the base
class for htypes.
> + """Perform final restore"""
> +
> + nroot = self.mount()
> + if nroot:
> + print "Restore root set to %s" % nroot
> +
> + req = criu_req.make_restore_req(self, img, nroot)
> + resp = connection.send_req(req)
> + while True:
> + if resp.type == pycriu.rpc.NOTIFY:
> + print "\t\tNotify (%s.%d)" % (resp.notify.script, resp.notify.pid)
> + if resp.notify.script == "setup-namespaces":
> + #
> + # At that point we have only one task
> + # living in namespaces and waiting for
> + # us to ACK the notify. Htype might want
> + # to configure namespace (external net
> + # devices) and cgroups
> + #
> + self.prepare_ct(resp.notify.pid)
> + elif resp.notify.script == "network-unlock":
> + self.net_unlock()
> + elif resp.notify.script == "network-lock":
> + raise Exception("Locking network on restore?")
> +
> + resp = connection.ack_notify()
> + continue
> +
> + if not resp.success:
> + raise Exception("Restore failed")
> + break
> +
> + self.restored(resp.restore.pid)
More information about the CRIU
mailing list