qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qapi: fill in CpuInfoFast.arch in query-cpus-fast

* 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 <cohuck@redhat.com>, "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
<https://www.redhat.com/archives/libvir-list/2018-February/msg00121.html>.

Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Viktor VM Mihajlovski <mihajlov@linux.vnet.ibm.com>
Cc: qemu-stable@nongnu.org
Fixes: ca230ff33f89bf7102cbfbc2328716da6750aaed
Fixes: 25fa194b7b11901561532e435beb83d046899f7a
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180427192852.15013-2-lersek@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
(cherry picked from commit 96054f56396eaa0b9b5c681fc3e42a0004b17ade)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

authored by

Laszlo Ersek and committed by
Michael Roth
3882183f 3b52d474

+16 -2
+15 -1
cpus.c
··· 2218 2218 info->value->props = props; 2219 2219 } 2220 2220 2221 - #if defined(TARGET_S390X) 2221 + #if defined(TARGET_I386) 2222 + info->value->arch = CPU_INFO_ARCH_X86; 2223 + #elif defined(TARGET_PPC) 2224 + info->value->arch = CPU_INFO_ARCH_PPC; 2225 + #elif defined(TARGET_SPARC) 2226 + info->value->arch = CPU_INFO_ARCH_SPARC; 2227 + #elif defined(TARGET_MIPS) 2228 + info->value->arch = CPU_INFO_ARCH_MIPS; 2229 + #elif defined(TARGET_TRICORE) 2230 + info->value->arch = CPU_INFO_ARCH_TRICORE; 2231 + #elif defined(TARGET_S390X) 2222 2232 s390_cpu = S390_CPU(cpu); 2223 2233 env = &s390_cpu->env; 2224 2234 info->value->arch = CPU_INFO_ARCH_S390; 2225 2235 info->value->u.s390.cpu_state = env->cpu_state; 2236 + #elif defined(TARGET_RISCV) 2237 + info->value->arch = CPU_INFO_ARCH_RISCV; 2238 + #else 2239 + info->value->arch = CPU_INFO_ARCH_OTHER; 2226 2240 #endif 2227 2241 if (!cur_item) { 2228 2242 head = cur_item = info;
+1 -1
qapi/misc.json
··· 573 573 'mips': 'CpuInfoOther', 574 574 'tricore': 'CpuInfoOther', 575 575 's390': 'CpuInfoS390', 576 - 'riscv': 'CpuInfoRISCV', 576 + 'riscv': 'CpuInfoOther', 577 577 'other': 'CpuInfoOther' } } 578 578 579 579 ##