diff mbox

[v2] qmp: Disable query-cpu-* commands when they're unavailable

Message ID 1475696941-8056-1-git-send-email-ehabkost@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eduardo Habkost Oct. 5, 2016, 7:49 p.m. UTC
Instead of requiring clients to actually call the query-cpu-*
commands to find out if they are implemented, remove them from
the output of "query-commands", so clients know they are not
available.

This is implemented by extending the existing hack at
qmp_unregister_commands_hack(). I wish I could avoid adding even
more #ifdefs to that code, but that's the solution we have today.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
* Instead of adding new qmp_commands_init() and
  arch_qmp_commands_init() functions, simply extend the hack at
  qmp_unregister_commands_hack()
---
 monitor.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Markus Armbruster Oct. 6, 2016, 2:17 p.m. UTC | #1
Eduardo Habkost <ehabkost@redhat.com> writes:

> Instead of requiring clients to actually call the query-cpu-*
> commands to find out if they are implemented, remove them from
> the output of "query-commands", so clients know they are not
> available.
>
> This is implemented by extending the existing hack at
> qmp_unregister_commands_hack(). I wish I could avoid adding even
> more #ifdefs to that code, but that's the solution we have today.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2:
> * Instead of adding new qmp_commands_init() and
>   arch_qmp_commands_init() functions, simply extend the hack at
>   qmp_unregister_commands_hack()
> ---
>  monitor.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/monitor.c b/monitor.c
> index 83c4edf..4ff74b7 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -992,6 +992,15 @@ static void qmp_unregister_commands_hack(void)
>  #ifndef TARGET_ARM
>      qmp_unregister_command("query-gic-capabilities");
>  #endif
> +#if !defined(TARGET_S390X)
> +    qmp_unregister_command("query-cpu-model-expansion");
> +    qmp_unregister_command("query-cpu-model-baseline");
> +    qmp_unregister_command("query-cpu-model-comparison");
> +#endif
> +#if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \
> +    && !defined(TARGET_S390X)
> +    qmp_unregister_command("query-cpu-definitions");
> +#endif
>  }
>  
>  static void qmp_init_marshal(void)

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Markus Armbruster Oct. 7, 2016, 12:03 p.m. UTC | #2
Eduardo Habkost <ehabkost@redhat.com> writes:

> Instead of requiring clients to actually call the query-cpu-*
> commands to find out if they are implemented, remove them from
> the output of "query-commands", so clients know they are not
> available.
>
> This is implemented by extending the existing hack at
> qmp_unregister_commands_hack(). I wish I could avoid adding even
> more #ifdefs to that code, but that's the solution we have today.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Applied to my qapi-next branch.  Thanks!
Christian Borntraeger Oct. 7, 2016, 12:05 p.m. UTC | #3
On 10/05/2016 09:49 PM, Eduardo Habkost wrote:
> Instead of requiring clients to actually call the query-cpu-*
> commands to find out if they are implemented, remove them from
> the output of "query-commands", so clients know they are not
> available.
> 
> This is implemented by extending the existing hack at
> qmp_unregister_commands_hack(). I wish I could avoid adding even
> more #ifdefs to that code, but that's the solution we have today.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2:
> * Instead of adding new qmp_commands_init() and
>   arch_qmp_commands_init() functions, simply extend the hack at
>   qmp_unregister_commands_hack()
> ---
>  monitor.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/monitor.c b/monitor.c
> index 83c4edf..4ff74b7 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -992,6 +992,15 @@ static void qmp_unregister_commands_hack(void)
>  #ifndef TARGET_ARM
>      qmp_unregister_command("query-gic-capabilities");
>  #endif
> +#if !defined(TARGET_S390X)
> +    qmp_unregister_command("query-cpu-model-expansion");
> +    qmp_unregister_command("query-cpu-model-baseline");
> +    qmp_unregister_command("query-cpu-model-comparison");
> +#endif
> +#if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \
> +    && !defined(TARGET_S390X)
> +    qmp_unregister_command("query-cpu-definitions");
> +#endif

Had no chance to test that, but the patch looks sane.

>  }
> 
>  static void qmp_init_marshal(void)
>
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index 83c4edf..4ff74b7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -992,6 +992,15 @@  static void qmp_unregister_commands_hack(void)
 #ifndef TARGET_ARM
     qmp_unregister_command("query-gic-capabilities");
 #endif
+#if !defined(TARGET_S390X)
+    qmp_unregister_command("query-cpu-model-expansion");
+    qmp_unregister_command("query-cpu-model-baseline");
+    qmp_unregister_command("query-cpu-model-comparison");
+#endif
+#if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \
+    && !defined(TARGET_S390X)
+    qmp_unregister_command("query-cpu-definitions");
+#endif
 }
 
 static void qmp_init_marshal(void)