All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/4] qapi: introduce the SysEmuTarget enumeration
@ 2018-04-26 18:34 Laszlo Ersek
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast Laszlo Ersek
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Laszlo Ersek @ 2018-04-26 18:34 UTC (permalink / raw)
  To: qemu devel list
  Cc: Daniel P. Berrange, Cornelia Huck, Eric Blake, Markus Armbruster,
	Viktor VM Mihajlovski, qemu-stable

This is version 2 of the set posted earlier at

  http://mid.mail-archive.com/20180424214550.32549-1-lersek@redhat.com

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/20180420231246.23130-4-lersek@redhat.com

Cc: "Daniel P. Berrange" <berrange@redhat.com>
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

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(-)

-- 
2.14.1.3.gb7cf6e02401b

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast
  2018-04-26 18:34 [Qemu-devel] [PATCH v2 0/4] qapi: introduce the SysEmuTarget enumeration Laszlo Ersek
@ 2018-04-26 18:34 ` Laszlo Ersek
  2018-04-27  7:05   ` Cornelia Huck
  2018-04-27  7:18   ` Markus Armbruster
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json" Laszlo Ersek
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 13+ messages in thread
From: Laszlo Ersek @ 2018-04-26 18:34 UTC (permalink / raw)
  To: qemu devel list
  Cc: Cornelia Huck, Eric Blake, Markus Armbruster,
	Viktor VM Mihajlovski, qemu-stable

* 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>
---

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(-)

diff --git a/qapi/misc.json b/qapi/misc.json
index 5636f4a14997..104d013adba6 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -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
 #
diff --git a/cpus.c b/cpus.c
index 38eba8bff334..60563a6d54ec 100644
--- a/cpus.c
+++ b/cpus.c
@@ -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;
 }
-- 
2.14.1.3.gb7cf6e02401b

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json"
  2018-04-26 18:34 [Qemu-devel] [PATCH v2 0/4] qapi: introduce the SysEmuTarget enumeration Laszlo Ersek
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast Laszlo Ersek
@ 2018-04-26 18:34 ` Laszlo Ersek
  2018-04-26 19:27   ` Eric Blake
  2018-04-27  7:18   ` Markus Armbruster
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 3/4] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget Laszlo Ersek
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch Laszlo Ersek
  3 siblings, 2 replies; 13+ messages in thread
From: Laszlo Ersek @ 2018-04-26 18:34 UTC (permalink / raw)
  To: qemu devel list; +Cc: Daniel P. Berrange, Eric Blake, Markus Armbruster

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" <berrange@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

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(-)

diff --git a/qapi/common.json b/qapi/common.json
index d9b14dd429f3..7daa9b6798ac 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -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' ] }
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 3e14bc41f2c0..a032cec37509 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -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):
-- 
2.14.1.3.gb7cf6e02401b

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v2 3/4] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget
  2018-04-26 18:34 [Qemu-devel] [PATCH v2 0/4] qapi: introduce the SysEmuTarget enumeration Laszlo Ersek
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast Laszlo Ersek
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json" Laszlo Ersek
@ 2018-04-26 18:34 ` Laszlo Ersek
  2018-04-26 19:31   ` Eric Blake
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch Laszlo Ersek
  3 siblings, 1 reply; 13+ messages in thread
From: Laszlo Ersek @ 2018-04-26 18:34 UTC (permalink / raw)
  To: qemu devel list; +Cc: Daniel P. Berrange, Eric Blake, Markus Armbruster

Now that we have @SysEmuTarget, it makes sense to restrict
@TargetInfo.@arch to valid sysemu targets at the schema level.

Cc: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---

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(-)

diff --git a/qapi/misc.json b/qapi/misc.json
index 104d013adba6..460866cf542f 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -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' }
diff --git a/arch_init.c b/arch_init.c
index 6ee07478bd11..9597218ceda3 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -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;
 }
-- 
2.14.1.3.gb7cf6e02401b

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
  2018-04-26 18:34 [Qemu-devel] [PATCH v2 0/4] qapi: introduce the SysEmuTarget enumeration Laszlo Ersek
                   ` (2 preceding siblings ...)
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 3/4] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget Laszlo Ersek
@ 2018-04-26 18:34 ` Laszlo Ersek
  2018-04-26 19:41   ` Eric Blake
  2018-04-27  7:29   ` Markus Armbruster
  3 siblings, 2 replies; 13+ messages in thread
From: Laszlo Ersek @ 2018-04-26 18:34 UTC (permalink / raw)
  To: qemu devel list; +Cc: Daniel P. Berrange, Eric Blake, Markus Armbruster

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" <berrange@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

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/f0c9c7ca-3dcf-4f74-9812-5dea5b6376cd@redhat.com>.
      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(-)

diff --git a/qapi/misc.json b/qapi/misc.json
index 460866cf542f..74e5c2e3b8f7 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -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
diff --git a/cpus.c b/cpus.c
index 60563a6d54ec..5bcd3ecf3848 100644
--- a/cpus.c
+++ b/cpus.c
@@ -2179,73 +2179,112 @@ CpuInfoList *qmp_query_cpus(Error **errp)
         if (!cur_item) {
             head = cur_item = info;
         } else {
             cur_item->next = info;
             cur_item = info;
         }
     }
 
     return head;
 }
 
+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;
+
+    case SYS_EMU_TARGET_PPC:
+    case SYS_EMU_TARGET_PPCEMB:
+    case SYS_EMU_TARGET_PPC64:
+        return CPU_INFO_ARCH_PPC;
+
+    case SYS_EMU_TARGET_SPARC:
+    case SYS_EMU_TARGET_SPARC64:
+        return CPU_INFO_ARCH_SPARC;
+
+    case SYS_EMU_TARGET_MIPS:
+    case SYS_EMU_TARGET_MIPSEL:
+    case SYS_EMU_TARGET_MIPS64:
+    case SYS_EMU_TARGET_MIPS64EL:
+        return CPU_INFO_ARCH_MIPS;
+
+    case SYS_EMU_TARGET_TRICORE:
+        return CPU_INFO_ARCH_TRICORE;
+
+    case SYS_EMU_TARGET_S390X:
+        return CPU_INFO_ARCH_S390;
+
+    case SYS_EMU_TARGET_RISCV32:
+    case SYS_EMU_TARGET_RISCV64:
+        return CPU_INFO_ARCH_RISCV;
+
+    default:
+        return CPU_INFO_ARCH_OTHER;
+    }
+}
+
+static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, const CPUState *cpu)
+{
+#ifdef TARGET_S390X
+    S390CPU *s390_cpu = S390_CPU(cpu);
+    CPUS390XState *env = &s390_cpu->env;
+
+    info->cpu_state = env->cpu_state;
+#else
+    abort();
+#endif
+}
+
 /*
  * fast means: we NEVER interrupt vCPU threads to retrieve
  * information from KVM.
  */
 CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
 {
     MachineState *ms = MACHINE(qdev_get_machine());
     MachineClass *mc = MACHINE_GET_CLASS(ms);
     CpuInfoFastList *head = NULL, *cur_item = NULL;
+    SysEmuTarget target = qapi_enum_parse(&SysEmuTarget_lookup, TARGET_NAME,
+                                          -1, &error_abort);
     CPUState *cpu;
-#if defined(TARGET_S390X)
-    S390CPU *s390_cpu;
-    CPUS390XState *env;
-#endif
 
     CPU_FOREACH(cpu) {
         CpuInfoFastList *info = g_malloc0(sizeof(*info));
         info->value = g_malloc0(sizeof(*info->value));
 
         info->value->cpu_index = cpu->cpu_index;
         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_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
+        info->value->arch = sysemu_target_to_cpuinfo_arch(target);
+        info->value->target = target;
+        if (target == SYS_EMU_TARGET_S390X) {
+            cpustate_to_cpuinfo_s390(&info->value->u.s390x, cpu);
+        } else {
+            /* do nothing for @CpuInfoOther */
+        }
+
         if (!cur_item) {
             head = cur_item = info;
         } else {
             cur_item->next = info;
             cur_item = info;
         }
     }
 
     return head;
 }
 
-- 
2.14.1.3.gb7cf6e02401b

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json"
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json" Laszlo Ersek
@ 2018-04-26 19:27   ` Eric Blake
  2018-04-27  7:18   ` Markus Armbruster
  1 sibling, 0 replies; 13+ messages in thread
From: Eric Blake @ 2018-04-26 19:27 UTC (permalink / raw)
  To: Laszlo Ersek, qemu devel list; +Cc: Daniel P. Berrange, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 2414 bytes --]

On 04/26/2018 01:34 PM, Laszlo Ersek wrote:
> 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" <berrange@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---

> +++ b/qapi/common.json

> +
> +##
> +# @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.

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:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 3/4] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 3/4] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget Laszlo Ersek
@ 2018-04-26 19:31   ` Eric Blake
  0 siblings, 0 replies; 13+ messages in thread
From: Eric Blake @ 2018-04-26 19:31 UTC (permalink / raw)
  To: Laszlo Ersek, qemu devel list; +Cc: Daniel P. Berrange, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

On 04/26/2018 01:34 PM, Laszlo Ersek wrote:
> Now that we have @SysEmuTarget, it makes sense to restrict
> @TargetInfo.@arch to valid sysemu targets at the schema level.
> 
> Cc: "Daniel P. Berrange" <berrange@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> ---

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch Laszlo Ersek
@ 2018-04-26 19:41   ` Eric Blake
  2018-04-26 19:45     ` Eric Blake
  2018-04-27  7:29   ` Markus Armbruster
  1 sibling, 1 reply; 13+ messages in thread
From: Eric Blake @ 2018-04-26 19:41 UTC (permalink / raw)
  To: Laszlo Ersek, qemu devel list; +Cc: Daniel P. Berrange, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 1640 bytes --]

On 04/26/2018 01:34 PM, Laszlo Ersek wrote:
> 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" <berrange@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> 

> +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.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
  2018-04-26 19:41   ` Eric Blake
@ 2018-04-26 19:45     ` Eric Blake
  0 siblings, 0 replies; 13+ messages in thread
From: Eric Blake @ 2018-04-26 19:45 UTC (permalink / raw)
  To: Laszlo Ersek, qemu devel list; +Cc: Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

On 04/26/2018 02:41 PM, Eric Blake wrote:

> 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.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast Laszlo Ersek
@ 2018-04-27  7:05   ` Cornelia Huck
  2018-04-27  7:18   ` Markus Armbruster
  1 sibling, 0 replies; 13+ messages in thread
From: Cornelia Huck @ 2018-04-27  7:05 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: qemu devel list, Eric Blake, Markus Armbruster,
	Viktor VM Mihajlovski, qemu-stable

On Thu, 26 Apr 2018 20:34:01 +0200
Laszlo Ersek <lersek@redhat.com> wrote:

> * 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>
> ---
> 
> 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(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast Laszlo Ersek
  2018-04-27  7:05   ` Cornelia Huck
@ 2018-04-27  7:18   ` Markus Armbruster
  1 sibling, 0 replies; 13+ messages in thread
From: Markus Armbruster @ 2018-04-27  7:18 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: qemu devel list, qemu-stable, Cornelia Huck, Viktor VM Mihajlovski

Laszlo Ersek <lersek@redhat.com> writes:

> * 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: Markus Armbruster <armbru@redhat.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json"
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json" Laszlo Ersek
  2018-04-26 19:27   ` Eric Blake
@ 2018-04-27  7:18   ` Markus Armbruster
  1 sibling, 0 replies; 13+ messages in thread
From: Markus Armbruster @ 2018-04-27  7:18 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: qemu devel list

Laszlo Ersek <lersek@redhat.com> writes:

> 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" <berrange@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Markus Armbruster <armbru@redhat.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch
  2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch Laszlo Ersek
  2018-04-26 19:41   ` Eric Blake
@ 2018-04-27  7:29   ` Markus Armbruster
  1 sibling, 0 replies; 13+ messages in thread
From: Markus Armbruster @ 2018-04-27  7:29 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: qemu devel list

Laszlo Ersek <lersek@redhat.com> writes:

> 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" <berrange@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>
> 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/f0c9c7ca-3dcf-4f74-9812-5dea5b6376cd@redhat.com>.
>       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(-)
>
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 460866cf542f..74e5c2e3b8f7 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -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

Let's deprecate this misbegotten enumeration, as I proposed in
Message-ID: <87bme5uolc.fsf@dusky.pond.sub.org>.  Could be done as a
follow-up patch.

> +#
> +# @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.

>  #
>  # Since: 2.12
>  #
>  ##
[...]

In case we decide not to deprecate @arch right away:
Reviewed-by: Markus Armbruster <armbru@redhat.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-04-27  7:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26 18:34 [Qemu-devel] [PATCH v2 0/4] qapi: introduce the SysEmuTarget enumeration Laszlo Ersek
2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 1/4] qapi: fill in CpuInfoFast.arch in query-cpus-fast Laszlo Ersek
2018-04-27  7:05   ` Cornelia Huck
2018-04-27  7:18   ` Markus Armbruster
2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 2/4] qapi: add SysEmuTarget to "common.json" Laszlo Ersek
2018-04-26 19:27   ` Eric Blake
2018-04-27  7:18   ` Markus Armbruster
2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 3/4] qapi: change the type of TargetInfo.arch from string to enum SysEmuTarget Laszlo Ersek
2018-04-26 19:31   ` Eric Blake
2018-04-26 18:34 ` [Qemu-devel] [PATCH v2 4/4] qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch Laszlo Ersek
2018-04-26 19:41   ` Eric Blake
2018-04-26 19:45     ` Eric Blake
2018-04-27  7:29   ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.