|
|
383d26 |
From 17a1d383393e879c43e2aa8f2b264cb001cbca78 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
383d26 |
Date: Tue, 13 Nov 2018 18:16:37 +0100
|
|
|
383d26 |
Subject: [PATCH 18/22] qapi: discriminate CpuInfoFast on SysEmuTarget, not
|
|
|
383d26 |
CpuInfoArch
|
|
|
383d26 |
MIME-Version: 1.0
|
|
|
383d26 |
Content-Type: text/plain; charset=UTF-8
|
|
|
383d26 |
Content-Transfer-Encoding: 8bit
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
383d26 |
Message-id: <20181113181639.4999-5-lersek@redhat.com>
|
|
|
383d26 |
Patchwork-id: 83005
|
|
|
383d26 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 4/6] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
|
|
|
383d26 |
Bugzilla: 1607406
|
|
|
383d26 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
Add a new field @target (of type @SysEmuTarget) to the output of the
|
|
|
383d26 |
@query-cpus-fast command, which provides more information about the
|
|
|
383d26 |
emulation target than the field @arch (of type @CpuInfoArch). Make @target
|
|
|
383d26 |
the new discriminator for the @CpuInfoFast return structure. Keep @arch
|
|
|
383d26 |
for compatibility.
|
|
|
383d26 |
|
|
|
383d26 |
Cc: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
383d26 |
Cc: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Cc: Markus Armbruster <armbru@redhat.com>
|
|
|
383d26 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
383d26 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Message-Id: <20180427192852.15013-5-lersek@redhat.com>
|
|
|
383d26 |
Reviewed-by: Markus Armbruster <armbru@redhat.com>
|
|
|
383d26 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
383d26 |
(cherry picked from commit daa9d2bc6d73618bc230787ddfa821a6a6560fc2)
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
cpus.c | 87 ++++++++++++++++++++++++++++++++++++++++++----------------
|
|
|
383d26 |
qapi/misc.json | 62 +++++++++++++++++++++++++++++++----------
|
|
|
383d26 |
2 files changed, 110 insertions(+), 39 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/cpus.c b/cpus.c
|
|
|
383d26 |
index 4f83f16..be3a4eb 100644
|
|
|
383d26 |
--- a/cpus.c
|
|
|
383d26 |
+++ b/cpus.c
|
|
|
383d26 |
@@ -2187,6 +2187,59 @@ CpuInfoList *qmp_query_cpus(Error **errp)
|
|
|
383d26 |
return head;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
+static CpuInfoArch sysemu_target_to_cpuinfo_arch(SysEmuTarget target)
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ /*
|
|
|
383d26 |
+ * The @SysEmuTarget -> @CpuInfoArch mapping below is based on the
|
|
|
383d26 |
+ * TARGET_ARCH -> TARGET_BASE_ARCH mapping in the "configure" script.
|
|
|
383d26 |
+ */
|
|
|
383d26 |
+ switch (target) {
|
|
|
383d26 |
+ case SYS_EMU_TARGET_I386:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_X86_64:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_X86;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ case SYS_EMU_TARGET_PPC:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_PPCEMB:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_PPC64:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_PPC;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ case SYS_EMU_TARGET_SPARC:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_SPARC64:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_SPARC;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ case SYS_EMU_TARGET_MIPS:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_MIPSEL:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_MIPS64:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_MIPS64EL:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_MIPS;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ case SYS_EMU_TARGET_TRICORE:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_TRICORE;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ case SYS_EMU_TARGET_S390X:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_S390;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ case SYS_EMU_TARGET_RISCV32:
|
|
|
383d26 |
+ case SYS_EMU_TARGET_RISCV64:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_RISCV;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ default:
|
|
|
383d26 |
+ return CPU_INFO_ARCH_OTHER;
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
+static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, const CPUState *cpu)
|
|
|
383d26 |
+{
|
|
|
383d26 |
+#ifdef TARGET_S390X
|
|
|
383d26 |
+ S390CPU *s390_cpu = S390_CPU(cpu);
|
|
|
383d26 |
+ CPUS390XState *env = &s390_cpu->env;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ info->cpu_state = env->cpu_state;
|
|
|
383d26 |
+#else
|
|
|
383d26 |
+ abort();
|
|
|
383d26 |
+#endif
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
/*
|
|
|
383d26 |
* fast means: we NEVER interrupt vCPU threads to retrieve
|
|
|
383d26 |
* information from KVM.
|
|
|
383d26 |
@@ -2196,11 +2249,9 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
|
|
|
383d26 |
MachineState *ms = MACHINE(qdev_get_machine());
|
|
|
383d26 |
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
|
|
383d26 |
CpuInfoFastList *head = NULL, *cur_item = NULL;
|
|
|
383d26 |
+ SysEmuTarget target = qapi_enum_parse(&SysEmuTarget_lookup, TARGET_NAME,
|
|
|
383d26 |
+ -1, &error_abort);
|
|
|
383d26 |
CPUState *cpu;
|
|
|
383d26 |
-#if defined(TARGET_S390X)
|
|
|
383d26 |
- S390CPU *s390_cpu;
|
|
|
383d26 |
- CPUS390XState *env;
|
|
|
383d26 |
-#endif
|
|
|
383d26 |
|
|
|
383d26 |
CPU_FOREACH(cpu) {
|
|
|
383d26 |
CpuInfoFastList *info = g_malloc0(sizeof(*info));
|
|
|
383d26 |
@@ -2218,26 +2269,14 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
|
|
|
383d26 |
info->value->props = props;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
-#if defined(TARGET_I386)
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_X86;
|
|
|
383d26 |
-#elif defined(TARGET_PPC)
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_PPC;
|
|
|
383d26 |
-#elif defined(TARGET_SPARC)
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_SPARC;
|
|
|
383d26 |
-#elif defined(TARGET_MIPS)
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_MIPS;
|
|
|
383d26 |
-#elif defined(TARGET_TRICORE)
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_TRICORE;
|
|
|
383d26 |
-#elif defined(TARGET_S390X)
|
|
|
383d26 |
- s390_cpu = S390_CPU(cpu);
|
|
|
383d26 |
- env = &s390_cpu->env;
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_S390;
|
|
|
383d26 |
- info->value->u.s390.cpu_state = env->cpu_state;
|
|
|
383d26 |
-#elif defined(TARGET_RISCV)
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_RISCV;
|
|
|
383d26 |
-#else
|
|
|
383d26 |
- info->value->arch = CPU_INFO_ARCH_OTHER;
|
|
|
383d26 |
-#endif
|
|
|
383d26 |
+ info->value->arch = sysemu_target_to_cpuinfo_arch(target);
|
|
|
383d26 |
+ info->value->target = target;
|
|
|
383d26 |
+ if (target == SYS_EMU_TARGET_S390X) {
|
|
|
383d26 |
+ cpustate_to_cpuinfo_s390(&info->value->u.s390x, cpu);
|
|
|
383d26 |
+ } else {
|
|
|
383d26 |
+ /* do nothing for @CpuInfoOther */
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+
|
|
|
383d26 |
if (!cur_item) {
|
|
|
383d26 |
head = cur_item = info;
|
|
|
383d26 |
} else {
|
|
|
383d26 |
diff --git a/qapi/misc.json b/qapi/misc.json
|
|
|
383d26 |
index 7cf4fbc..d7fd8bd 100644
|
|
|
383d26 |
--- a/qapi/misc.json
|
|
|
383d26 |
+++ b/qapi/misc.json
|
|
|
383d26 |
@@ -558,25 +558,55 @@
|
|
|
383d26 |
# @props: properties describing to which node/socket/core/thread
|
|
|
383d26 |
# virtual CPU belongs to, provided if supported by board
|
|
|
383d26 |
#
|
|
|
383d26 |
-# @arch: architecture of the cpu, which determines which additional fields
|
|
|
383d26 |
-# will be listed
|
|
|
383d26 |
+# @arch: base architecture of the cpu
|
|
|
383d26 |
+#
|
|
|
383d26 |
+# @target: the QEMU system emulation target, which is more specific than
|
|
|
383d26 |
+# @arch and determines which additional fields will be listed
|
|
|
383d26 |
+# (since 2.13)
|
|
|
383d26 |
#
|
|
|
383d26 |
# Since: 2.12
|
|
|
383d26 |
#
|
|
|
383d26 |
##
|
|
|
383d26 |
-{ 'union': 'CpuInfoFast',
|
|
|
383d26 |
- 'base': {'cpu-index': 'int', 'qom-path': 'str',
|
|
|
383d26 |
- 'thread-id': 'int', '*props': 'CpuInstanceProperties',
|
|
|
383d26 |
- 'arch': 'CpuInfoArch' },
|
|
|
383d26 |
- 'discriminator': 'arch',
|
|
|
383d26 |
- 'data': { 'x86': 'CpuInfoOther',
|
|
|
383d26 |
- 'sparc': 'CpuInfoOther',
|
|
|
383d26 |
- 'ppc': 'CpuInfoOther',
|
|
|
383d26 |
- 'mips': 'CpuInfoOther',
|
|
|
383d26 |
- 'tricore': 'CpuInfoOther',
|
|
|
383d26 |
- 's390': 'CpuInfoS390',
|
|
|
383d26 |
- 'riscv': 'CpuInfoOther',
|
|
|
383d26 |
- 'other': 'CpuInfoOther' } }
|
|
|
383d26 |
+{ 'union' : 'CpuInfoFast',
|
|
|
383d26 |
+ 'base' : { 'cpu-index' : 'int',
|
|
|
383d26 |
+ 'qom-path' : 'str',
|
|
|
383d26 |
+ 'thread-id' : 'int',
|
|
|
383d26 |
+ '*props' : 'CpuInstanceProperties',
|
|
|
383d26 |
+ 'arch' : 'CpuInfoArch',
|
|
|
383d26 |
+ 'target' : 'SysEmuTarget' },
|
|
|
383d26 |
+ 'discriminator' : 'target',
|
|
|
383d26 |
+ 'data' : { 'aarch64' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'alpha' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'arm' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'cris' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'hppa' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'i386' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'lm32' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'm68k' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'microblaze' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'microblazeel' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'mips' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'mips64' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'mips64el' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'mipsel' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'moxie' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'nios2' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'or1k' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'ppc' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'ppc64' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'ppcemb' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'riscv32' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'riscv64' : 'CpuInfoOther',
|
|
|
383d26 |
+ 's390x' : 'CpuInfoS390',
|
|
|
383d26 |
+ 'sh4' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'sh4eb' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'sparc' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'sparc64' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'tricore' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'unicore32' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'x86_64' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'xtensa' : 'CpuInfoOther',
|
|
|
383d26 |
+ 'xtensaeb' : 'CpuInfoOther' } }
|
|
|
383d26 |
|
|
|
383d26 |
##
|
|
|
383d26 |
# @query-cpus-fast:
|
|
|
383d26 |
@@ -602,6 +632,7 @@
|
|
|
383d26 |
# },
|
|
|
383d26 |
# "qom-path": "/machine/unattached/device[0]",
|
|
|
383d26 |
# "arch":"x86",
|
|
|
383d26 |
+# "target":"x86_64",
|
|
|
383d26 |
# "cpu-index": 0
|
|
|
383d26 |
# },
|
|
|
383d26 |
# {
|
|
|
383d26 |
@@ -613,6 +644,7 @@
|
|
|
383d26 |
# },
|
|
|
383d26 |
# "qom-path": "/machine/unattached/device[2]",
|
|
|
383d26 |
# "arch":"x86",
|
|
|
383d26 |
+# "target":"x86_64",
|
|
|
383d26 |
# "cpu-index": 1
|
|
|
383d26 |
# }
|
|
|
383d26 |
# ]
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|