All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [Attempt 2] xl save but leave domain paused
@ 2013-07-03 23:58 Ian Murray
  2013-07-04  8:40 ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Murray @ 2013-07-03 23:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Murray, Ian.Campbell

    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>

    Somewhat fixed alignment.
    Re-worked the if statements so they read better - no change to logic.
    Removed spurious empty line.
    Fixed Man page.

    Signed-off-by: Ian Murray <murrayie@yahoo.co.uk>
---
 docs/man/xl.pod.1         |    6 +++++-
 tools/libxl/xl_cmdimpl.c  |   20 ++++++++++++++------
 tools/libxl/xl_cmdtable.c |    3 ++-
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
index 64a118e..5975d7b 100644
--- a/docs/man/xl.pod.1
+++ b/docs/man/xl.pod.1
@@ -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>]
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 8a478ba..0e2b0b6 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -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;
 }
 
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 44b42b0..326a660 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -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,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [Attempt 2] xl save but leave domain paused
  2013-07-03 23:58 [PATCH] [Attempt 2] xl save but leave domain paused Ian Murray
@ 2013-07-04  8:40 ` Ian Campbell
  2013-07-17 10:36   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Campbell @ 2013-07-04  8:40 UTC (permalink / raw)
  To: Ian Murray; +Cc: xen-devel

On Thu, 2013-07-04 at 00:58 +0100, Ian Murray wrote:
>     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>
> 
>     Somewhat fixed alignment.
>     Re-worked the if statements so they read better - no change to logic.
>     Removed spurious empty line.
>     Fixed Man page.
> 
>     Signed-off-by: Ian Murray <murrayie@yahoo.co.uk>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> ---
>  docs/man/xl.pod.1         |    6 +++++-
>  tools/libxl/xl_cmdimpl.c  |   20 ++++++++++++++------
>  tools/libxl/xl_cmdtable.c |    3 ++-
>  3 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
> index 64a118e..5975d7b 100644
> --- a/docs/man/xl.pod.1
> +++ b/docs/man/xl.pod.1
> @@ -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>]
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 8a478ba..0e2b0b6 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -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;
>  }
>  
> diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
> index 44b42b0..326a660 100644
> --- a/tools/libxl/xl_cmdtable.c
> +++ b/tools/libxl/xl_cmdtable.c
> @@ -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,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [Attempt 2] xl save but leave domain paused
  2013-07-04  8:40 ` Ian Campbell
@ 2013-07-17 10:36   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2013-07-17 10:36 UTC (permalink / raw)
  To: Ian Murray; +Cc: xen-devel

On Thu, 2013-07-04 at 09:40 +0100, Ian Campbell wrote:
> On Thu, 2013-07-04 at 00:58 +0100, Ian Murray wrote:
> >     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>
> > 
> >     Somewhat fixed alignment.
> >     Re-worked the if statements so they read better - no change to logic.
> >     Removed spurious empty line.
> >     Fixed Man page.
> > 
> >     Signed-off-by: Ian Murray <murrayie@yahoo.co.uk>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>

Applied, thanks. I changed the summary line to "xl: support for leaving
domain paused after save" to make it clear this wasn't a change to the
default behaviour.

Ian.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-17 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-03 23:58 [PATCH] [Attempt 2] xl save but leave domain paused Ian Murray
2013-07-04  8:40 ` Ian Campbell
2013-07-17 10:36   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.