diff mbox series

[V1,14/32] savevm: VMS_RESTART and cprsave restart

Message ID 1596122076-341293-15-git-send-email-steven.sistare@oracle.com
State New
Headers show
Series Live Update | expand

Commit Message

Steven Sistare July 30, 2020, 3:14 p.m. UTC
Add the VMS_RESTART variant of vmstate, for use when upgrading qemu in place
on the same host without a reboot.  Invoke it using:
  cprsave <filename> restart

VMS_RESTART supports guest ram mapped by private anonymous memory, versus
VMS_REBOOT which requires that guest ram be mapped by persistent shared
memory.  Subsequent patches complete its implementation.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 hmp-commands.hx             | 4 +++-
 include/migration/vmstate.h | 1 +
 migration/savevm.c          | 4 +++-
 monitor/qmp-cmds.c          | 2 +-
 qapi/migration.json         | 1 +
 5 files changed, 9 insertions(+), 3 deletions(-)

Comments

Eric Blake July 30, 2020, 4:22 p.m. UTC | #1
On 7/30/20 10:14 AM, Steve Sistare wrote:
> Add the VMS_RESTART variant of vmstate, for use when upgrading qemu in place
> on the same host without a reboot.  Invoke it using:
>    cprsave <filename> restart
> 
> VMS_RESTART supports guest ram mapped by private anonymous memory, versus
> VMS_REBOOT which requires that guest ram be mapped by persistent shared
> memory.  Subsequent patches complete its implementation.
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---

> +++ b/qapi/migration.json
> @@ -1639,6 +1639,7 @@
>   #
>   # @file: name of checkpoint file
>   # @mode: 'reboot' : checkpoint can be cprload'ed after a host kexec reboot.
> +#        'restart': checkpoint can be cprload'ed after restarting qemu.

This should be a modification to an enum type (the 'CprMode' type I 
suggested earlier in the series).
Steven Sistare July 30, 2020, 6:14 p.m. UTC | #2
On 7/30/2020 12:22 PM, Eric Blake wrote:
> On 7/30/20 10:14 AM, Steve Sistare wrote:
>> Add the VMS_RESTART variant of vmstate, for use when upgrading qemu in place
>> on the same host without a reboot.  Invoke it using:
>>    cprsave <filename> restart
>>
>> VMS_RESTART supports guest ram mapped by private anonymous memory, versus
>> VMS_REBOOT which requires that guest ram be mapped by persistent shared
>> memory.  Subsequent patches complete its implementation.
>>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>> ---
> 
>> +++ b/qapi/migration.json
>> @@ -1639,6 +1639,7 @@
>>   #
>>   # @file: name of checkpoint file
>>   # @mode: 'reboot' : checkpoint can be cprload'ed after a host kexec reboot.
>> +#        'restart': checkpoint can be cprload'ed after restarting qemu.
> 
> This should be a modification to an enum type (the 'CprMode' type I suggested earlier in the series).

Will do - steve
Dr. David Alan Gilbert Sept. 11, 2020, 6:44 p.m. UTC | #3
* Steve Sistare (steven.sistare@oracle.com) wrote:
> Add the VMS_RESTART variant of vmstate, for use when upgrading qemu in place
> on the same host without a reboot.  Invoke it using:
>   cprsave <filename> restart
> 
> VMS_RESTART supports guest ram mapped by private anonymous memory, versus
> VMS_REBOOT which requires that guest ram be mapped by persistent shared
> memory.  Subsequent patches complete its implementation.
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>

You should find with the enum like Eric suggests this mostly disappears;
but also you might want to put it after the patches that implement it.

Dave

> ---
>  hmp-commands.hx             | 4 +++-
>  include/migration/vmstate.h | 1 +
>  migration/savevm.c          | 4 +++-
>  monitor/qmp-cmds.c          | 2 +-
>  qapi/migration.json         | 1 +
>  5 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 7517876..11a2089 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -369,7 +369,7 @@ ERST
>      {
>          .name       = "cprsave",
>          .args_type  = "file:s,mode:s",
> -        .params     = "file 'reboot'",
> +        .params     = "file 'restart'|'reboot'",
>          .help       = "create a checkpoint of the VM in file",
>          .cmd        = hmp_cprsave,
>      },
> @@ -380,6 +380,8 @@ SRST
>    in *file*.
>    If *mode* is 'reboot', the checkpoint can be cprload'ed after a host kexec
>    reboot.
> +  If *mode* is 'restart', the checkpoint can be cprload'ed after restarting
> +  qemu.
>    exec() /usr/bin/qemu-exec if it exists, else exec /usr/bin/qemu-system-x86_64,
>    passing all the original command line arguments.  The VCPUs remain paused.
>  ERST
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index c58551a..8239b84 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -162,6 +162,7 @@ typedef enum {
>      VMS_MIGRATE  = (1U << 1),
>      VMS_SNAPSHOT = (1U << 2),
>      VMS_REBOOT   = (1U << 3),
> +    VMS_RESTART  = (1U << 4),
>      VMS_MODE_ALL = ~0U
>  } VMStateMode;
>  
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 00f493b..38cc63a 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2708,6 +2708,8 @@ void save_cpr_snapshot(const char *file, const char *mode, Error **errp)
>  
>      if (!strcmp(mode, "reboot")) {
>          op = VMS_REBOOT;
> +    } else if (!strcmp(mode, "restart")) {
> +        op = VMS_RESTART;
>      } else {
>          error_setg(errp, "cprsave: bad mode %s", mode);
>          return;
> @@ -2973,7 +2975,7 @@ void load_cpr_snapshot(const char *file, Error **errp)
>          return;
>      }
>  
> -    ret = qemu_loadvm_state(f, VMS_REBOOT);
> +    ret = qemu_loadvm_state(f, VMS_REBOOT | VMS_RESTART);
>      qemu_fclose(f);
>      if (ret < 0) {
>          error_setg(errp, "Error %d while loading VM state", ret);
> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index 8c400e6..8a74c6e 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -164,7 +164,7 @@ void qmp_cont(Error **errp)
>  
>  char *qmp_cprinfo(Error **errp)
>  {
> -    return g_strdup("reboot");
> +    return g_strdup("reboot restart");
>  }
>  
>  void qmp_cprsave(const char *file, const char *mode, Error **errp)
> diff --git a/qapi/migration.json b/qapi/migration.json
> index 8190b16..d22992b 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -1639,6 +1639,7 @@
>  #
>  # @file: name of checkpoint file
>  # @mode: 'reboot' : checkpoint can be cprload'ed after a host kexec reboot.
> +#        'restart': checkpoint can be cprload'ed after restarting qemu.
>  #
>  # Since 5.0
>  ##
> -- 
> 1.8.3.1
>
Steven Sistare Sept. 24, 2020, 9:44 p.m. UTC | #4
On 9/11/2020 2:44 PM, Dr. David Alan Gilbert wrote:
> * Steve Sistare (steven.sistare@oracle.com) wrote:
>> Add the VMS_RESTART variant of vmstate, for use when upgrading qemu in place
>> on the same host without a reboot.  Invoke it using:
>>   cprsave <filename> restart
>>
>> VMS_RESTART supports guest ram mapped by private anonymous memory, versus
>> VMS_REBOOT which requires that guest ram be mapped by persistent shared
>> memory.  Subsequent patches complete its implementation.
>>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> 
> You should find with the enum like Eric suggests this mostly disappears;
> but also you might want to put it after the patches that implement it.

Sure.  If this gets too small I will add it to the implementation patch.
I cannot move this after the impl, because the impl has additional uses of VMS_RESTART.

- Steve

>> ---
>>  hmp-commands.hx             | 4 +++-
>>  include/migration/vmstate.h | 1 +
>>  migration/savevm.c          | 4 +++-
>>  monitor/qmp-cmds.c          | 2 +-
>>  qapi/migration.json         | 1 +
>>  5 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/hmp-commands.hx b/hmp-commands.hx
>> index 7517876..11a2089 100644
>> --- a/hmp-commands.hx
>> +++ b/hmp-commands.hx
>> @@ -369,7 +369,7 @@ ERST
>>      {
>>          .name       = "cprsave",
>>          .args_type  = "file:s,mode:s",
>> -        .params     = "file 'reboot'",
>> +        .params     = "file 'restart'|'reboot'",
>>          .help       = "create a checkpoint of the VM in file",
>>          .cmd        = hmp_cprsave,
>>      },
>> @@ -380,6 +380,8 @@ SRST
>>    in *file*.
>>    If *mode* is 'reboot', the checkpoint can be cprload'ed after a host kexec
>>    reboot.
>> +  If *mode* is 'restart', the checkpoint can be cprload'ed after restarting
>> +  qemu.
>>    exec() /usr/bin/qemu-exec if it exists, else exec /usr/bin/qemu-system-x86_64,
>>    passing all the original command line arguments.  The VCPUs remain paused.
>>  ERST
>> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
>> index c58551a..8239b84 100644
>> --- a/include/migration/vmstate.h
>> +++ b/include/migration/vmstate.h
>> @@ -162,6 +162,7 @@ typedef enum {
>>      VMS_MIGRATE  = (1U << 1),
>>      VMS_SNAPSHOT = (1U << 2),
>>      VMS_REBOOT   = (1U << 3),
>> +    VMS_RESTART  = (1U << 4),
>>      VMS_MODE_ALL = ~0U
>>  } VMStateMode;
>>  
>> diff --git a/migration/savevm.c b/migration/savevm.c
>> index 00f493b..38cc63a 100644
>> --- a/migration/savevm.c
>> +++ b/migration/savevm.c
>> @@ -2708,6 +2708,8 @@ void save_cpr_snapshot(const char *file, const char *mode, Error **errp)
>>  
>>      if (!strcmp(mode, "reboot")) {
>>          op = VMS_REBOOT;
>> +    } else if (!strcmp(mode, "restart")) {
>> +        op = VMS_RESTART;
>>      } else {
>>          error_setg(errp, "cprsave: bad mode %s", mode);
>>          return;
>> @@ -2973,7 +2975,7 @@ void load_cpr_snapshot(const char *file, Error **errp)
>>          return;
>>      }
>>  
>> -    ret = qemu_loadvm_state(f, VMS_REBOOT);
>> +    ret = qemu_loadvm_state(f, VMS_REBOOT | VMS_RESTART);
>>      qemu_fclose(f);
>>      if (ret < 0) {
>>          error_setg(errp, "Error %d while loading VM state", ret);
>> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
>> index 8c400e6..8a74c6e 100644
>> --- a/monitor/qmp-cmds.c
>> +++ b/monitor/qmp-cmds.c
>> @@ -164,7 +164,7 @@ void qmp_cont(Error **errp)
>>  
>>  char *qmp_cprinfo(Error **errp)
>>  {
>> -    return g_strdup("reboot");
>> +    return g_strdup("reboot restart");
>>  }
>>  
>>  void qmp_cprsave(const char *file, const char *mode, Error **errp)
>> diff --git a/qapi/migration.json b/qapi/migration.json
>> index 8190b16..d22992b 100644
>> --- a/qapi/migration.json
>> +++ b/qapi/migration.json
>> @@ -1639,6 +1639,7 @@
>>  #
>>  # @file: name of checkpoint file
>>  # @mode: 'reboot' : checkpoint can be cprload'ed after a host kexec reboot.
>> +#        'restart': checkpoint can be cprload'ed after restarting qemu.
>>  #
>>  # Since 5.0
>>  ##
>> -- 
>> 1.8.3.1
>>
diff mbox series

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 7517876..11a2089 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -369,7 +369,7 @@  ERST
     {
         .name       = "cprsave",
         .args_type  = "file:s,mode:s",
-        .params     = "file 'reboot'",
+        .params     = "file 'restart'|'reboot'",
         .help       = "create a checkpoint of the VM in file",
         .cmd        = hmp_cprsave,
     },
@@ -380,6 +380,8 @@  SRST
   in *file*.
   If *mode* is 'reboot', the checkpoint can be cprload'ed after a host kexec
   reboot.
+  If *mode* is 'restart', the checkpoint can be cprload'ed after restarting
+  qemu.
   exec() /usr/bin/qemu-exec if it exists, else exec /usr/bin/qemu-system-x86_64,
   passing all the original command line arguments.  The VCPUs remain paused.
 ERST
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index c58551a..8239b84 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -162,6 +162,7 @@  typedef enum {
     VMS_MIGRATE  = (1U << 1),
     VMS_SNAPSHOT = (1U << 2),
     VMS_REBOOT   = (1U << 3),
+    VMS_RESTART  = (1U << 4),
     VMS_MODE_ALL = ~0U
 } VMStateMode;
 
diff --git a/migration/savevm.c b/migration/savevm.c
index 00f493b..38cc63a 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2708,6 +2708,8 @@  void save_cpr_snapshot(const char *file, const char *mode, Error **errp)
 
     if (!strcmp(mode, "reboot")) {
         op = VMS_REBOOT;
+    } else if (!strcmp(mode, "restart")) {
+        op = VMS_RESTART;
     } else {
         error_setg(errp, "cprsave: bad mode %s", mode);
         return;
@@ -2973,7 +2975,7 @@  void load_cpr_snapshot(const char *file, Error **errp)
         return;
     }
 
-    ret = qemu_loadvm_state(f, VMS_REBOOT);
+    ret = qemu_loadvm_state(f, VMS_REBOOT | VMS_RESTART);
     qemu_fclose(f);
     if (ret < 0) {
         error_setg(errp, "Error %d while loading VM state", ret);
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index 8c400e6..8a74c6e 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -164,7 +164,7 @@  void qmp_cont(Error **errp)
 
 char *qmp_cprinfo(Error **errp)
 {
-    return g_strdup("reboot");
+    return g_strdup("reboot restart");
 }
 
 void qmp_cprsave(const char *file, const char *mode, Error **errp)
diff --git a/qapi/migration.json b/qapi/migration.json
index 8190b16..d22992b 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1639,6 +1639,7 @@ 
 #
 # @file: name of checkpoint file
 # @mode: 'reboot' : checkpoint can be cprload'ed after a host kexec reboot.
+#        'restart': checkpoint can be cprload'ed after restarting qemu.
 #
 # Since 5.0
 ##