@@ -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,
@@ -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"
@@ -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
new file mode 100644
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "sysemu/arch_init.h"
+
+void arch_qmp_commands_init(void)
+{
+}
@@ -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");
+}
@@ -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");
+}
@@ -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");
+}
@@ -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)
@@ -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);
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 <ehabkost@redhat.com> --- 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