qapi: introduce the SysEmuTarget enumeration
v2 cover qapi: introduce the SysEmuTarget enumeration
This is version 2 of the set posted earlier at
http://mid.mail-archive.com/[email protected]
This version seeks to address the v1 feedback. Changes are noted per patch.
The following firmware schema / interop docs patch remains dependent on this series, without any changes to the former:
[Qemu-devel] [qemu RFC v3 3/3] qapi: add "firmware.json"
http://mid.mail-archive.com/[email protected]
Thanks
Laszlo
Laszlo Ersek (4):
qapi: fill in CpuInfoFast.arch in query-cpus-fast
qapi: add SysEmuTarget to "common.json"
qapi: change the type of TargetInfo.arch from string to enum
SysEmuTarget
qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
qapi/common.json | 27 +++++++++++++++++++ qapi/misc.json | 69 +++++++++++++++++++++++++++++++++++------------ arch_init.c | 4 ++- cpus.c | 73 +++++++++++++++++++++++++++++++++++++++++++------- scripts/qapi/common.py | 2 +- 5 files changed, 146 insertions(+), 29 deletions(-)
Signature · 1 line
2.14.1.3.gb7cf6e02401b
PATCH v2 1/4 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 <[email protected]>, "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>.
---
Notes:
PATCHv2:
- squash v1 patches 1/6 and 2/6 [Eric, Markus, Cornelia]
- fix "added added" typo in the commit message [Eric]
- update commit message wrt. S390X particulars [Cornelia, Markus, Viktor]
- pick up Eric's R-b (synthesized from his R-b's for v1 1/6 & 2/6)
- don't pick up Cornelia's R-b (only given for v1 1/6)
- update the CC list
PATCHv1:
- new patch
qapi/misc.json | 2 +- cpus.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
qapi/misc.json +1 -1
@@ -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' } } ## # @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 #
cpus.c +15 -1
@@ -2210,27 +2210,41 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) info->value->qom_path =object_get_canonical_path (OBJECT (cpu)); info->value->thread_id = cpu->thread_id; info->value->has_props = !!mc->cpu_index_to_instance_props;if (info->value->has_props) {CpuInstanceProperties *props; props =g_malloc0 (sizeof (*props)); *props = mc->cpu_index_to_instance_props (ms, cpu->cpu_index); info->value->props = props; } -#if defined(TARGET_S390X ) +#if defined(TARGET_I386 ) + info->value->arch =CPU_INFO_ARCH_X86 ; +#elif defined(TARGET_PPC ) + info->value->arch =CPU_INFO_ARCH_PPC ; +#elif defined(TARGET_SPARC ) + info->value->arch =CPU_INFO_ARCH_SPARC ; +#elif defined(TARGET_MIPS ) + info->value->arch =CPU_INFO_ARCH_MIPS ; +#elif defined(TARGET_TRICORE ) + info->value->arch =CPU_INFO_ARCH_TRICORE ; +#elif defined(TARGET_S390X ) s390_cpu =S390_CPU (cpu); env = &s390_cpu->env; info->value->arch =CPU_INFO_ARCH_S390 ; info->value->u.s390.cpu_state = env->cpu_state; +#elif defined(TARGET_RISCV ) + info->value->arch =CPU_INFO_ARCH_RISCV ; +#else + info->value->arch =CPU_INFO_ARCH_OTHER ;#endif if (!cur_item) { head = cur_item = info; }else { cur_item->next = info; cur_item = info; } }return head; }
Signature · 1 line
2.14.1.3.gb7cf6e02401b
PATCH v2 2/4 qapi: add SysEmuTarget to "common.json"
In reply to Laszlo ErsekWe'll soon need an enumeration type that lists all the softmmu targets that QEMU (the project) supports. Introduce @SysEmuTarget to "common.json".
The enum constant @x86_64 is not spelled @x86-64 because the corresponding emulator is called qemu-system-x86_64.
Like other enum types, @SysEmuTarget too can be used for discriminator fields in unions. For the @i386 constant, a C-language union member called "i386" would be generated. On mingw build hosts, "i386" is a macro however. Add "i386" to "polluted_words" at once.
---
Notes:
PATCHv2:
- document the use of the underscore in @x86_64 in both the commit message and in the schema [Eric, Dan]
- extend "polluted_words" with "i386" [Eric]
- drop previous R-b's
- update the CC list
PATCHv1:
- pick up R-b's from Markus and Kashyap, no changes
RFCv3:
- The patch is new in this version. [Dan, Markus]
- 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.
- 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 | 27 +++++++++++++++++++++++++++ scripts/qapi/common.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-)
qapi/common.json +27 -0
@@ -118,11 +118,38 @@ # # @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. +# +# Notes: @x86_64 doesn't match the QAPI convention of preferring hyphen +# ("-") over underscore ("_"). This is intentional; the +# @SysEmuTarget constants are supposed to produce QEMU executable +# names when stringified and appended to the "qemu-system-" +# prefix. Put differently, the replacement text of the +# TARGET_NAME preprocessor macro must be possible to look up in +# the list of (stringified) enum constants. +# +# 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' ] }
scripts/qapi/common.py +1 -1
@@ -1814,23 +1814,23 @@ def c_name(name, protect=True): # C++ ISO/IEC 14882:2003 2.11 cpp_words = set(['bool', 'catch', 'class', 'const_cast', 'delete', 'dynamic_cast', 'explicit', 'false', 'friend', 'mutable', 'namespace', 'new', 'operator', 'private', 'protected', 'public', 'reinterpret_cast', 'static_cast', 'template', 'this', 'throw', 'true', 'try', 'typeid', 'typename', 'using', 'virtual', 'wchar_t', # alternative representations 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq']) # namespace pollution: - polluted_words = set(['unix', 'errno', 'mips', 'sparc']) + polluted_words = set(['unix', 'errno', 'mips', 'sparc', 'i386']) name = name.translate(c_name_trans) if protect and (name in c89_words | c99_words | c11_words | gcc_words | cpp_words | polluted_words): return 'q_' + name return name eatspace = '\033EATSPACE.' pointer_suffix = ' *' + eatspace def genindent(count):
Signature · 1 line
2.14.1.3.gb7cf6e02401b
PATCH v2 3/4 qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget
In reply to Laszlo ErsekNow that we have @SysEmuTarget, it makes sense to restrict @TargetInfo.@arch to valid sysemu targets at the schema level.
---
Notes:
PATCHv2:
- drop naive code comment in qmp_query_target() [Markus]
- pick up Markus's R-b
- update CC list
PATCHv1:
- qmp_query_target(): pass (-1) as fallback value [Markus]
- qmp_query_target(): catch lookup error with error_abort [Markus]
RFCv3:
- The patch is new in this version. [Markus]
qapi/misc.json | 6 ++++-- arch_init.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)
qapi/misc.json +4 -2
@@ -1,18 +1,20 @@ # -*- Mode: Python -*- # ## # = Miscellanea ## +{ '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'] } ## # @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' } } ## # @query-target: # # Return information about the target for this QEMU # # Returns: TargetInfo # # Since: 1.2.0 ## { 'command': 'query-target', 'returns': 'TargetInfo' }
arch_init.c +3 -1
@@ -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" #ifdef TARGET_SPARC int graphic_width =1024 ;int graphic_height =768 ;int graphic_depth =8 ;#else int graphic_width =800 ;
@@ -104,15 +105,16 @@ int xen_available(void)return 1 ;#else return 0 ;#endif }TargetInfo *qmp_query_target (Error **errp) {TargetInfo *info =g_malloc0 (sizeof (*info)); - info->arch =g_strdup (TARGET_NAME ); + info->arch =qapi_enum_parse (&SysEmuTarget_lookup,TARGET_NAME ,-1 , + &error_abort);return info; }
Signature · 1 line
2.14.1.3.gb7cf6e02401b
PATCH v2 4/4 qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
In reply to Laszlo ErsekAdd a new field @target (of type @SysEmuTarget) to the output of the @query-cpus-fast command, which provides more information about the emulation target than the field @arch (of type @CpuInfoArch). Make @target the new discriminator for the @CpuInfoFast return structure. Keep @arch for compatibility.
---
Notes:
PATCHv2:
- drop patch v1 5/6 with the CpuInfoCommon refactoring / extraction, as @CpuInfo / @query-cpus are deprecated [Eric, Markus]
- for the same reason, add @target to @CpuInfoFast / @query-cpus-fast only [Eric, Markus]
- Can't set @arch compatibly from a QAPI enum lookup of the proposed TARGET_BASE_ARCH macro, because TARGET_BASE_ARCH=s390x is not identical to the @s390 @CpuInfoArch constant -- see more at
<http://mid.mail-archive.com/[email protected]>.
Keep sysemu_target_to_cpuinfo_arch() instead. [Markus, Eric]
- update CC list
PATCHv1:
- new patch
qapi/misc.json | 63 ++++++++++++++++++++++++++++++++---------- cpus.c | 87 ++++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 111 insertions(+), 39 deletions(-)
qapi/misc.json +48 -15
@@ -550,41 +550,72 @@ # Information about a virtual CPU # # @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 +# @arch: base architecture of the cpu +# +# @target: the QEMU system emulation target, which is more specific than +# @arch and determines which additional fields will be listed +# (since 2.13) +# # # Since: 2.12 # ## -{ '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': 'CpuInfoOther', - 'other': 'CpuInfoOther' } } +{ 'union' : 'CpuInfoFast', + 'base' : { 'cpu-index' : 'int', + 'qom-path' : 'str', + 'thread-id' : 'int', + '*props' : 'CpuInstanceProperties', + 'arch' : 'CpuInfoArch', + 'target' : 'SysEmuTarget' }, + 'discriminator' : 'target', + 'data' : { 'aarch64' : 'CpuInfoOther', + 'alpha' : 'CpuInfoOther', + 'arm' : 'CpuInfoOther', + 'cris' : 'CpuInfoOther', + 'hppa' : 'CpuInfoOther', + 'i386' : 'CpuInfoOther', + 'lm32' : 'CpuInfoOther', + 'm68k' : 'CpuInfoOther', + 'microblaze' : 'CpuInfoOther', + 'microblazeel' : 'CpuInfoOther', + 'mips' : 'CpuInfoOther', + 'mips64' : 'CpuInfoOther', + 'mips64el' : 'CpuInfoOther', + 'mipsel' : 'CpuInfoOther', + 'moxie' : 'CpuInfoOther', + 'nios2' : 'CpuInfoOther', + 'or1k' : 'CpuInfoOther', + 'ppc' : 'CpuInfoOther', + 'ppc64' : 'CpuInfoOther', + 'ppcemb' : 'CpuInfoOther', + 'riscv32' : 'CpuInfoOther', + 'riscv64' : 'CpuInfoOther', + 's390x' : 'CpuInfoS390', + 'sh4' : 'CpuInfoOther', + 'sh4eb' : 'CpuInfoOther', + 'sparc' : 'CpuInfoOther', + 'sparc64' : 'CpuInfoOther', + 'tricore' : 'CpuInfoOther', + 'unicore32' : 'CpuInfoOther', + 'x86_64' : 'CpuInfoOther', + 'xtensa' : 'CpuInfoOther', + 'xtensaeb' : 'CpuInfoOther' } } ## # @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
@@ -594,33 +625,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' ] } ## # @IOThreadInfo: # # Information about an iothread
cpus.c +63 -24
136 lines not on this page · raw message
Signature · 1 line
2.14.1.3.gb7cf6e02401b
Re: [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json"
In reply to Laszlo ErsekQuoted 27 lines · Laszlo Ersek
We'll soon need an enumeration type that lists all the softmmu targets that QEMU (the project) supports. Introduce @SysEmuTarget to "common.json".
The enum constant @x86_64 is not spelled @x86-64 because the corresponding emulator is called qemu-system-x86_64.
Like other enum types, @SysEmuTarget too can be used for discriminator fields in unions. For the @i386 constant, a C-language union member called "i386" would be generated. On mingw build hosts, "i386" is a macro however. Add "i386" to "
polluted_words" at once.Cc "Daniel P. Berrange" <[email protected]>Cc Eric Blake <[email protected]>Cc Markus Armbruster <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>---
+++
b/qapi/common.jsonqapi/common.json +7
-0+ +## +# @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
qapi/common.json line 145
Quoted 10 lines
qapi/common.json +10
-0+# individual target constants are not documented here, for the time +# being. +# +# Notes: @x86_64 doesn't match the QAPI convention of preferring hyphen +# ("-") over underscore ("_"). This is intentional; the +# @SysEmuTarget constants are supposed to produce QEMU executable +# names when stringified and appended to the "qemu-system-" +# prefix. Put differently, the replacement text of the +# TARGET_NAME preprocessor macro must be possible to look up in +# the list of (stringified) enum constants.
I think the Notes: goes a little bit deep into implementation details, considering that it is part of the user-facing documentation. Maybe it is sufficient to shorten to just:
Notes: The resulting QMP strings can be appended to the "qemu-system-" prefix to produce the corresponding QEMU executable name.
and maybe add:
This is true even for "qemu-system-x86_64".
and leave the rest for the commit message.
Everything else looks good, so depending on what happens to the Notes section after other reviewers have chimed in, you can probably add:
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v2 3/4] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget
In reply to Laszlo ErsekQuoted 9 lines · Laszlo Ersek
Now that we have @SysEmuTarget, it makes sense to restrict @TargetInfo.@arch to valid sysemu targets at the schema level.
Cc "Daniel P. Berrange" <[email protected]>Cc Eric Blake <[email protected]>Cc Markus Armbruster <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
In reply to Laszlo ErsekQuoted 13 lines · Laszlo Ersek
Add a new field @target (of type @SysEmuTarget) to the output of the @query-cpus-fast command, which provides more information about the emulation target than the field @arch (of type @CpuInfoArch). Make @target the new discriminator for the @CpuInfoFast return structure. Keep @arch for compatibility.
Cc "Daniel P. Berrange" <[email protected]>Cc Eric Blake <[email protected]>Cc Markus Armbruster <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>---
cpus.c CpuInfoList *qmp_query_cpus(Error **errp) · line 2199
Quoted 10 lines
cpus.c +10
-0+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 ;
Thankfully, the addition of new targets is infrequent, so hopefully not too hard to keep this mapping up-to-date.
I also like that this approach is introspectible via 'query-qmp-schema'
- if 'query-cpus-fast' has the "target" member, then you know that it is fixed (you can ignore "arch" in that case, even though you know it works); if it lacks "target", you know that "arch":"s390x" is the only real string to look for and that all other systems report "x86" whether or not that was accurate.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
Quoted 4 lines · Eric Blake
I also like that this approach is introspectible via 'query-qmp-schema'
- if 'query-cpus-fast' has the "target" member, then you know that it is fixed (you can ignore "arch" in that case, even though you know it works); if it lacks "target", you know that "arch":"s390x" is the only
Correcting myself: "arch":"s390" is the magic string for older qemu; and your mapping function from target to arch keeps it that way, so that older clients not aware of "target":"s390x" still get the right behavior.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast
In reply to Laszlo ErsekQuoted 59 lines · On Thu, 26 Apr 2018 20:34:01 +0200 Laszlo Ersek <[email protected]> wrote:
* Commit
ca230ff33f89added the @arch field to @CpuInfoFast, but it failed to set the new field inqmp_query_cpus_fast(), whenTARGET_S390Xwas not defined. The updated @query-cpus-fast example in "qapi-schema.json" showed "arch":"x86" only becauseqmp_query_cpus_fast()callsg_malloc0()to allocate @CpuInfoFast, and theCPU_INFO_ARCH_X86enum 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_S390Xwas not defined. Set @arch now, by copying the corresponding assignments fromqmp_query_cpus().* Commit
25fa194b7b11added 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, whenTARGET_RISCVwas defined; onlyqmp_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 <[email protected]>, "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 <[email protected]>Cc Eric Blake <[email protected]>Cc Markus Armbruster <[email protected]>Cc Viktor VM Mihajlovski <[email protected]>Fixes ca230ff33f89bf7102cbfbc2328716da6750aaedFixes 25fa194b7b11901561532e435beb83d046899f7aSigned-off-by Laszlo Ersek <[email protected]>Reviewed-by Eric Blake <[email protected]>---
Notes:
PATCHv2:- squash v1 patches 1/6 and 2/6 [Eric, Markus, Cornelia]
- fix "added added" typo in the commit message [Eric]
- update commit message wrt. S390X particulars [Cornelia, Markus, Viktor]
- pick up Eric's R-b (synthesized from his R-b's for v1 1/6 & 2/6)
- don't pick up Cornelia's R-b (only given for v1 1/6)
- update the CC list
Quoted 7 lines
PATCHv1:
- new patch
qapi/misc.json | 2 +- cpus.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
Re: [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast
In reply to Laszlo ErsekQuoted 32 lines · Laszlo Ersek
* Commit
ca230ff33f89added the @arch field to @CpuInfoFast, but it failed to set the new field inqmp_query_cpus_fast(), whenTARGET_S390Xwas not defined. The updated @query-cpus-fast example in "qapi-schema.json" showed "arch":"x86" only becauseqmp_query_cpus_fast()callsg_malloc0()to allocate @CpuInfoFast, and theCPU_INFO_ARCH_X86enum 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_S390Xwas not defined. Set @arch now, by copying the corresponding assignments fromqmp_query_cpus().* Commit
25fa194b7b11added 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, whenTARGET_RISCVwas defined; onlyqmp_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 <[email protected]>, "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>.
Quoted 9 lines
Cc Cornelia Huck <[email protected]>Cc Eric Blake <[email protected]>Cc Markus Armbruster <[email protected]>Cc Viktor VM Mihajlovski <[email protected]>Fixes ca230ff33f89bf7102cbfbc2328716da6750aaedFixes 25fa194b7b11901561532e435beb83d046899f7aSigned-off-by Laszlo Ersek <[email protected]>Reviewed-by Eric Blake <[email protected]>
Re: [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json"
In reply to Laszlo ErsekQuoted 12 lines · Laszlo Ersek
We'll soon need an enumeration type that lists all the softmmu targets that QEMU (the project) supports. Introduce @SysEmuTarget to "common.json".
The enum constant @x86_64 is not spelled @x86-64 because the corresponding emulator is called qemu-system-x86_64.
Like other enum types, @SysEmuTarget too can be used for discriminator fields in unions. For the @i386 constant, a C-language union member called "i386" would be generated. On mingw build hosts, "i386" is a macro however. Add "i386" to "
polluted_words" at once.
Quoted 4 lines
Cc "Daniel P. Berrange" <[email protected]>Cc Eric Blake <[email protected]>Cc Markus Armbruster <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>
Re: [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
In reply to Laszlo ErsekQuoted 46 lines · Laszlo Ersek
Add a new field @target (of type @SysEmuTarget) to the output of the @query-cpus-fast command, which provides more information about the emulation target than the field @arch (of type @CpuInfoArch). Make @target the new discriminator for the @CpuInfoFast return structure. Keep @arch for compatibility.
Cc "Daniel P. Berrange" <[email protected]>Cc Eric Blake <[email protected]>Cc Markus Armbruster <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>---
Notes:
PATCHv2:- drop patch v1 5/6 with the CpuInfoCommon refactoring / extraction, as @CpuInfo / @query-cpus are deprecated [Eric, Markus]
- for the same reason, add @target to @CpuInfoFast / @query-cpus-fast only [Eric, Markus]
- Can't set @arch compatibly from a QAPI enum lookup of the proposed
TARGET_BASE_ARCHmacro, because TARGET_BASE_ARCH=s390x is not identical to the @s390 @CpuInfoArch constant -- see more at
<http://mid.mail-archive.com/[email protected]>.
Keepsysemu_target_to_cpuinfo_arch()instead. [Markus, Eric]- update CC list
PATCHv1:
- new patch
qapi/misc.json | 63 ++++++++++++++++++++++++++++++++---------- cpus.c | 87 ++++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 111 insertions(+), 39 deletions(-)qapi/misc.json +0
-0@@ -550,41 +550,72 @@ # Information about a virtual CPU # # @cpu-index: index of the virtual CPU #
qapi/misc.json line 561
Quoted 10 lines
qapi/misc.json +1
-2# @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 +# @arch: base architecture of the cpu
Let's deprecate this misbegotten enumeration, as I proposed in
Message-ID: <[email protected]>. Could be done as a follow-up patch.
qapi/misc.json line 566
Quoted 5 lines
qapi/misc.json +5
-0+# +# @target: the QEMU system emulation target, which is more specific than +# @arch and determines which additional fields will be listed +# (since 2.13) +#
May want to drop "is more specific than @arch and" then.
qapi/misc.json line 570
Quoted 4 lines
qapi/misc.json +0
-0# # Since: 2.12 # ##
[...]
In case we decide not to deprecate @arch right away: