From nobody Wed Oct 29 06:43:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524606534897998.2254379713952; Tue, 24 Apr 2018 14:48:54 -0700 (PDT) Received: from localhost ([::1]:60949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5np-00043Z-DS for importer@patchew.org; Tue, 24 Apr 2018 17:48:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5lK-0002lJ-5P for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB5lG-000725-Ub for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43528 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fB5lG-00071i-Q1; Tue, 24 Apr 2018 17:46:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0973A814DF4C; Tue, 24 Apr 2018 21:46:04 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-175.rdu2.redhat.com [10.10.120.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id C56EC2156A4E; Tue, 24 Apr 2018 21:46:02 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 23:45:45 +0200 Message-Id: <20180424214550.32549-2-lersek@redhat.com> In-Reply-To: <20180424214550.32549-1-lersek@redhat.com> References: <20180424214550.32549-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 24 Apr 2018 21:46:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 24 Apr 2018 21:46:05 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/6] qapi: fill in CpuInfoFast.arch in query-cpus-fast 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 Crosthwaite , qemu-stable@nongnu.org, Markus Armbruster , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit ca230ff33f89 added 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(). Cc: Eric Blake Cc: Markus Armbruster Cc: Paolo Bonzini Cc: Peter Crosthwaite Cc: Richard Henderson Cc: qemu-stable@nongnu.org Fixes: ca230ff33f89bf7102cbfbc2328716da6750aaed Signed-off-by: Laszlo Ersek Reviewed-by: Cornelia Huck Reviewed-by: Eric Blake --- Notes: PATCHv1: =20 - new patch cpus.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 38eba8bff334..1a9a2edee1f2 100644 --- a/cpus.c +++ b/cpus.c @@ -2210,27 +2210,39 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) info->value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); info->value->thread_id =3D cpu->thread_id; =20 info->value->has_props =3D !!mc->cpu_index_to_instance_props; if (info->value->has_props) { CpuInstanceProperties *props; props =3D g_malloc0(sizeof(*props)); *props =3D mc->cpu_index_to_instance_props(ms, cpu->cpu_index); info->value->props =3D props; } =20 -#if defined(TARGET_S390X) +#if defined(TARGET_I386) + info->value->arch =3D CPU_INFO_ARCH_X86; +#elif defined(TARGET_PPC) + info->value->arch =3D CPU_INFO_ARCH_PPC; +#elif defined(TARGET_SPARC) + info->value->arch =3D CPU_INFO_ARCH_SPARC; +#elif defined(TARGET_MIPS) + info->value->arch =3D CPU_INFO_ARCH_MIPS; +#elif defined(TARGET_TRICORE) + info->value->arch =3D CPU_INFO_ARCH_TRICORE; +#elif defined(TARGET_S390X) s390_cpu =3D S390_CPU(cpu); env =3D &s390_cpu->env; info->value->arch =3D CPU_INFO_ARCH_S390; info->value->u.s390.cpu_state =3D env->cpu_state; +#else + info->value->arch =3D CPU_INFO_ARCH_OTHER; #endif if (!cur_item) { head =3D cur_item =3D info; } else { cur_item->next =3D info; cur_item =3D info; } } =20 return head; } --=20 2.14.1.3.gb7cf6e02401b From nobody Wed Oct 29 06:43:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524606706085240.1878503840294; Tue, 24 Apr 2018 14:51:46 -0700 (PDT) Received: from localhost ([::1]:60968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5qj-0006YS-An for importer@patchew.org; Tue, 24 Apr 2018 17:51:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5lK-0002lI-4p for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB5lH-00072Z-VN for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47104 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fB5lH-00072Q-RK; Tue, 24 Apr 2018 17:46:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CCA3406C79C; Tue, 24 Apr 2018 21:46:06 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-175.rdu2.redhat.com [10.10.120.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46C4F2166BC6; Tue, 24 Apr 2018 21:46:04 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 23:45:46 +0200 Message-Id: <20180424214550.32549-3-lersek@redhat.com> In-Reply-To: <20180424214550.32549-1-lersek@redhat.com> References: <20180424214550.32549-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 24 Apr 2018 21:46:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 24 Apr 2018 21:46:07 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/6] qapi: handle the riscv CpuInfoArch in query-cpus-fast 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: Riku Voipio , Sagar Karandikar , Peter Crosthwaite , Bastian Koppelmann , qemu-stable@nongnu.org, Palmer Dabbelt , Laurent Vivier , Markus Armbruster , Michael Clark , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. In theory, there are two ways to fix this: (a) Fill in both the @arch field and the @CpuInfoRISCV sub-structure in qmp_query_cpus_fast(), by copying the logic from qmp_query_cpus(). (b) Assign @CpuInfoOther to the @riscv enum constant in @CpuInfoFast, and populate only the @arch field in qmp_query_cpus_fast(). Approach (b) seems more robust, because: - clearly there has never been an attempt to get actual RISV CPU state from qmp_query_cpus_fast(), so its lack of RISCV support is not actually a problem, - getting CPU state without interrupting KVM looks like an exceptional thing to do (only S390X does it currently). Cc: Bastian Koppelmann Cc: Eric Blake Cc: Laurent Vivier Cc: Markus Armbruster Cc: Michael Clark Cc: Palmer Dabbelt Cc: Paolo Bonzini Cc: Peter Crosthwaite Cc: Richard Henderson Cc: Riku Voipio Cc: Sagar Karandikar Cc: qemu-stable@nongnu.org Fixes: 25fa194b7b11901561532e435beb83d046899f7a Signed-off-by: Laszlo Ersek Reviewed-by: Eric Blake --- Notes: PATCHv1: =20 - new patch qapi/misc.json | 2 +- cpus.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index 5636f4a14997..104d013adba6 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -565,23 +565,23 @@ { 'union': 'CpuInfoFast', 'base': {'cpu-index': 'int', 'qom-path': 'str', 'thread-id': 'int', '*props': 'CpuInstanceProperties', 'arch': 'CpuInfoArch' }, 'discriminator': 'arch', 'data': { 'x86': 'CpuInfoOther', 'sparc': 'CpuInfoOther', 'ppc': 'CpuInfoOther', 'mips': 'CpuInfoOther', 'tricore': 'CpuInfoOther', 's390': 'CpuInfoS390', - 'riscv': 'CpuInfoRISCV', + 'riscv': 'CpuInfoOther', 'other': 'CpuInfoOther' } } =20 ## # @query-cpus-fast: # # Returns information about all virtual CPUs. This command does not # incur a performance penalty and should be used in production # instead of query-cpus. # # Returns: list of @CpuInfoFast # diff --git a/cpus.c b/cpus.c index 1a9a2edee1f2..60563a6d54ec 100644 --- a/cpus.c +++ b/cpus.c @@ -2225,22 +2225,24 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) #elif defined(TARGET_SPARC) info->value->arch =3D CPU_INFO_ARCH_SPARC; #elif defined(TARGET_MIPS) info->value->arch =3D CPU_INFO_ARCH_MIPS; #elif defined(TARGET_TRICORE) info->value->arch =3D CPU_INFO_ARCH_TRICORE; #elif defined(TARGET_S390X) s390_cpu =3D S390_CPU(cpu); env =3D &s390_cpu->env; info->value->arch =3D CPU_INFO_ARCH_S390; info->value->u.s390.cpu_state =3D env->cpu_state; +#elif defined(TARGET_RISCV) + info->value->arch =3D CPU_INFO_ARCH_RISCV; #else info->value->arch =3D CPU_INFO_ARCH_OTHER; #endif if (!cur_item) { head =3D cur_item =3D info; } else { cur_item->next =3D info; cur_item =3D info; } } =20 --=20 2.14.1.3.gb7cf6e02401b From nobody Wed Oct 29 06:43:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524606534881930.5275478131675; Tue, 24 Apr 2018 14:48:54 -0700 (PDT) Received: from localhost ([::1]:60948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5np-00042v-Pt for importer@patchew.org; Tue, 24 Apr 2018 17:48:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5lK-0002lH-4C for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB5lI-000730-Oa for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:32820 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fB5lI-00072m-Jq for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25B15406E8C3 for ; Tue, 24 Apr 2018 21:46:08 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-175.rdu2.redhat.com [10.10.120.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A751215CDD0; Tue, 24 Apr 2018 21:46:06 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 23:45:47 +0200 Message-Id: <20180424214550.32549-4-lersek@redhat.com> In-Reply-To: <20180424214550.32549-1-lersek@redhat.com> References: <20180424214550.32549-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 21:46:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 21:46:08 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 3/6] qapi: add SysEmuTarget to "common.json" 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: Thomas Huth , Kashyap Chamarthy , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We'll soon need an enumeration type that lists all the softmmu targets that QEMU (the project) supports. Introduce @SysEmuTarget to "common.json". Cc: "Daniel P. Berrange" Cc: David Gibson Cc: Eric Blake Cc: Gerd Hoffmann Cc: Kashyap Chamarthy Cc: Markus Armbruster Cc: Paolo Bonzini Cc: Thomas Huth Signed-off-by: Laszlo Ersek Reviewed-by: Markus Armbruster Reviewed-by: Kashyap Chamarthy --- Notes: PATCHv1: =20 - pick up R-b's from Markus and Kashyap, no changes =20 RFCv3: =20 - The patch is new in this version. [Dan, Markus] =20 - The original idea was to call the new enum @Target; however, @Target generates exactly the TARGET_AARCH64, TARGET_ALPHA, TARGET_ARM, ... enumeration constants that conflict with the poisoned preprocessing macros of the same names. Hence @SysEmuTarget -- it's more accurate anyway, since we want it to stand for system emulation targets. =20 - Also, we discussed defining the new type in either "common.json" or "misc.json". "misc.json" turned out to be a problem: "firmware.json" would then include "misc.json" for the new type's sake, but that inclusion would become the first appearance of "misc.json" -- within "firmware.json". That messed up the generated documentation. By adding the new type to "common.json", "misc.json" (see the 2nd patch) and "firmware.json" (see the 3rd patch) can both consume the new type without problems. qapi/common.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qapi/common.json b/qapi/common.json index d9b14dd429f3..1fd63172754a 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -118,11 +118,30 @@ # # @bar3: PCI BAR3 is used for the feature # # @bar4: PCI BAR4 is used for the feature # # @bar5: PCI BAR5 is used for the feature # # Since: 2.12 ## { 'enum': 'OffAutoPCIBAR', 'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' = ] } + +## +# @SysEmuTarget: +# +# The comprehensive enumeration of QEMU system emulation ("softmmu") +# targets. Run "./configure --help" in the project root directory, and +# look for the *-softmmu targets near the "--target-list" option. The +# individual target constants are not documented here, for the time +# being. +# +# Since: 2.13 +## +{ 'enum' : 'SysEmuTarget', + 'data' : [ 'aarch64', 'alpha', 'arm', 'cris', 'hppa', 'i386', 'lm32', + 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', + 'mips64el', 'mipsel', 'moxie', 'nios2', 'or1k', 'ppc', + 'ppc64', 'ppcemb', 'riscv32', 'riscv64', 's390x', 'sh4', + 'sh4eb', 'sparc', 'sparc64', 'tricore', 'unicore32', + 'x86_64', 'xtensa', 'xtensaeb' ] } --=20 2.14.1.3.gb7cf6e02401b From nobody Wed Oct 29 06:43:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524606821909661.8269916265508; Tue, 24 Apr 2018 14:53:41 -0700 (PDT) Received: from localhost ([::1]:60976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5sa-0008C1-Lm for importer@patchew.org; Tue, 24 Apr 2018 17:53:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5lL-0002lV-Gp for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB5lK-000752-HE for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:11 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:32822 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fB5lK-00074V-AH for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB28C4072CC4 for ; Tue, 24 Apr 2018 21:46:09 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-175.rdu2.redhat.com [10.10.120.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61D462156A4F; Tue, 24 Apr 2018 21:46:08 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 23:45:48 +0200 Message-Id: <20180424214550.32549-5-lersek@redhat.com> In-Reply-To: <20180424214550.32549-1-lersek@redhat.com> References: <20180424214550.32549-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 21:46:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 21:46:09 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 4/6] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget 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: Thomas Huth , Kashyap Chamarthy , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that we have @SysEmuTarget, it makes sense to restict @TargetInfo.@arch to valid sysemu targets at the schema level. Cc: "Daniel P. Berrange" Cc: David Gibson Cc: Eric Blake Cc: Gerd Hoffmann Cc: Kashyap Chamarthy Cc: Markus Armbruster Cc: Paolo Bonzini Cc: Thomas Huth Signed-off-by: Laszlo Ersek Reviewed-by: Markus Armbruster --- Notes: PATCHv1: =20 - qmp_query_target(): pass (-1) as fallback value [Markus] - qmp_query_target(): catch lookup error with error_abort [Markus] =20 RFCv3: =20 - The patch is new in this version. [Markus] qapi/misc.json | 6 ++++-- arch_init.c | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index 104d013adba6..460866cf542f 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1,18 +1,20 @@ # -*- Mode: Python -*- # =20 ## # =3D Miscellanea ## =20 +{ 'include': 'common.json' } + ## # @qmp_capabilities: # # Enable QMP capabilities. # # Arguments: # # @enable: An optional list of QMPCapability values to enable. The # client must not enable any capability that is not # mentioned in the QMP greeting message. If the field is not # provided, it means no QMP capabilities will be enabled. @@ -2441,28 +2443,28 @@ # ] # } # ## { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } =20 ## # @TargetInfo: # # Information describing the QEMU target. # -# @arch: the target architecture (eg "x86_64", "i386", etc) +# @arch: the target architecture # # Since: 1.2.0 ## { 'struct': 'TargetInfo', - 'data': { 'arch': 'str' } } + 'data': { 'arch': 'SysEmuTarget' } } =20 ## # @query-target: # # Return information about the target for this QEMU # # Returns: TargetInfo # # Since: 1.2.0 ## { 'command': 'query-target', 'returns': 'TargetInfo' } diff --git a/arch_init.c b/arch_init.c index 6ee07478bd11..ee3a57019000 100644 --- a/arch_init.c +++ b/arch_init.c @@ -21,22 +21,23 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN * THE SOFTWARE. */ #include "qemu/osdep.h" #include "qemu-common.h" #include "cpu.h" #include "sysemu/sysemu.h" #include "sysemu/arch_init.h" #include "hw/pci/pci.h" #include "hw/audio/soundhw.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "hw/acpi/acpi.h" #include "qemu/help_option.h" =20 #ifdef TARGET_SPARC int graphic_width =3D 1024; int graphic_height =3D 768; int graphic_depth =3D 8; #else int graphic_width =3D 800; @@ -104,15 +105,22 @@ int xen_available(void) return 1; #else return 0; #endif } =20 =20 TargetInfo *qmp_query_target(Error **errp) { TargetInfo *info =3D g_malloc0(sizeof(*info)); =20 - info->arch =3D g_strdup(TARGET_NAME); + /* + * The fallback enum value is irrelevant here (TARGET_NAME is a + * macro and can never be NULL), so simply pass (-1). Also, the + * lookup should never fail -- if it fails, then @SysEmuTarget needs + * extending. Catch that with "error_abort". + */ + info->arch =3D qapi_enum_parse(&SysEmuTarget_lookup, TARGET_NAME, -1, + &error_abort); =20 return info; } --=20 2.14.1.3.gb7cf6e02401b From nobody Wed Oct 29 06:43:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524606643813711.1525681441049; Tue, 24 Apr 2018 14:50:43 -0700 (PDT) Received: from localhost ([::1]:60963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5pj-0005mC-1S for importer@patchew.org; Tue, 24 Apr 2018 17:50:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5lM-0002ls-Ql for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB5lL-00075Z-Cv for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:32824 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fB5lL-00075P-8I for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB839406E97E for ; Tue, 24 Apr 2018 21:46:10 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-175.rdu2.redhat.com [10.10.120.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23B5B2156A32; Tue, 24 Apr 2018 21:46:10 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 23:45:49 +0200 Message-Id: <20180424214550.32549-6-lersek@redhat.com> In-Reply-To: <20180424214550.32549-1-lersek@redhat.com> References: <20180424214550.32549-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 21:46:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 21:46:10 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 5/6] qapi: extract CpuInfoCommon to mitigate schema duplication 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: Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" @CpuInfo and @CpuInfoFast duplicate the following four fields: @qom-path, @thread-id, @props and @arch. From these, extract the first three to a common structure called @CpuInfoCommon. (More on @arch later.) Introduce two new mid-layer structures, @CpuInfoBase and @CpuInfoFastBase, to soak up the union base struct fields on top of @CpuInfoCommon that are specific to @query-cpus and @query-cpus-fast, respectively. This is necessary because the base struct spec in union definitions does not let us mix named fields with a recursive base struct. (In other words, we couldn't directly use @CpuInfoCommon *plus* some other fields within @CpuInfo and @CpuInfoFast as base struct). @arch cannot be hoisted higher than to @CpuInfoBase and @CpuInfoFastBase because the union descriminator is only accepted from a direct base struct, not from an indirect one. Cc: Eric Blake Cc: Markus Armbruster Signed-off-by: Laszlo Ersek --- Notes: PATCHv1: =20 - new patch qapi/misc.json | 94 +++++++++++++++++++++++++--------= ---- qapi/qapi-schema.json | 2 +- tests/test-x86-cpuid-compat.c | 2 +- tests/migration/guestperf/engine.py | 2 +- 4 files changed, 68 insertions(+), 32 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index 460866cf542f..d7b776a5af37 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -348,52 +348,81 @@ # # @s390: since 2.12 # # @riscv: since 2.12 # # Since: 2.6 ## { 'enum': 'CpuInfoArch', 'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 's390', 'riscv', 'oth= er' ] } =20 ## -# @CpuInfo: +# @CpuInfoCommon: # -# Information about a virtual CPU +# Collects fields common to @CpuInfoBase and @CpuInfoFastBase; that is, +# fields that are shared by @query-cpus and @query-cpus-fast, and not +# specific to the target architecture. +# +# @qom-path: path to the CPU object in the QOM tree (since 2.4) +# +# @thread-id: ID of the underlying host thread +# +# @props: properties describing which node/socket/core/thread the +# virtual CPU belongs to, if supported by the board (since 2.10) +# +# Since: 2.13 +## +{ 'struct' : 'CpuInfoCommon', + 'data' : { 'qom-path' : 'str', + 'thread-id' : 'int', + '*props' : 'CpuInstanceProperties' } } + +## +# @CpuInfoBase: +# +# Extends @CpuInfoCommon with fields that are specific to the @query-cpus +# command, but not specific to the target architecture. # # @CPU: the index of the virtual CPU # # @current: this only exists for backwards compatibility and should be ign= ored # # @halted: true if the virtual CPU is in the halt state. Halt usually ref= ers # to a processor specific low power mode. # -# @qom_path: path to the CPU object in the QOM tree (since 2.4) -# -# @thread_id: ID of the underlying host thread -# -# @props: properties describing to which node/socket/core/thread -# virtual CPU belongs to, provided if supported by board (since 2.= 10) -# # @arch: architecture of the cpu, which determines which additional fields # will be listed (since 2.6) # -# Since: 0.14.0 +# Since: 2.13 # # Notes: @halted is a transient state that changes frequently. By the tim= e the # data is sent to the client, the guest may no longer be halted. +# Moreover, @arch cannot be moved up to @CpuInfoCommon because +# that would prevent its use as the discriminator in @CpuInfo. +## +{ 'struct' : 'CpuInfoBase', + 'base' : 'CpuInfoCommon', + 'data' : { 'CPU' : 'int', + 'current' : 'bool', + 'halted' : 'bool', + 'arch' : 'CpuInfoArch' } } + +## +# @CpuInfo: +# +# Information about a virtual CPU +# +# Since: 0.14.0 ## { 'union': 'CpuInfo', - 'base': {'CPU': 'int', 'current': 'bool', 'halted': 'bool', - 'qom_path': 'str', 'thread_id': 'int', - '*props': 'CpuInstanceProperties', 'arch': 'CpuInfoArch' }, + 'base': 'CpuInfoBase', 'discriminator': 'arch', 'data': { 'x86': 'CpuInfoX86', 'sparc': 'CpuInfoSPARC', 'ppc': 'CpuInfoPPC', 'mips': 'CpuInfoMIPS', 'tricore': 'CpuInfoTricore', 's390': 'CpuInfoS390', 'riscv': 'CpuInfoRISCV', 'other': 'CpuInfoOther' } } =20 ## @@ -512,70 +541,77 @@ # # Since: 0.14.0 # # Example: # # -> { "execute": "query-cpus" } # <- { "return": [ # { # "CPU":0, # "current":true, # "halted":false, -# "qom_path":"/machine/unattached/device[0]", +# "qom-path":"/machine/unattached/device[0]", # "arch":"x86", # "pc":3227107138, -# "thread_id":3134 +# "thread-id":3134 # }, # { # "CPU":1, # "current":false, # "halted":true, -# "qom_path":"/machine/unattached/device[2]", +# "qom-path":"/machine/unattached/device[2]", # "arch":"x86", # "pc":7108165, -# "thread_id":3135 +# "thread-id":3135 # } # ] # } # # Notes: This interface is deprecated (since 2.12.0), and it is strongly # recommended that you avoid using it. Use @query-cpus-fast to # obtain information about virtual CPUs. # ## { 'command': 'query-cpus', 'returns': ['CpuInfo'] } =20 ## -# @CpuInfoFast: +# @CpuInfoFastBase: # -# Information about a virtual CPU +# Extends @CpuInfoCommon with fields that are specific to the +# @query-cpus-fast command, but not specific to the target architecture. # # @cpu-index: index of the virtual CPU # -# @qom-path: path to the CPU object in the QOM tree -# -# @thread-id: ID of the underlying host thread -# -# @props: properties describing to which node/socket/core/thread -# virtual CPU belongs to, provided if supported by board -# # @arch: architecture of the cpu, which determines which additional fields # will be listed # +# Since: 2.13 +# +# Notes: @arch cannot be moved up to @CpuInfoCommon because that would +# prevent its use as the discriminator in @CpuInfoFast. +## +{ 'struct' : 'CpuInfoFastBase', + 'base' : 'CpuInfoCommon', + 'data' : { 'cpu-index' : 'int', + 'arch' : 'CpuInfoArch' } } + +## +# @CpuInfoFast: +# +# Information about a virtual CPU +# # Since: 2.12 # ## { 'union': 'CpuInfoFast', - 'base': {'cpu-index': 'int', 'qom-path': 'str', - 'thread-id': 'int', '*props': 'CpuInstanceProperties', - 'arch': 'CpuInfoArch' }, + 'base': 'CpuInfoFastBase', 'discriminator': 'arch', 'data': { 'x86': 'CpuInfoOther', 'sparc': 'CpuInfoOther', 'ppc': 'CpuInfoOther', 'mips': 'CpuInfoOther', 'tricore': 'CpuInfoOther', 's390': 'CpuInfoS390', 'riscv': 'CpuInfoOther', 'other': 'CpuInfoOther' } } =20 ## diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 25bce78352b8..5bfd2ef1dd3b 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -61,23 +61,23 @@ 'query-migrate-cache-size', 'query-tpm-models', 'query-tpm-types', 'ringbuf-read' ], 'name-case-whitelist': [ 'ACPISlotType', # DIMM, visible through query-acpi-ospm-st= atus 'CpuInfoMIPS', # PC, visible through query-cpu 'CpuInfoTricore', # PC, visible through query-cpu 'QapiErrorClass', # all members, visible through errors 'UuidInfo', # UUID, visible through query-uuid 'X86CPURegister32', # all members, visible indirectly through = qom-get - 'q_obj_CpuInfo-base' # CPU, visible through query-cpu + 'CpuInfoBase' # CPU, visible through query-cpu ] } } =20 # Documentation generated with qapi-gen.py is in source order, with # included sub-schemas inserted at the first include directive # (subsequent include directives have no effect). To get a sane and # stable order, it's best to include each sub-schema just once, or # include it first right here. =20 { 'include': 'common.json' } { 'include': 'sockets.json' } { 'include': 'run-state.json' } diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 02e41843fc9c..df51b3bbacbc 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -10,23 +10,23 @@ static char *get_cpu0_qom_path(void) { QDict *resp; QList *ret; QDict *cpu0; char *path; =20 resp =3D qmp("{'execute': 'query-cpus', 'arguments': {}}"); g_assert(qdict_haskey(resp, "return")); ret =3D qdict_get_qlist(resp, "return"); =20 cpu0 =3D qobject_to(QDict, qlist_peek(ret)); - path =3D g_strdup(qdict_get_str(cpu0, "qom_path")); + path =3D g_strdup(qdict_get_str(cpu0, "qom-path")); QDECREF(resp); return path; } =20 static QObject *qom_get(const char *path, const char *prop) { QDict *resp =3D qmp("{ 'execute': 'qom-get'," " 'arguments': { 'path': %s," " 'property': %s } }", path, prop); QObject *ret =3D qdict_get(resp, "return"); diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestper= f/engine.py index e14d4320b239..663881c163e9 100644 --- a/tests/migration/guestperf/engine.py +++ b/tests/migration/guestperf/engine.py @@ -104,23 +104,23 @@ class Engine(object): info.get("x-cpu-throttle-percentage", 0), ) =20 def _migrate(self, hardware, scenario, src, dst, connect_uri): src_qemu_time =3D [] src_vcpu_time =3D [] src_pid =3D src.get_pid() =20 vcpus =3D src.command("query-cpus") src_threads =3D [] for vcpu in vcpus: - src_threads.append(vcpu["thread_id"]) + src_threads.append(vcpu["thread-id"]) =20 # XXX how to get dst timings on remote host ? =20 if self._verbose: print "Sleeping %d seconds for initial guest workload run" % s= elf._sleep sleep_secs =3D self._sleep while sleep_secs > 1: src_qemu_time.append(self._cpu_timing(src_pid)) src_vcpu_time.extend(self._vcpu_timing(src_pid, src_threads)) time.sleep(1) sleep_secs -=3D 1 --=20 2.14.1.3.gb7cf6e02401b From nobody Wed Oct 29 06:43:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524606709809671.7588662379467; Tue, 24 Apr 2018 14:51:49 -0700 (PDT) Received: from localhost ([::1]:60969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5qm-0006b2-Tb for importer@patchew.org; Tue, 24 Apr 2018 17:51:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5lQ-0002sS-C4 for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB5lN-00077R-Vo for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53832 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fB5lN-00077L-PG for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B617EC013; Tue, 24 Apr 2018 21:46:12 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-175.rdu2.redhat.com [10.10.120.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14A0F2166BC6; Tue, 24 Apr 2018 21:46:10 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 23:45:50 +0200 Message-Id: <20180424214550.32549-7-lersek@redhat.com> In-Reply-To: <20180424214550.32549-1-lersek@redhat.com> References: <20180424214550.32549-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 24 Apr 2018 21:46:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 24 Apr 2018 21:46:13 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 6/6] qapi: discriminate CpuInfo[Fast] on SysEmuTarget, not CpuInfoArch 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: Paolo Bonzini , Richard Henderson , Markus Armbruster , Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a new field @target (of type @SysEmuTarget) to the outputs of the @query-cpus and @query-cpus-fast commands, which provides more information about the emulation target than the field @arch (of type @CpuInfoArch). Keep @arch for compatibility. Make @target the new discriminator for the @CpuInfo and @CpuInfoFast return structures. This lets us hoist @arch to @CpuInfoCommon, but it also requires some gymnastics in qmp_query_cpus() and qmp_query_cpus_fast(). In particular, conditional compilation cannot be removed, because each pair of CPU base arch structures, such as X86CPU/CPUX86State, PowerPCCPU/CPUPPCState, SPARCCPU/CPUSPARCState, is only visible when building QEMU for a target that maps to that CPU base arch. Cc: Eric Blake Cc: Markus Armbruster Cc: Paolo Bonzini Cc: Peter Crosthwaite Cc: Richard Henderson Signed-off-by: Laszlo Ersek --- Notes: PATCHv1: =20 - new patch qapi/misc.json | 118 ++++++++++++++++++------- cpus.c | 275 ++++++++++++++++++++++++++++++++++++++++++-----------= ---- 2 files changed, 291 insertions(+), 102 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index d7b776a5af37..98c15880f9f0 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -361,77 +361,105 @@ # Collects fields common to @CpuInfoBase and @CpuInfoFastBase; that is, # fields that are shared by @query-cpus and @query-cpus-fast, and not # specific to the target architecture. # # @qom-path: path to the CPU object in the QOM tree (since 2.4) # # @thread-id: ID of the underlying host thread # # @props: properties describing which node/socket/core/thread the # virtual CPU belongs to, if supported by the board (since 2.10) # +# @arch: base architecture of the cpu (since 2.6) +# # Since: 2.13 ## { 'struct' : 'CpuInfoCommon', 'data' : { 'qom-path' : 'str', 'thread-id' : 'int', - '*props' : 'CpuInstanceProperties' } } + '*props' : 'CpuInstanceProperties', + 'arch' : 'CpuInfoArch' } } =20 ## # @CpuInfoBase: # # Extends @CpuInfoCommon with fields that are specific to the @query-cpus # command, but not specific to the target architecture. # # @CPU: the index of the virtual CPU # # @current: this only exists for backwards compatibility and should be ign= ored # # @halted: true if the virtual CPU is in the halt state. Halt usually ref= ers # to a processor specific low power mode. # -# @arch: architecture of the cpu, which determines which additional fields -# will be listed (since 2.6) +# @target: the QEMU system emulation target, which is more specific than +# @arch and determines which additional fields will be listed +# # # Since: 2.13 # # Notes: @halted is a transient state that changes frequently. By the tim= e the # data is sent to the client, the guest may no longer be halted. -# Moreover, @arch cannot be moved up to @CpuInfoCommon because +# Moreover, @target cannot be moved up to @CpuInfoCommon because # that would prevent its use as the discriminator in @CpuInfo. ## { 'struct' : 'CpuInfoBase', 'base' : 'CpuInfoCommon', 'data' : { 'CPU' : 'int', 'current' : 'bool', 'halted' : 'bool', - 'arch' : 'CpuInfoArch' } } + 'target' : 'SysEmuTarget' } } =20 ## # @CpuInfo: # # Information about a virtual CPU # # Since: 0.14.0 ## -{ 'union': 'CpuInfo', - 'base': 'CpuInfoBase', - 'discriminator': 'arch', - 'data': { 'x86': 'CpuInfoX86', - 'sparc': 'CpuInfoSPARC', - 'ppc': 'CpuInfoPPC', - 'mips': 'CpuInfoMIPS', - 'tricore': 'CpuInfoTricore', - 's390': 'CpuInfoS390', - 'riscv': 'CpuInfoRISCV', - 'other': 'CpuInfoOther' } } +{ 'union' : 'CpuInfo', + 'base' : 'CpuInfoBase', + 'discriminator' : 'target', + 'data' : { 'i386' : 'CpuInfoX86', + 'x86_64' : 'CpuInfoX86', + 'sparc' : 'CpuInfoSPARC', + 'sparc64' : 'CpuInfoSPARC', + 'ppc' : 'CpuInfoPPC', + 'ppcemb' : 'CpuInfoPPC', + 'ppc64' : 'CpuInfoPPC', + 'mips' : 'CpuInfoMIPS', + 'mipsel' : 'CpuInfoMIPS', + 'mips64' : 'CpuInfoMIPS', + 'mips64el' : 'CpuInfoMIPS', + 'tricore' : 'CpuInfoTricore', + 's390x' : 'CpuInfoS390', + 'riscv32' : 'CpuInfoRISCV', + 'riscv64' : 'CpuInfoRISCV', + 'aarch64' : 'CpuInfoOther', + 'alpha' : 'CpuInfoOther', + 'arm' : 'CpuInfoOther', + 'cris' : 'CpuInfoOther', + 'hppa' : 'CpuInfoOther', + 'lm32' : 'CpuInfoOther', + 'm68k' : 'CpuInfoOther', + 'microblaze' : 'CpuInfoOther', + 'microblazeel' : 'CpuInfoOther', + 'moxie' : 'CpuInfoOther', + 'nios2' : 'CpuInfoOther', + 'or1k' : 'CpuInfoOther', + 'sh4' : 'CpuInfoOther', + 'sh4eb' : 'CpuInfoOther', + 'unicore32' : 'CpuInfoOther', + 'xtensa' : 'CpuInfoOther', + 'xtensaeb' : 'CpuInfoOther' } } =20 ## # @CpuInfoX86: # # Additional information about a virtual i386 or x86_64 CPU # # @pc: the 64-bit instruction pointer # # Since: 2.6 ## { 'struct': 'CpuInfoX86', 'data': { 'pc': 'int' } } @@ -543,84 +571,110 @@ # # Example: # # -> { "execute": "query-cpus" } # <- { "return": [ # { # "CPU":0, # "current":true, # "halted":false, # "qom-path":"/machine/unattached/device[0]", # "arch":"x86", +# "target":"x86_64", # "pc":3227107138, # "thread-id":3134 # }, # { # "CPU":1, # "current":false, # "halted":true, # "qom-path":"/machine/unattached/device[2]", # "arch":"x86", +# "target":"x86_64", # "pc":7108165, # "thread-id":3135 # } # ] # } # # Notes: This interface is deprecated (since 2.12.0), and it is strongly # recommended that you avoid using it. Use @query-cpus-fast to # obtain information about virtual CPUs. # ## { 'command': 'query-cpus', 'returns': ['CpuInfo'] } =20 ## # @CpuInfoFastBase: # # Extends @CpuInfoCommon with fields that are specific to the # @query-cpus-fast command, but not specific to the target architecture. # # @cpu-index: index of the virtual CPU # -# @arch: architecture of the cpu, which determines which additional fields -# will be listed +# @target: the QEMU system emulation target, which is more specific than +# @arch and determines which additional fields will be listed # # Since: 2.13 # -# Notes: @arch cannot be moved up to @CpuInfoCommon because that would +# Notes: @target cannot be moved up to @CpuInfoCommon because that would # prevent its use as the discriminator in @CpuInfoFast. ## { 'struct' : 'CpuInfoFastBase', 'base' : 'CpuInfoCommon', 'data' : { 'cpu-index' : 'int', - 'arch' : 'CpuInfoArch' } } + 'target' : 'SysEmuTarget' } } =20 ## # @CpuInfoFast: # # Information about a virtual CPU # # Since: 2.12 # ## -{ 'union': 'CpuInfoFast', - 'base': 'CpuInfoFastBase', - 'discriminator': 'arch', - 'data': { 'x86': 'CpuInfoOther', - 'sparc': 'CpuInfoOther', - 'ppc': 'CpuInfoOther', - 'mips': 'CpuInfoOther', - 'tricore': 'CpuInfoOther', - 's390': 'CpuInfoS390', - 'riscv': 'CpuInfoOther', - 'other': 'CpuInfoOther' } } +{ 'union' : 'CpuInfoFast', + 'base' : 'CpuInfoFastBase', + 'discriminator' : 'target', + 'data' : { 'i386' : 'CpuInfoOther', + 'x86_64' : 'CpuInfoOther', + 'sparc' : 'CpuInfoOther', + 'sparc64' : 'CpuInfoOther', + 'ppc' : 'CpuInfoOther', + 'ppcemb' : 'CpuInfoOther', + 'ppc64' : 'CpuInfoOther', + 'mips' : 'CpuInfoOther', + 'mipsel' : 'CpuInfoOther', + 'mips64' : 'CpuInfoOther', + 'mips64el' : 'CpuInfoOther', + 'tricore' : 'CpuInfoOther', + 's390x' : 'CpuInfoS390', + 'riscv32' : 'CpuInfoOther', + 'riscv64' : 'CpuInfoOther', + 'aarch64' : 'CpuInfoOther', + 'alpha' : 'CpuInfoOther', + 'arm' : 'CpuInfoOther', + 'cris' : 'CpuInfoOther', + 'hppa' : 'CpuInfoOther', + 'lm32' : 'CpuInfoOther', + 'm68k' : 'CpuInfoOther', + 'microblaze' : 'CpuInfoOther', + 'microblazeel' : 'CpuInfoOther', + 'moxie' : 'CpuInfoOther', + 'nios2' : 'CpuInfoOther', + 'or1k' : 'CpuInfoOther', + 'sh4' : 'CpuInfoOther', + 'sh4eb' : 'CpuInfoOther', + 'unicore32' : 'CpuInfoOther', + 'xtensa' : 'CpuInfoOther', + 'xtensaeb' : 'CpuInfoOther' } } =20 ## # @query-cpus-fast: # # Returns information about all virtual CPUs. This command does not # incur a performance penalty and should be used in production # instead of query-cpus. # # Returns: list of @CpuInfoFast # # Since: 2.12 @@ -630,33 +684,35 @@ # -> { "execute": "query-cpus-fast" } # <- { "return": [ # { # "thread-id": 25627, # "props": { # "core-id": 0, # "thread-id": 0, # "socket-id": 0 # }, # "qom-path": "/machine/unattached/device[0]", # "arch":"x86", +# "target":"x86_64", # "cpu-index": 0 # }, # { # "thread-id": 25628, # "props": { # "core-id": 0, # "thread-id": 0, # "socket-id": 1 # }, # "qom-path": "/machine/unattached/device[2]", # "arch":"x86", +# "target":"x86_64", # "cpu-index": 1 # } # ] # } ## { 'command': 'query-cpus-fast', 'returns': [ 'CpuInfoFast' ] } =20 ## # @IOThreadInfo: # # Information about an iothread diff --git a/cpus.c b/cpus.c index 60563a6d54ec..86eed0ffe796 100644 --- a/cpus.c +++ b/cpus.c @@ -2093,88 +2093,235 @@ int vm_stop_force_state(RunState state) } } =20 void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) cpu_list(f, cpu_fprintf); #endif } =20 +static CpuInfoArch sysemu_target_to_cpuinfo_arch(SysEmuTarget target) +{ + /* + * The @SysEmuTarget -> @CpuInfoArch mapping below is based on the + * TARGET_ARCH -> TARGET_BASE_ARCH mapping in the "configure" script. + */ + switch (target) { + case SYS_EMU_TARGET_I386: + case SYS_EMU_TARGET_X86_64: + return CPU_INFO_ARCH_X86; + + case SYS_EMU_TARGET_PPC: + case SYS_EMU_TARGET_PPCEMB: + case SYS_EMU_TARGET_PPC64: + return CPU_INFO_ARCH_PPC; + + case SYS_EMU_TARGET_SPARC: + case SYS_EMU_TARGET_SPARC64: + return CPU_INFO_ARCH_SPARC; + + case SYS_EMU_TARGET_MIPS: + case SYS_EMU_TARGET_MIPSEL: + case SYS_EMU_TARGET_MIPS64: + case SYS_EMU_TARGET_MIPS64EL: + return CPU_INFO_ARCH_MIPS; + + case SYS_EMU_TARGET_TRICORE: + return CPU_INFO_ARCH_TRICORE; + + case SYS_EMU_TARGET_S390X: + return CPU_INFO_ARCH_S390; + + case SYS_EMU_TARGET_RISCV32: + case SYS_EMU_TARGET_RISCV64: + return CPU_INFO_ARCH_RISCV; + + default: + return CPU_INFO_ARCH_OTHER; + } +} + +static void cpustate_to_cpuinfo_x86(CpuInfoX86 *info, const CPUState *cpu) +{ +#ifdef TARGET_I386 + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + + info->pc =3D env->eip + env->segs[R_CS].base; +#else + abort(); +#endif +} + +static void cpustate_to_cpuinfo_ppc(CpuInfoPPC *info, const CPUState *cpu) +{ +#ifdef TARGET_PPC + PowerPCCPU *ppc_cpu =3D POWERPC_CPU(cpu); + CPUPPCState *env =3D &ppc_cpu->env; + + info->nip =3D env->nip; +#else + abort(); +#endif +} + +static void cpustate_to_cpuinfo_sparc(CpuInfoSPARC *info, const CPUState *= cpu) +{ +#ifdef TARGET_SPARC + SPARCCPU *sparc_cpu =3D SPARC_CPU(cpu); + CPUSPARCState *env =3D &sparc_cpu->env; + + info->pc =3D env->pc; + info->npc =3D env->npc; +#else + abort(); +#endif +} + +static void cpustate_to_cpuinfo_mips(CpuInfoMIPS *info, const CPUState *cp= u) +{ +#ifdef TARGET_MIPS + MIPSCPU *mips_cpu =3D MIPS_CPU(cpu); + CPUMIPSState *env =3D &mips_cpu->env; + + info->PC =3D env->active_tc.PC; +#else + abort(); +#endif +} + +static void cpustate_to_cpuinfo_tricore(CpuInfoTricore *info, + const CPUState *cpu) +{ +#ifdef TARGET_TRICORE + TriCoreCPU *tricore_cpu =3D TRICORE_CPU(cpu); + CPUTriCoreState *env =3D &tricore_cpu->env; + + info->PC =3D env->PC; +#else + abort(); +#endif +} + +static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, const CPUState *cp= u) +{ +#ifdef TARGET_S390X + S390CPU *s390_cpu =3D S390_CPU(cpu); + CPUS390XState *env =3D &s390_cpu->env; + + info->cpu_state =3D env->cpu_state; +#else + abort(); +#endif +} + +static void cpustate_to_cpuinfo_riscv(CpuInfoRISCV *info, const CPUState *= cpu) +{ +#ifdef TARGET_RISCV + RISCVCPU *riscv_cpu =3D RISCV_CPU(cpu); + CPURISCVState *env =3D &riscv_cpu->env; + + info->pc =3D env->pc; +#else + abort(); +#endif +} + CpuInfoList *qmp_query_cpus(Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(ms); CpuInfoList *head =3D NULL, *cur_item =3D NULL; + SysEmuTarget target =3D qapi_enum_parse(&SysEmuTarget_lookup, TARGET_N= AME, + -1, &error_abort); CPUState *cpu; =20 CPU_FOREACH(cpu) { CpuInfoList *info; -#if defined(TARGET_I386) - X86CPU *x86_cpu =3D X86_CPU(cpu); - CPUX86State *env =3D &x86_cpu->env; -#elif defined(TARGET_PPC) - PowerPCCPU *ppc_cpu =3D POWERPC_CPU(cpu); - CPUPPCState *env =3D &ppc_cpu->env; -#elif defined(TARGET_SPARC) - SPARCCPU *sparc_cpu =3D SPARC_CPU(cpu); - CPUSPARCState *env =3D &sparc_cpu->env; -#elif defined(TARGET_RISCV) - RISCVCPU *riscv_cpu =3D RISCV_CPU(cpu); - CPURISCVState *env =3D &riscv_cpu->env; -#elif defined(TARGET_MIPS) - MIPSCPU *mips_cpu =3D MIPS_CPU(cpu); - CPUMIPSState *env =3D &mips_cpu->env; -#elif defined(TARGET_TRICORE) - TriCoreCPU *tricore_cpu =3D TRICORE_CPU(cpu); - CPUTriCoreState *env =3D &tricore_cpu->env; -#elif defined(TARGET_S390X) - S390CPU *s390_cpu =3D S390_CPU(cpu); - CPUS390XState *env =3D &s390_cpu->env; -#endif =20 cpu_synchronize_state(cpu); =20 info =3D g_malloc0(sizeof(*info)); info->value =3D g_malloc0(sizeof(*info->value)); info->value->CPU =3D cpu->cpu_index; info->value->current =3D (cpu =3D=3D first_cpu); info->value->halted =3D cpu->halted; info->value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); info->value->thread_id =3D cpu->thread_id; -#if defined(TARGET_I386) - info->value->arch =3D CPU_INFO_ARCH_X86; - info->value->u.x86.pc =3D env->eip + env->segs[R_CS].base; -#elif defined(TARGET_PPC) - info->value->arch =3D CPU_INFO_ARCH_PPC; - info->value->u.ppc.nip =3D env->nip; -#elif defined(TARGET_SPARC) - info->value->arch =3D CPU_INFO_ARCH_SPARC; - info->value->u.q_sparc.pc =3D env->pc; - info->value->u.q_sparc.npc =3D env->npc; -#elif defined(TARGET_MIPS) - info->value->arch =3D CPU_INFO_ARCH_MIPS; - info->value->u.q_mips.PC =3D env->active_tc.PC; -#elif defined(TARGET_TRICORE) - info->value->arch =3D CPU_INFO_ARCH_TRICORE; - info->value->u.tricore.PC =3D env->PC; -#elif defined(TARGET_S390X) - info->value->arch =3D CPU_INFO_ARCH_S390; - info->value->u.s390.cpu_state =3D env->cpu_state; -#elif defined(TARGET_RISCV) - info->value->arch =3D CPU_INFO_ARCH_RISCV; - info->value->u.riscv.pc =3D env->pc; -#else - info->value->arch =3D CPU_INFO_ARCH_OTHER; -#endif + info->value->arch =3D sysemu_target_to_cpuinfo_arch(target); + info->value->target =3D target; + + /* + * The @SysEmuTarget -> @CpuInfo mapping below is based on the + * TARGET_ARCH -> TARGET_BASE_ARCH mapping in the "configure" scri= pt. + */ + switch (target) { + case SYS_EMU_TARGET_I386: + cpustate_to_cpuinfo_x86(&info->value->u.i386, cpu); + break; + case SYS_EMU_TARGET_X86_64: + cpustate_to_cpuinfo_x86(&info->value->u.x86_64, cpu); + break; + + case SYS_EMU_TARGET_PPC: + cpustate_to_cpuinfo_ppc(&info->value->u.ppc, cpu); + break; + case SYS_EMU_TARGET_PPCEMB: + cpustate_to_cpuinfo_ppc(&info->value->u.ppcemb, cpu); + break; + case SYS_EMU_TARGET_PPC64: + cpustate_to_cpuinfo_ppc(&info->value->u.ppc64, cpu); + break; + + case SYS_EMU_TARGET_SPARC: + cpustate_to_cpuinfo_sparc(&info->value->u.q_sparc, cpu); + break; + case SYS_EMU_TARGET_SPARC64: + cpustate_to_cpuinfo_sparc(&info->value->u.sparc64, cpu); + break; + + case SYS_EMU_TARGET_MIPS: + cpustate_to_cpuinfo_mips(&info->value->u.q_mips, cpu); + break; + case SYS_EMU_TARGET_MIPSEL: + cpustate_to_cpuinfo_mips(&info->value->u.mipsel, cpu); + break; + case SYS_EMU_TARGET_MIPS64: + cpustate_to_cpuinfo_mips(&info->value->u.mips64, cpu); + break; + case SYS_EMU_TARGET_MIPS64EL: + cpustate_to_cpuinfo_mips(&info->value->u.mips64el, cpu); + break; + + case SYS_EMU_TARGET_TRICORE: + cpustate_to_cpuinfo_tricore(&info->value->u.tricore, cpu); + break; + + case SYS_EMU_TARGET_S390X: + cpustate_to_cpuinfo_s390(&info->value->u.s390x, cpu); + break; + + case SYS_EMU_TARGET_RISCV32: + cpustate_to_cpuinfo_riscv(&info->value->u.riscv32, cpu); + break; + case SYS_EMU_TARGET_RISCV64: + cpustate_to_cpuinfo_riscv(&info->value->u.riscv64, cpu); + break; + + default: + /* do nothing for @CpuInfoOther */ + break; + } + info->value->has_props =3D !!mc->cpu_index_to_instance_props; if (info->value->has_props) { CpuInstanceProperties *props; props =3D g_malloc0(sizeof(*props)); *props =3D mc->cpu_index_to_instance_props(ms, cpu->cpu_index); info->value->props =3D props; } =20 /* XXX: waiting for the qapi to support GSList */ if (!cur_item) { head =3D cur_item =3D info; @@ -2188,64 +2335,50 @@ CpuInfoList *qmp_query_cpus(Error **errp) } =20 /* * fast means: we NEVER interrupt vCPU threads to retrieve * information from KVM. */ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(ms); CpuInfoFastList *head =3D NULL, *cur_item =3D NULL; + SysEmuTarget target =3D qapi_enum_parse(&SysEmuTarget_lookup, TARGET_N= AME, + -1, &error_abort); CPUState *cpu; -#if defined(TARGET_S390X) - S390CPU *s390_cpu; - CPUS390XState *env; -#endif =20 CPU_FOREACH(cpu) { CpuInfoFastList *info =3D g_malloc0(sizeof(*info)); info->value =3D g_malloc0(sizeof(*info->value)); =20 info->value->cpu_index =3D cpu->cpu_index; info->value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); info->value->thread_id =3D cpu->thread_id; =20 info->value->has_props =3D !!mc->cpu_index_to_instance_props; if (info->value->has_props) { CpuInstanceProperties *props; props =3D g_malloc0(sizeof(*props)); *props =3D mc->cpu_index_to_instance_props(ms, cpu->cpu_index); info->value->props =3D props; } =20 -#if defined(TARGET_I386) - info->value->arch =3D CPU_INFO_ARCH_X86; -#elif defined(TARGET_PPC) - info->value->arch =3D CPU_INFO_ARCH_PPC; -#elif defined(TARGET_SPARC) - info->value->arch =3D CPU_INFO_ARCH_SPARC; -#elif defined(TARGET_MIPS) - info->value->arch =3D CPU_INFO_ARCH_MIPS; -#elif defined(TARGET_TRICORE) - info->value->arch =3D CPU_INFO_ARCH_TRICORE; -#elif defined(TARGET_S390X) - s390_cpu =3D S390_CPU(cpu); - env =3D &s390_cpu->env; - info->value->arch =3D CPU_INFO_ARCH_S390; - info->value->u.s390.cpu_state =3D env->cpu_state; -#elif defined(TARGET_RISCV) - info->value->arch =3D CPU_INFO_ARCH_RISCV; -#else - info->value->arch =3D CPU_INFO_ARCH_OTHER; -#endif + info->value->arch =3D sysemu_target_to_cpuinfo_arch(target); + info->value->target =3D target; + if (target =3D=3D SYS_EMU_TARGET_S390X) { + cpustate_to_cpuinfo_s390(&info->value->u.s390x, cpu); + } else { + /* do nothing for @CpuInfoOther */ + } + if (!cur_item) { head =3D cur_item =3D info; } else { cur_item->next =3D info; cur_item =3D info; } } =20 return head; } =20 --=20 2.14.1.3.gb7cf6e02401b