diff mbox series

[V1,08/32] savevm: HMP command for cprinfo

Message ID 1596122076-341293-9-git-send-email-steven.sistare@oracle.com (mailing list archive)
State New, archived
Headers show
Series Live Update | expand

Commit Message

Steven Sistare July 30, 2020, 3:14 p.m. UTC
Enable HMP access to the cprinfo QMP command.

Usage: cprinfo

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

Comments

Dr. David Alan Gilbert Sept. 11, 2020, 5:27 p.m. UTC | #1
* Steve Sistare (steven.sistare@oracle.com) wrote:
> Enable HMP access to the cprinfo QMP command.
> 
> Usage: cprinfo
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>

As with Eric's comment on the qemp I don't think you need it;
for HMP alll you really need is something that lists it in the help.

(Also I'd expect an info  cpr   to be a possibility that could give
some information about it - e.g. if you've just saved/can save/loaded a
CPR image)

Dave

> ---
>  hmp-commands.hx       | 13 +++++++++++++
>  include/monitor/hmp.h |  1 +
>  monitor/hmp-cmds.c    | 10 ++++++++++
>  3 files changed, 24 insertions(+)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index cb67150..7517876 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -354,6 +354,19 @@ SRST
>  ERST
>  
>      {
> +        .name       = "cprinfo",
> +        .args_type  = "",
> +        .params     = "",
> +        .help       = "return list of modes supported by cprsave",
> +        .cmd        = hmp_cprinfo,
> +    },
> +
> +SRST
> +``cprinfo`` *tag*
> +  Return a space-delimited list of modes supported by cprsave.
> +ERST
> +
> +    {
>          .name       = "cprsave",
>          .args_type  = "file:s,mode:s",
>          .params     = "file 'reboot'",
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 7b8cdfd..919b9a9 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -59,6 +59,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict);
>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>  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_cprload(Monitor *mon, const QDict *qdict);
>  void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index ba95737..2f6af07 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1139,6 +1139,16 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict)
>      qapi_free_AnnounceParameters(params);
>  }
>  
> +void hmp_cprinfo(Monitor *mon, const QDict *qdict)
> +{
> +    Error *err = NULL;
> +    char *res = qmp_cprinfo(&err);
> +
> +    monitor_printf(mon, "%s\n", res);
> +    g_free(res);
> +    hmp_handle_error(mon, err);
> +}
> +
>  void hmp_cprsave(Monitor *mon, const QDict *qdict)
>  {
>      Error *err = NULL;
> -- 
> 1.8.3.1
>
Steven Sistare Sept. 24, 2020, 9:50 p.m. UTC | #2
On 9/11/2020 1:27 PM, Dr. David Alan Gilbert wrote:
> * Steve Sistare (steven.sistare@oracle.com) wrote:
>> Enable HMP access to the cprinfo QMP command.
>>
>> Usage: cprinfo
>>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> 
> As with Eric's comment on the qemp I don't think you need it;
> for HMP alll you really need is something that lists it in the help.

We need an architected stable interface to know that a qemu instance supports
cpr.  I don't think parsing help is good enough.  The hmp interface is great
for use in bash; easy to use and efficient.

> (Also I'd expect an info  cpr   to be a possibility that could give
> some information about it - e.g. if you've just saved/can save/loaded a
> CPR image)

Yes, that occurred to me.  We could add some flags in the future and remain
backwards compatible.  I should start now with a sub-command schema to make future 
expansion cleaner:
  "cprinfo modes" - return supported modes, eg "reboot restart"

- Steve

>> ---
>>  hmp-commands.hx       | 13 +++++++++++++
>>  include/monitor/hmp.h |  1 +
>>  monitor/hmp-cmds.c    | 10 ++++++++++
>>  3 files changed, 24 insertions(+)
>>
>> diff --git a/hmp-commands.hx b/hmp-commands.hx
>> index cb67150..7517876 100644
>> --- a/hmp-commands.hx
>> +++ b/hmp-commands.hx
>> @@ -354,6 +354,19 @@ SRST
>>  ERST
>>  
>>      {
>> +        .name       = "cprinfo",
>> +        .args_type  = "",
>> +        .params     = "",
>> +        .help       = "return list of modes supported by cprsave",
>> +        .cmd        = hmp_cprinfo,
>> +    },
>> +
>> +SRST
>> +``cprinfo`` *tag*
>> +  Return a space-delimited list of modes supported by cprsave.
>> +ERST
>> +
>> +    {
>>          .name       = "cprsave",
>>          .args_type  = "file:s,mode:s",
>>          .params     = "file 'reboot'",
>> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
>> index 7b8cdfd..919b9a9 100644
>> --- a/include/monitor/hmp.h
>> +++ b/include/monitor/hmp.h
>> @@ -59,6 +59,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict);
>>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>>  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_cprload(Monitor *mon, const QDict *qdict);
>>  void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
>> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
>> index ba95737..2f6af07 100644
>> --- a/monitor/hmp-cmds.c
>> +++ b/monitor/hmp-cmds.c
>> @@ -1139,6 +1139,16 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict)
>>      qapi_free_AnnounceParameters(params);
>>  }
>>  
>> +void hmp_cprinfo(Monitor *mon, const QDict *qdict)
>> +{
>> +    Error *err = NULL;
>> +    char *res = qmp_cprinfo(&err);
>> +
>> +    monitor_printf(mon, "%s\n", res);
>> +    g_free(res);
>> +    hmp_handle_error(mon, err);
>> +}
>> +
>>  void hmp_cprsave(Monitor *mon, const QDict *qdict)
>>  {
>>      Error *err = NULL;
>> -- 
>> 1.8.3.1
>>
diff mbox series

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index cb67150..7517876 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -354,6 +354,19 @@  SRST
 ERST
 
     {
+        .name       = "cprinfo",
+        .args_type  = "",
+        .params     = "",
+        .help       = "return list of modes supported by cprsave",
+        .cmd        = hmp_cprinfo,
+    },
+
+SRST
+``cprinfo`` *tag*
+  Return a space-delimited list of modes supported by cprsave.
+ERST
+
+    {
         .name       = "cprsave",
         .args_type  = "file:s,mode:s",
         .params     = "file 'reboot'",
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 7b8cdfd..919b9a9 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -59,6 +59,7 @@  void hmp_balloon(Monitor *mon, const QDict *qdict);
 void hmp_loadvm(Monitor *mon, const QDict *qdict);
 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_cprload(Monitor *mon, const QDict *qdict);
 void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index ba95737..2f6af07 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1139,6 +1139,16 @@  void hmp_announce_self(Monitor *mon, const QDict *qdict)
     qapi_free_AnnounceParameters(params);
 }
 
+void hmp_cprinfo(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    char *res = qmp_cprinfo(&err);
+
+    monitor_printf(mon, "%s\n", res);
+    g_free(res);
+    hmp_handle_error(mon, err);
+}
+
 void hmp_cprsave(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;