[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3 of 4] Add xm save -c/--checkpoint option
# HG changeset patch # User Brendan Cully <brendan@xxxxxxxxx> # Date 1172644688 28800 # Node ID c61bfd68ca422003ea6c0ed6e13e26dc881b98a8 # Parent 6b127078519f0c318b0d212ce901491eb1c155c7 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 6b127078519f -r c61bfd68ca42 tools/python/xen/xend/XendCheckpoint.py --- a/tools/python/xen/xend/XendCheckpoint.py Tue Feb 27 22:38:08 2007 -0800 +++ b/tools/python/xen/xend/XendCheckpoint.py Tue Feb 27 22:38:08 2007 -0800 @@ -54,7 +54,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()) @@ -121,9 +121,11 @@ def save(fd, dominfo, network, live, dst os.close(qemu_fd) os.remove("/tmp/xen.qemu-dm.%d" % dominfo.getDomid()) - dominfo.destroyDomain() - dominfo.testDeviceComplete() - + if checkpoint: + dominfo.resumeDomain() + else: + dominfo.destroyDomain() + dominfo.testDeviceComplete() try: dominfo.setName(domain_name) except VmError: diff -r 6b127078519f -r c61bfd68ca42 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Tue Feb 27 22:38:08 2007 -0800 +++ b/tools/python/xen/xend/XendDomain.py Tue Feb 27 22:38:08 2007 -0800 @@ -1172,7 +1172,7 @@ class XendDomain: XendCheckpoint.save(sock.fileno(), dominfo, True, live, dst) 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 @@ -1196,8 +1196,8 @@ class XendDomain: oflags |= os.O_LARGEFILE fd = os.open(dst, oflags) 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 6b127078519f -r c61bfd68ca42 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Tue Feb 27 22:38:08 2007 -0800 +++ b/tools/python/xen/xm/main.py Tue Feb 27 22:38:08 2007 -0800 @@ -102,7 +102,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.'), @@ -232,6 +232,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'), ), @@ -604,21 +607,37 @@ def xm_shell(args): ######################################################################### 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 |