From patchwork Tue Oct 4 19:25:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 678190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3spTRm0NRlz9sCg for ; Wed, 5 Oct 2016 06:26:26 +1100 (AEDT) Received: from localhost ([::1]:44916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brVM5-0004Y4-9n for incoming@patchwork.ozlabs.org; Tue, 04 Oct 2016 15:26:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brVLP-0004Gw-Ba for qemu-devel@nongnu.org; Tue, 04 Oct 2016 15:25:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brVLK-0006cC-1a for qemu-devel@nongnu.org; Tue, 04 Oct 2016 15:25:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brVLJ-0006bq-Kq for qemu-devel@nongnu.org; Tue, 04 Oct 2016 15:25:33 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4517F67AE9; Tue, 4 Oct 2016 19:25:32 +0000 (UTC) Received: from localhost (ovpn-116-132.phx2.redhat.com [10.3.116.132]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u94JPTg2018635; Tue, 4 Oct 2016 15:25:30 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org, armbru@redhat.com Date: Tue, 4 Oct 2016 16:25:15 -0300 Message-Id: <1475609115-19293-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 04 Oct 2016 19:25:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qmp: Disable query-cpu-* commands when they're unavailable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, borntraeger@de.ibm.com, agraf@suse.de, dahi@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, jdenemar@redhat.com, rth@twiddle.net, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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);