# HG changeset patch
# User Brendan Cully <brendan@xxxxxxxxx>
# Date 1172543764 28800
# Node ID b207ed258dcf3a6aee865ca82bc170f68e589342
# Parent b2edb7f3393255f7b51af7fe688de687233b525e
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 b2edb7f33932 -r b207ed258dcf tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py Mon Feb 26 18:36:04 2007 -0800
+++ b/tools/python/xen/xend/XendCheckpoint.py Mon Feb 26 18:36:04 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 b2edb7f33932 -r b207ed258dcf tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Mon Feb 26 18:36:04 2007 -0800
+++ b/tools/python/xen/xend/XendDomain.py Mon Feb 26 18:36:04 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 b2edb7f33932 -r b207ed258dcf tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Mon Feb 26 18:36:04 2007 -0800
+++ b/tools/python/xen/xm/main.py Mon Feb 26 18:36:04 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
|