[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 08 of 10] Add xm save -c/--checkpoint option
# HG changeset patch # User Brendan Cully <brendan@xxxxxxxxx> # Date 1166166342 28800 # Node ID a5274ebef731512d9681c7b81667b509f2e5346a # Parent d39e577379a3375d7340ef265d472f957694d8a0 Add xm save -c/--checkpoint option xm save --checkpoint leaves the domain running after creating the snapshot. Signed-off-by: Brendan Cully <brendan@xxxxxxxxx> diff -r d39e577379a3 -r a5274ebef731 tools/python/xen/xend/XendCheckpoint.py --- a/tools/python/xen/xend/XendCheckpoint.py Thu Dec 14 23:05:42 2006 -0800 +++ b/tools/python/xen/xend/XendCheckpoint.py Thu Dec 14 23:05:42 2006 -0800 @@ -51,7 +51,7 @@ def read_exact(fd, size, errmsg): return buf -def save(fd, dominfo, network, live, dst): +def save(fd, dominfo, network, live, dst, checkpoint=False): write_exact(fd, SIGNATURE, "could not write guest state file: signature") config = sxp.to_string(dominfo.sxpr()) @@ -83,7 +83,10 @@ def save(fd, dominfo, network, live, dst log.debug("In saveInputHandler %s", line) if line == "suspend": log.debug("Suspending %d ...", dominfo.getDomid()) - dominfo.shutdown('suspend') + if checkpoint: + dominfo.shutdown('checkpoint') + else: + dominfo.shutdown('suspend') dominfo.waitForShutdown() dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2, domain_name) @@ -96,7 +99,8 @@ def save(fd, dominfo, network, live, dst forkHelper(cmd, fd, saveInputHandler, False) - dominfo.destroyDomain() + if not checkpoint: + dominfo.destroyDomain() try: dominfo.setName(domain_name) except VmError: @@ -105,6 +109,8 @@ def save(fd, dominfo, network, live, dst # persistent VM, we need the rename, and don't expect the # conflict. This needs more thought. pass + if checkpoint: + dominfo.resumeDomain() except Exception, exn: log.exception("Save failed on domain %s (%s).", domain_name, diff -r d39e577379a3 -r a5274ebef731 tools/python/xen/xend/XendConstants.py --- a/tools/python/xen/xend/XendConstants.py Thu Dec 14 23:05:42 2006 -0800 +++ b/tools/python/xen/xend/XendConstants.py Thu Dec 14 23:05:42 2006 -0800 @@ -21,18 +21,20 @@ from xen.xend.XendAPIConstants import * # Shutdown codes and reasons. # -DOMAIN_POWEROFF = 0 -DOMAIN_REBOOT = 1 -DOMAIN_SUSPEND = 2 -DOMAIN_CRASH = 3 -DOMAIN_HALT = 4 +DOMAIN_POWEROFF = 0 +DOMAIN_REBOOT = 1 +DOMAIN_SUSPEND = 2 +DOMAIN_CRASH = 3 +DOMAIN_HALT = 4 +DOMAIN_CHECKPOINT = 5 DOMAIN_SHUTDOWN_REASONS = { - DOMAIN_POWEROFF: "poweroff", - DOMAIN_REBOOT : "reboot", - DOMAIN_SUSPEND : "suspend", - DOMAIN_CRASH : "crash", - DOMAIN_HALT : "halt" + DOMAIN_POWEROFF : "poweroff", + DOMAIN_REBOOT : "reboot", + DOMAIN_SUSPEND : "suspend", + DOMAIN_CRASH : "crash", + DOMAIN_HALT : "halt", + DOMAIN_CHECKPOINT: "checkpoint" } REVERSE_DOMAIN_SHUTDOWN_REASONS = \ dict([(y, x) for x, y in DOMAIN_SHUTDOWN_REASONS.items()]) diff -r d39e577379a3 -r a5274ebef731 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Thu Dec 14 23:05:42 2006 -0800 +++ b/tools/python/xen/xend/XendDomain.py Thu Dec 14 23:05:42 2006 -0800 @@ -1134,7 +1134,7 @@ class XendDomain: dominfo.testDeviceComplete() sock.close() - def domain_save(self, domid, dst): + def domain_save(self, domid, dst, checkpoint): """Start saving a domain to file. @param domid: Domain ID or Name @@ -1155,8 +1155,8 @@ class XendDomain: fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC) try: - # For now we don't support 'live checkpoint' - XendCheckpoint.save(fd, dominfo, False, False, dst) + XendCheckpoint.save(fd, dominfo, False, False, dst, + checkpoint=checkpoint) finally: os.close(fd) except OSError, ex: diff -r d39e577379a3 -r a5274ebef731 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Thu Dec 14 23:05:42 2006 -0800 +++ b/tools/python/xen/xend/XendDomainInfo.py Thu Dec 14 23:05:42 2006 -0800 @@ -828,7 +828,7 @@ class XendDomainInfo: reason = self.readDom('control/shutdown') - if reason and reason != 'suspend': + if reason and reason not in ('suspend', 'checkpoint'): sst = self.readDom('xend/shutdown_start_time') now = time.time() if sst: @@ -994,7 +994,7 @@ class XendDomainInfo: self._clearRestart() - if reason == 'suspend': + if reason in ('suspend', 'checkpoint'): self._stateSet(DOM_STATE_SUSPENDED) # Don't destroy the domain. XendCheckpoint will do # this once it has finished. However, stop watching diff -r d39e577379a3 -r a5274ebef731 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Thu Dec 14 23:05:42 2006 -0800 +++ b/tools/python/xen/xm/main.py Thu Dec 14 23:05:42 2006 -0800 @@ -97,7 +97,7 @@ SUBCOMMAND_HELP = { 'reboot' : ('<Domain> [-wa]', 'Reboot a domain.'), 'restore' : ('<CheckpointFile> [-p]', 'Restore a domain from a saved state.'), - 'save' : ('<Domain> <CheckpointFile>', + 'save' : ('[-c] <Domain> <CheckpointFile>', 'Save a domain state to restore later.'), 'shutdown' : ('<Domain> [-waRH]', 'Shutdown a domain.'), 'top' : ('', 'Monitor a host and the domains in real time.'), @@ -224,6 +224,9 @@ SUBCOMMAND_OPTIONS = { 'resume': ( ('-p', '--paused', 'Do not unpause domain after resuming it'), ), + 'save': ( + ('-c', '--checkpoint', 'Leave domain running after creating snapshot'), + ), 'restore': ( ('-p', '--paused', 'Do not unpause domain after restoring it'), ), @@ -531,21 +534,37 @@ def get_single_vm(dom): ######################################################################### def xm_save(args): - arg_check(args, "save", 2) - - try: - dominfo = parse_doms_info(server.xend.domain(args[0])) + arg_check(args, "save", 2, 3) + + try: + (options, params) = getopt.gnu_getopt(args, 'c', ['checkpoint']) + except getopt.GetoptError, opterr: + err(opterr) + sys.exit(1) + + checkpoint = False + for (k, v) in options: + if k in ['-c', '--checkpoint']: + checkpoint = True + + if len(params) != 2: + err("Wrong number of parameters") + usage('save') + sys.exit(1) + + try: + dominfo = parse_doms_info(server.xend.domain(params[0])) except xmlrpclib.Fault, ex: raise ex domid = dominfo['domid'] - savefile = os.path.abspath(args[1]) + savefile = os.path.abspath(params[1]) if not os.access(os.path.dirname(savefile), os.W_OK): err("xm save: Unable to create file %s" % savefile) sys.exit(1) - server.xend.domain.save(domid, savefile) + server.xend.domain.save(domid, savefile, checkpoint) def xm_restore(args): arg_check(args, "restore", 1, 2) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |