[Qemu-devel] [PATCH v2] qapi: report the default CPU type for each machine

Daniel P. Berrangé posted 1 patch 2 weeks ago
Test s390x passed
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190612114125.22060-1-berrange@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
qapi/misc.json | 6 +++++-
vl.c           | 4 ++++
2 files changed, 9 insertions(+), 1 deletion(-)

[Qemu-devel] [PATCH v2] qapi: report the default CPU type for each machine

Posted by Daniel P. Berrangé 2 weeks ago
When user doesn't request any explicit CPU model with libvirt or QEMU,
a machine type specific CPU model is picked. Currently there is no way
to determine what this QEMU built-in default is, so libvirt cannot
report this back to the user in the XML config.

This extends the "query-machines" QMP command so that it reports the
default CPU model typename for each machine.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---

Changed in v2:

 - Fix qapi docs version tag

 qapi/misc.json | 6 +++++-
 vl.c           | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/qapi/misc.json b/qapi/misc.json
index 8b3ca4fdd3..9e2dedd938 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -2018,12 +2018,16 @@
 #
 # @hotpluggable-cpus: cpu hotplug via -device is supported (since 2.7.0)
 #
+# @default-cpu-type: default CPU model typename if none is requested via
+#                    the -cpu argument. (since 4.1)
+#
 # Since: 1.2.0
 ##
 { 'struct': 'MachineInfo',
   'data': { 'name': 'str', '*alias': 'str',
             '*is-default': 'bool', 'cpu-max': 'int',
-            'hotpluggable-cpus': 'bool'} }
+            'hotpluggable-cpus': 'bool',
+            '*default-cpu-type': 'str'} }
 
 ##
 # @query-machines:
diff --git a/vl.c b/vl.c
index 201144b162..b2de329bd2 100644
--- a/vl.c
+++ b/vl.c
@@ -1519,6 +1519,10 @@ MachineInfoList *qmp_query_machines(Error **errp)
         info->name = g_strdup(mc->name);
         info->cpu_max = !mc->max_cpus ? 1 : mc->max_cpus;
         info->hotpluggable_cpus = mc->has_hotpluggable_cpus;
+        if (mc->default_cpu_type) {
+            info->default_cpu_type = g_strdup(mc->default_cpu_type);
+            info->has_default_cpu_type = true;
+        }
 
         entry = g_malloc0(sizeof(*entry));
         entry->value = info;
-- 
2.21.0