Skip to contentSkip to conversation

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

PATCH Applied Eduardo Habkost 4 participants 5 messages Oct 5, 2016 – Oct 7, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qmp: Disable query-cpu-* commands when they're unavailable

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.

---
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(+)
monitor.c +9 -0
index 83c4edf..4ff74b7 100644
@@ -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)
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Eduardo Habkost

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.

Quoted 8 lines

---
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(+)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v2 1/1
#2 lore raw
In reply to Eduardo Habkost
Quoted 29 lines · Eduardo Habkost

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.

---
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(+)
monitor.c +2 -0
index 83c4edf..4ff74b7 100644
@@ -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");

monitor.c static void qmp_unregister_commands_hack(void) · line 1006

Quoted 10 lines
monitor.c +7 -0
+    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)
#3 lore raw
In reply to Eduardo Habkost
Quoted 10 lines · Eduardo Habkost

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.

Applied to my qapi-next branch. Thanks!

#4 lore raw
In reply to Eduardo Habkost
Quoted 26 lines · Eduardo Habkost

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.

---
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(+)
monitor.c +0 -0
index 83c4edf..4ff74b7 100644
@@ -992,6 +992,15 @@ static void qmp_unregister_commands_hack(void)
 #ifndef TARGET_ARM
     qmp_unregister_command("query-gic-capabilities");

monitor.c static void qmp_unregister_commands_hack(void) · line 1003

Quoted 10 lines
monitor.c +9 -0
 #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.

Quoted 4 lines
monitor.c +0 -0
 }
 
 static void qmp_init_marshal(void)