diff mbox series

[V5,13/25] cpr: HMP interfaces for restart

Message ID 1625678434-240960-14-git-send-email-steven.sistare@oracle.com
State New
Headers show
Series Live Update | expand

Commit Message

Steve Sistare July 7, 2021, 5:20 p.m. UTC
cprsave <file> <mode>
  mode may be "restart"

cprexec <command>
  Call cprexec().
  Arguments:
    command : command line to execute, with space-separated arguments

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 hmp-commands.hx       | 20 +++++++++++++++++++-
 include/monitor/hmp.h |  1 +
 monitor/hmp-cmds.c    | 11 +++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

Comments

Zheng Chuan July 28, 2021, 4:56 a.m. UTC | #1
Hi

On 2021/7/8 1:20, Steve Sistare wrote:
> cprsave <file> <mode>
>   mode may be "restart"
> 
> cprexec <command>
>   Call cprexec().
>   Arguments:
>     command : command line to execute, with space-separated arguments
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
>  hmp-commands.hx       | 20 +++++++++++++++++++-
>  include/monitor/hmp.h |  1 +
>  monitor/hmp-cmds.c    | 11 +++++++++++
>  3 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 11827ae..d956405 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -366,7 +366,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,
>      },
> @@ -379,6 +379,24 @@ If *mode* is 'reboot', the checkpoint remains valid after a host kexec
>  reboot, and guest ram must be backed by persistant shared memory.  To
Same, Should be persistent.
>  resume from the checkpoint, issue the quit command, reboot the system,
>  and issue the cprload command.
> +
> +If *mode* is 'restart', the checkpoint remains valid after restarting qemu,
> +and guest ram must be allocated with the memfd-alloc machine option.  To
> +resume from the checkpoint, issue the cprexec command to restart, and issue
> +the cprload command.
> +ERST
> +
> +    {
> +        .name       = "cprexec",
> +        .args_type  = "command:S",
> +        .params     = "command",
> +        .help       = "Restart qemu by directly exec'ing command",
> +        .cmd        = hmp_cprexec,
> +    },
> +
> +SRST
> +``cprexec`` *command*
> +Restart qemu by directly exec'ing *command*, replacing the qemu process.
>  ERST
>  
>      {
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 98bb775..ffc5eb1 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -60,6 +60,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict);
>  void hmp_delvm(Monitor *mon, const QDict *qdict);
>  void hmp_cprinfo(Monitor *mon, const QDict *qdict);
>  void hmp_cprsave(Monitor *mon, const QDict *qdict);
> +void hmp_cprexec(Monitor *mon, const QDict *qdict);
>  void hmp_cprload(Monitor *mon, const QDict *qdict);
>  void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
>  void hmp_migrate_continue(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index a56f83c..163564e 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1217,6 +1217,17 @@ out:
>      hmp_handle_error(mon, err);
>  }
>  
> +void hmp_cprexec(Monitor *mon, const QDict *qdict)
> +{
> +    Error *err = NULL;
> +    const char *command = qdict_get_try_str(qdict, "command");
> +    strList *args = strList_from_string(command, ' ');
> +
> +    qmp_cprexec(args, &err);
> +    qapi_free_strList(args);
> +    hmp_handle_error(mon, err);
> +}
> +
>  void hmp_cprload(Monitor *mon, const QDict *qdict)
>  {
>      Error *err = NULL;
>
diff mbox series

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 11827ae..d956405 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -366,7 +366,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,
     },
@@ -379,6 +379,24 @@  If *mode* is 'reboot', the checkpoint remains valid after a host kexec
 reboot, and guest ram must be backed by persistant shared memory.  To
 resume from the checkpoint, issue the quit command, reboot the system,
 and issue the cprload command.
+
+If *mode* is 'restart', the checkpoint remains valid after restarting qemu,
+and guest ram must be allocated with the memfd-alloc machine option.  To
+resume from the checkpoint, issue the cprexec command to restart, and issue
+the cprload command.
+ERST
+
+    {
+        .name       = "cprexec",
+        .args_type  = "command:S",
+        .params     = "command",
+        .help       = "Restart qemu by directly exec'ing command",
+        .cmd        = hmp_cprexec,
+    },
+
+SRST
+``cprexec`` *command*
+Restart qemu by directly exec'ing *command*, replacing the qemu process.
 ERST
 
     {
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 98bb775..ffc5eb1 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -60,6 +60,7 @@  void hmp_savevm(Monitor *mon, const QDict *qdict);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
 void hmp_cprinfo(Monitor *mon, const QDict *qdict);
 void hmp_cprsave(Monitor *mon, const QDict *qdict);
+void hmp_cprexec(Monitor *mon, const QDict *qdict);
 void hmp_cprload(Monitor *mon, const QDict *qdict);
 void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
 void hmp_migrate_continue(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index a56f83c..163564e 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1217,6 +1217,17 @@  out:
     hmp_handle_error(mon, err);
 }
 
+void hmp_cprexec(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    const char *command = qdict_get_try_str(qdict, "command");
+    strList *args = strList_from_string(command, ' ');
+
+    qmp_cprexec(args, &err);
+    qapi_free_strList(args);
+    hmp_handle_error(mon, err);
+}
+
 void hmp_cprload(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;