# HG changeset patch
# User Brendan Cully <brendan@xxxxxxxxx>
# Date 1168565202 28800
# Node ID 086b3085b3ef106de92c86d7fbcd2d5c63291603
# Parent b10287396924bf9973987cc3bfeb442847189e21
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 b10287396924 -r 086b3085b3ef tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py Thu Jan 11 17:26:42 2007 -0800
+++ b/tools/python/xen/xend/XendCheckpoint.py Thu Jan 11 17:26:42 2007 -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())
@@ -96,7 +96,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 +106,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 b10287396924 -r 086b3085b3ef tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Thu Jan 11 17:26:42 2007 -0800
+++ b/tools/python/xen/xend/XendDomain.py Thu Jan 11 17:26:42 2007 -0800
@@ -1177,7 +1177,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
@@ -1198,8 +1198,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 b10287396924 -r 086b3085b3ef tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Thu Jan 11 17:26:42 2007 -0800
+++ b/tools/python/xen/xm/main.py Thu Jan 11 17:26:42 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.'),
@@ -230,6 +230,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'),
),
@@ -586,21 +589,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
|