]> xenbits.xensource.com Git - xen.git/commitdiff
xl: support for leaving domain paused after save
authorIan Murray <murrayie@yahoo.co.uk>
Wed, 3 Jul 2013 23:58:27 +0000 (00:58 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 17 Jul 2013 09:39:22 +0000 (10:39 +0100)
New feature to allow xl save to leave a domain paused after its
memory has been saved. This is to allow disk snapshots of domU
to be taken that exactly correspond to the memory state at save time.
Once the snapshot(s) have been taken or whatever, the domain can be
unpaused in the usual manner.

Usage:
    xl save -p <domid> <filespec>

Signed-off-by: Ian Murray <murrayie@yahoo.co.uk>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
docs/man/xl.pod.1
tools/libxl/xl_cmdimpl.c
tools/libxl/xl_cmdtable.c

index 64a118e607cfabaaa8ee54fc5ed32bde3c762b2f..5975d7b646e5d103055d492a17b1b0e847948fde 100644 (file)
@@ -504,7 +504,7 @@ Pass VNC password to vncviewer via stdin.
 
 Saves a running domain to a state file so that it can be restored
 later.  Once saved, the domain will no longer be running on the
-system, unless the -c option is used.
+system, unless the -c or -p options are used.
 B<xl restore> restores from this checkpoint file.
 Passing a config file argument allows the user to manually select the VM config
 file used to create the domain.
@@ -515,6 +515,10 @@ file used to create the domain.
 
 Leave domain running after creating the snapshot.
 
+=item B<-p>
+
+Leave domain paused after creating the snapshot.
+
 =back
 
 =item B<sharing> [I<domain-id>]
index d365f904c09a2f25c8533e54393e1a220dbbe8c7..4a8feaf65d450cd872281a9a23b751f3f504150d 100644 (file)
@@ -3266,7 +3266,7 @@ static void save_domain_core_writeconfig(int fd, const char *source,
 }
 
 static int save_domain(uint32_t domid, const char *filename, int checkpoint,
-                const char *override_config_file)
+                            int leavepaused, const char *override_config_file)
 {
     int fd;
     uint8_t *config_data;
@@ -3290,11 +3290,15 @@ static int save_domain(uint32_t domid, const char *filename, int checkpoint,
     int rc = libxl_domain_suspend(ctx, domid, fd, 0, NULL);
     close(fd);
 
-    if (rc < 0)
+    if (rc < 0) {
         fprintf(stderr, "Failed to save domain, resuming domain\n");
-
-    if (checkpoint || rc < 0)
         libxl_domain_resume(ctx, domid, 1, 0);
+    }
+    else if (leavepaused || checkpoint) {
+        if (leavepaused)
+            libxl_domain_pause(ctx, domid);
+        libxl_domain_resume(ctx, domid, 1, 0);
+    }
     else
         libxl_domain_destroy(ctx, domid, 0);
 
@@ -3838,12 +3842,16 @@ int main_save(int argc, char **argv)
     const char *filename;
     const char *config_filename = NULL;
     int checkpoint = 0;
+    int leavepaused = 0;
     int opt;
 
-    SWITCH_FOREACH_OPT(opt, "c", NULL, "save", 2) {
+    SWITCH_FOREACH_OPT(opt, "cp", NULL, "save", 2) {
     case 'c':
         checkpoint = 1;
         break;
+    case 'p':
+        leavepaused = 1;
+        break;
     }
 
     if (argc-optind > 3) {
@@ -3856,7 +3864,7 @@ int main_save(int argc, char **argv)
     if ( argc - optind >= 3 )
         config_filename = argv[optind + 2];
 
-    save_domain(domid, filename, checkpoint, config_filename);
+    save_domain(domid, filename, checkpoint, leavepaused, config_filename);
     return 0;
 }
 
index 44b42b03116f6a4be2f71976e0ca3a2ebbe2c313..326a6606e045c3b8484acd6454a243d7863c4854 100644 (file)
@@ -142,7 +142,8 @@ struct cmd_spec cmd_table[] = {
       "Save a domain state to restore later",
       "[options] <Domain> <CheckpointFile> [<ConfigFile>]",
       "-h  Print this help.\n"
-      "-c  Leave domain running after creating the snapshot."
+      "-c  Leave domain running after creating the snapshot.\n"
+      "-p  Leave domain paused after creating the snapshot."
     },
     { "migrate",
       &main_migrate, 0, 1,