Pablo Greco e6a3ae
From 9000286ea20abb4e03c76ab8f873a6e9eb708377 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Date: Thu, 14 Nov 2019 08:20:41 +0000
Pablo Greco e6a3ae
Subject: [PATCH 1/8] qapi: fill in CpuInfoFast.arch in query-cpus-fast
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Message-id: <20191114082041.20840-2-mlevitsk@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 92245
Pablo Greco e6a3ae
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 1/1] qapi: fill in CpuInfoFast.arch in query-cpus-fast
Pablo Greco e6a3ae
Bugzilla: 1730969
Pablo Greco e6a3ae
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
* Commit ca230ff33f89 added the @arch field to @CpuInfoFast, but it failed
Pablo Greco e6a3ae
  to set the new field in qmp_query_cpus_fast(), when TARGET_S390X was not
Pablo Greco e6a3ae
  defined. The updated @query-cpus-fast example in "qapi-schema.json"
Pablo Greco e6a3ae
  showed "arch":"x86" only because qmp_query_cpus_fast() calls g_malloc0()
Pablo Greco e6a3ae
  to allocate @CpuInfoFast, and the CPU_INFO_ARCH_X86 enum constant is
Pablo Greco e6a3ae
  generated with value 0.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
  All @arch values other than @s390 implied the @CpuInfoOther sub-struct
Pablo Greco e6a3ae
  for @CpuInfoFast -- at the time of writing the patch --, thus no fields
Pablo Greco e6a3ae
  other than @arch needed to be set when TARGET_S390X was not defined. Set
Pablo Greco e6a3ae
  @arch now, by copying the corresponding assignments from
Pablo Greco e6a3ae
  qmp_query_cpus().
Pablo Greco e6a3ae
Pablo Greco e6a3ae
* Commit 25fa194b7b11 added the @riscv enum constant to @CpuInfoArch (used
Pablo Greco e6a3ae
  in both @CpuInfo and @CpuInfoFast -- the return types of the @query-cpus
Pablo Greco e6a3ae
  and @query-cpus-fast commands, respectively), and assigned, in both
Pablo Greco e6a3ae
  return structures, the @CpuInfoRISCV sub-structure to the new enum
Pablo Greco e6a3ae
  value.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
  However, qmp_query_cpus_fast() would not populate either the @arch field
Pablo Greco e6a3ae
  or the @CpuInfoRISCV sub-structure, when TARGET_RISCV was defined; only
Pablo Greco e6a3ae
  qmp_query_cpus() would.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
  Assign @CpuInfoOther to the @riscv enum constant in @CpuInfoFast, and
Pablo Greco e6a3ae
  populate only the @arch field in qmp_query_cpus_fast(). Getting CPU
Pablo Greco e6a3ae
  state without interrupting KVM is an exceptional thing that only S390X
Pablo Greco e6a3ae
  does currently. Quoting Cornelia Huck <cohuck@redhat.com>, "s390x is
Pablo Greco e6a3ae
  exceptional in that it has state in QEMU that is actually interesting
Pablo Greco e6a3ae
  for upper layers and can be retrieved without performance penalty". See
Pablo Greco e6a3ae
  also
Pablo Greco e6a3ae
  <https://www.redhat.com/archives/libvir-list/2018-February/msg00121.html>.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Cc: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Cc: Eric Blake <eblake@redhat.com>
Pablo Greco e6a3ae
Cc: Markus Armbruster <armbru@redhat.com>
Pablo Greco e6a3ae
Cc: Viktor VM Mihajlovski <mihajlov@linux.vnet.ibm.com>
Pablo Greco e6a3ae
Cc: qemu-stable@nongnu.org
Pablo Greco e6a3ae
Fixes: ca230ff33f89bf7102cbfbc2328716da6750aaed
Pablo Greco e6a3ae
Fixes: 25fa194b7b11901561532e435beb83d046899f7a
Pablo Greco e6a3ae
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Eric Blake <eblake@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Pablo Greco e6a3ae
Message-Id: <20180427192852.15013-2-lersek@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 96054f56396eaa0b9b5c681fc3e42a0004b17ade)
Pablo Greco e6a3ae
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 cpus.c         | 16 +++++++++++++++-
Pablo Greco e6a3ae
 qapi/misc.json |  2 +-
Pablo Greco e6a3ae
 2 files changed, 16 insertions(+), 2 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/cpus.c b/cpus.c
Pablo Greco e6a3ae
index 6100089..cea42f9 100644
Pablo Greco e6a3ae
--- a/cpus.c
Pablo Greco e6a3ae
+++ b/cpus.c
Pablo Greco e6a3ae
@@ -2218,11 +2218,25 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
Pablo Greco e6a3ae
             info->value->props = props;
Pablo Greco e6a3ae
         }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-#if defined(TARGET_S390X)
Pablo Greco e6a3ae
+#if defined(TARGET_I386)
Pablo Greco e6a3ae
+        info->value->arch = CPU_INFO_ARCH_X86;
Pablo Greco e6a3ae
+#elif defined(TARGET_PPC)
Pablo Greco e6a3ae
+        info->value->arch = CPU_INFO_ARCH_PPC;
Pablo Greco e6a3ae
+#elif defined(TARGET_SPARC)
Pablo Greco e6a3ae
+        info->value->arch = CPU_INFO_ARCH_SPARC;
Pablo Greco e6a3ae
+#elif defined(TARGET_MIPS)
Pablo Greco e6a3ae
+        info->value->arch = CPU_INFO_ARCH_MIPS;
Pablo Greco e6a3ae
+#elif defined(TARGET_TRICORE)
Pablo Greco e6a3ae
+        info->value->arch = CPU_INFO_ARCH_TRICORE;
Pablo Greco e6a3ae
+#elif defined(TARGET_S390X)
Pablo Greco e6a3ae
         s390_cpu = S390_CPU(cpu);
Pablo Greco e6a3ae
         env = &s390_cpu->env;
Pablo Greco e6a3ae
         info->value->arch = CPU_INFO_ARCH_S390;
Pablo Greco e6a3ae
         info->value->u.s390.cpu_state = env->cpu_state;
Pablo Greco e6a3ae
+#elif defined(TARGET_RISCV)
Pablo Greco e6a3ae
+        info->value->arch = CPU_INFO_ARCH_RISCV;
Pablo Greco e6a3ae
+#else
Pablo Greco e6a3ae
+        info->value->arch = CPU_INFO_ARCH_OTHER;
Pablo Greco e6a3ae
 #endif
Pablo Greco e6a3ae
         if (!cur_item) {
Pablo Greco e6a3ae
             head = cur_item = info;
Pablo Greco e6a3ae
diff --git a/qapi/misc.json b/qapi/misc.json
Pablo Greco e6a3ae
index 5636f4a..104d013 100644
Pablo Greco e6a3ae
--- a/qapi/misc.json
Pablo Greco e6a3ae
+++ b/qapi/misc.json
Pablo Greco e6a3ae
@@ -573,7 +573,7 @@
Pablo Greco e6a3ae
             'mips': 'CpuInfoOther',
Pablo Greco e6a3ae
             'tricore': 'CpuInfoOther',
Pablo Greco e6a3ae
             's390': 'CpuInfoS390',
Pablo Greco e6a3ae
-            'riscv': 'CpuInfoRISCV',
Pablo Greco e6a3ae
+            'riscv': 'CpuInfoOther',
Pablo Greco e6a3ae
             'other': 'CpuInfoOther' } }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 ##
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae