[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] qmp: Disable query-cpu-* commands when they're unav
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH] qmp: Disable query-cpu-* commands when they're unavailable |
Date: |
Tue, 4 Oct 2016 16:25:15 -0300 |
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 adding a new arch-specific hook:
arch_init_qmp_commands(), that can enable the available QMP
commands (which are now disabled by default).
Signed-off-by: Eduardo Habkost <address@hidden>
---
include/sysemu/arch_init.h | 1 +
qmp.c | 1 +
stubs/Makefile.objs | 1 +
stubs/arch-qmp-commands-init.c | 7 +++++++
target-arm/monitor.c | 7 +++++++
target-i386/cpu.c | 6 ++++++
target-ppc/monitor.c | 7 +++++++
target-s390x/cpu_models.c | 9 +++++++++
vl.c | 10 ++++++++++
9 files changed, 49 insertions(+)
create mode 100644 stubs/arch-qmp-commands-init.c
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index 1c9dad1..5fd1eab 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -34,6 +34,7 @@ void audio_init(void);
int kvm_available(void);
int xen_available(void);
+void arch_qmp_commands_init(void);
CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp);
CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionType
type,
CpuModelInfo *mode,
diff --git a/qmp.c b/qmp.c
index 621f6ae..a3b01d3 100644
--- a/qmp.c
+++ b/qmp.c
@@ -31,6 +31,7 @@
#include "qom/qom-qobject.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qobject.h"
+#include "qapi/qmp/dispatch.h"
#include "qapi/qmp-input-visitor.h"
#include "hw/boards.h"
#include "qom/object_interfaces.h"
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index c5850e8..0ea3a07 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -1,3 +1,4 @@
+stub-obj-y += arch-qmp-commands-init.o
stub-obj-y += arch-query-cpu-def.o
stub-obj-y += arch-query-cpu-model-expansion.o
stub-obj-y += arch-query-cpu-model-comparison.o
diff --git a/stubs/arch-qmp-commands-init.c b/stubs/arch-qmp-commands-init.c
new file mode 100644
index 0000000..17b26f7
--- /dev/null
+++ b/stubs/arch-qmp-commands-init.c
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "sysemu/arch_init.h"
+
+void arch_qmp_commands_init(void)
+{
+}
diff --git a/target-arm/monitor.c b/target-arm/monitor.c
index 299cb80..d265c9d 100644
--- a/target-arm/monitor.c
+++ b/target-arm/monitor.c
@@ -21,6 +21,8 @@
*/
#include "qemu/osdep.h"
#include "qmp-commands.h"
+#include "qapi/qmp/dispatch.h"
+#include "sysemu/arch_init.h"
#include "hw/boards.h"
#include "kvm_arm.h"
@@ -81,3 +83,8 @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp)
return head;
}
+
+void arch_qmp_commands_init(void)
+{
+ qmp_enable_command("query-cpu-model-definitions");
+}
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 333309b..72eb705 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -29,6 +29,7 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qapi/qmp/qerror.h"
+#include "qapi/qmp/dispatch.h"
#include "qapi-types.h"
#include "qapi-visit.h"
@@ -3565,3 +3566,8 @@ static void x86_cpu_register_types(void)
}
type_init(x86_cpu_register_types)
+
+void arch_qmp_commands_init(void)
+{
+ qmp_enable_command("query-cpu-model-definitions");
+}
diff --git a/target-ppc/monitor.c b/target-ppc/monitor.c
index c2d0806..dac8131 100644
--- a/target-ppc/monitor.c
+++ b/target-ppc/monitor.c
@@ -25,6 +25,8 @@
#include "cpu.h"
#include "monitor/monitor.h"
#include "monitor/hmp-target.h"
+#include "qapi/qmp/dispatch.h"
+#include "sysemu/arch_init.h"
#include "hmp.h"
static target_long monitor_get_ccr (const struct MonitorDef *md, int val)
@@ -145,3 +147,8 @@ int target_get_monitor_def(CPUState *cs, const char *name,
uint64_t *pval)
return -EINVAL;
}
+
+void arch_qmp_commands_init(void)
+{
+ qmp_enable_command("query-cpu-model-definitions");
+}
diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c
index 3ff6a70..534762f 100644
--- a/target-s390x/cpu_models.c
+++ b/target-s390x/cpu_models.c
@@ -19,6 +19,7 @@
#include "qapi/qmp/qerror.h"
#include "qapi/qmp-input-visitor.h"
#include "qapi/qmp/qbool.h"
+#include "qapi/qmp/dispatch.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu/arch_init.h"
#endif
@@ -589,6 +590,14 @@ CpuModelBaselineInfo
*arch_query_cpu_model_baseline(CpuModelInfo *infoa,
cpu_info_from_model(baseline_info->model, &model, true);
return baseline_info;
}
+
+void arch_qmp_commands_init(void)
+{
+ qmp_enable_command("query-cpu-model-expansion");
+ qmp_enable_command("query-cpu-model-baseline");
+ qmp_enable_command("query-cpu-model-comparison");
+ qmp_enable_command("query-cpu-model-definitions");
+}
#endif
static void check_consistency(const S390CPUModel *model)
diff --git a/vl.c b/vl.c
index f3abd99..2d7e09d 100644
--- a/vl.c
+++ b/vl.c
@@ -92,6 +92,7 @@ int main(int argc, char **argv)
#include "sysemu/cpus.h"
#include "sysemu/kvm.h"
#include "qapi/qmp/qjson.h"
+#include "qapi/qmp/dispatch.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qemu-options.h"
@@ -3031,6 +3032,15 @@ int main(int argc, char **argv, char **envp)
module_call_init(MODULE_INIT_QOM);
module_call_init(MODULE_INIT_QAPI);
+ /* These commands are unavailable by default. Architectures that
+ * support them should enable them in arch_qmp_commands_init()
+ */
+ qmp_disable_command("query-cpu-model-expansion");
+ qmp_disable_command("query-cpu-model-baseline");
+ qmp_disable_command("query-cpu-model-comparison");
+ qmp_disable_command("query-cpu-model-definitions");
+ arch_qmp_commands_init();
+
qemu_add_opts(&qemu_drive_opts);
qemu_add_drive_opts(&qemu_legacy_drive_opts);
qemu_add_drive_opts(&qemu_common_drive_opts);
--
2.7.4
- [Qemu-devel] [PATCH] qmp: Disable query-cpu-* commands when they're unavailable,
Eduardo Habkost <=