WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 8 of 8] Add xm save -c/--checkpoint option

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 8 of 8] Add xm save -c/--checkpoint option
From: Brendan Cully <brendan@xxxxxxxxx>
Date: Thu, 11 Jan 2007 17:27:03 -0700
Delivery-date: Thu, 11 Jan 2007 17:33:48 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1168565215@xxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# 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