From 06441913a6b0832d545bb40b1c4969cca99059a7 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 13 Nov 2018 18:16:34 +0100 Subject: [PATCH 15/22] qapi: fill in CpuInfoFast.arch in query-cpus-fast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Laszlo Ersek Message-id: <20181113181639.4999-2-lersek@redhat.com> Patchwork-id: 83003 O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 1/6] qapi: fill in CpuInfoFast.arch in query-cpus-fast Bugzilla: 1607406 RH-Acked-by: Philippe Mathieu-Daudé RH-Acked-by: Marc-André Lureau RH-Acked-by: Markus Armbruster * Commit ca230ff33f89 added the @arch field to @CpuInfoFast, but it failed to set the new field in qmp_query_cpus_fast(), when TARGET_S390X was not defined. The updated @query-cpus-fast example in "qapi-schema.json" showed "arch":"x86" only because qmp_query_cpus_fast() calls g_malloc0() to allocate @CpuInfoFast, and the CPU_INFO_ARCH_X86 enum constant is generated with value 0. All @arch values other than @s390 implied the @CpuInfoOther sub-struct for @CpuInfoFast -- at the time of writing the patch --, thus no fields other than @arch needed to be set when TARGET_S390X was not defined. Set @arch now, by copying the corresponding assignments from qmp_query_cpus(). * Commit 25fa194b7b11 added the @riscv enum constant to @CpuInfoArch (used in both @CpuInfo and @CpuInfoFast -- the return types of the @query-cpus and @query-cpus-fast commands, respectively), and assigned, in both return structures, the @CpuInfoRISCV sub-structure to the new enum value. However, qmp_query_cpus_fast() would not populate either the @arch field or the @CpuInfoRISCV sub-structure, when TARGET_RISCV was defined; only qmp_query_cpus() would. Assign @CpuInfoOther to the @riscv enum constant in @CpuInfoFast, and populate only the @arch field in qmp_query_cpus_fast(). Getting CPU state without interrupting KVM is an exceptional thing that only S390X does currently. Quoting Cornelia Huck , "s390x is exceptional in that it has state in QEMU that is actually interesting for upper layers and can be retrieved without performance penalty". See also . Cc: Cornelia Huck Cc: Eric Blake Cc: Markus Armbruster Cc: Viktor VM Mihajlovski Cc: qemu-stable@nongnu.org Fixes: ca230ff33f89bf7102cbfbc2328716da6750aaed Fixes: 25fa194b7b11901561532e435beb83d046899f7a Signed-off-by: Laszlo Ersek Reviewed-by: Eric Blake Reviewed-by: Cornelia Huck Reviewed-by: Markus Armbruster Message-Id: <20180427192852.15013-2-lersek@redhat.com> Signed-off-by: Markus Armbruster (cherry picked from commit 96054f56396eaa0b9b5c681fc3e42a0004b17ade) Signed-off-by: Miroslav Rezanina --- cpus.c | 16 +++++++++++++++- qapi/misc.json | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index 398392b..4f83f16 100644 --- a/cpus.c +++ b/cpus.c @@ -2218,11 +2218,25 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) info->value->props = props; } -#if defined(TARGET_S390X) +#if defined(TARGET_I386) + info->value->arch = CPU_INFO_ARCH_X86; +#elif defined(TARGET_PPC) + info->value->arch = CPU_INFO_ARCH_PPC; +#elif defined(TARGET_SPARC) + info->value->arch = CPU_INFO_ARCH_SPARC; +#elif defined(TARGET_MIPS) + info->value->arch = CPU_INFO_ARCH_MIPS; +#elif defined(TARGET_TRICORE) + info->value->arch = CPU_INFO_ARCH_TRICORE; +#elif defined(TARGET_S390X) s390_cpu = S390_CPU(cpu); env = &s390_cpu->env; info->value->arch = CPU_INFO_ARCH_S390; info->value->u.s390.cpu_state = env->cpu_state; +#elif defined(TARGET_RISCV) + info->value->arch = CPU_INFO_ARCH_RISCV; +#else + info->value->arch = CPU_INFO_ARCH_OTHER; #endif if (!cur_item) { head = cur_item = info; diff --git a/qapi/misc.json b/qapi/misc.json index 045eb7c..8b28270 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -573,7 +573,7 @@ 'mips': 'CpuInfoOther', 'tricore': 'CpuInfoOther', 's390': 'CpuInfoS390', - 'riscv': 'CpuInfoRISCV', + 'riscv': 'CpuInfoOther', 'other': 'CpuInfoOther' } } ## -- 1.8.3.1