yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qapi-fill-in-CpuInfoFast.arch-in-query-cpus-fast.patch

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