qapi: report the default CPU type for each machine
PATCH v2 1/1 qapi: report the default CPU type for each machine
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.
---
Changed in v2:
- Fix qapi docs version tag
qapi/misc.json | 6 +++++- vl.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-)
qapi/misc.json +5 -1
@@ -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:
vl.c +4 -0
@@ -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;
Signature · 1 line
2.21.0
ping, any comments / thoughts ?
Quoted 61 lines · Daniel P. Berrangé
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 <[email protected]>Signed-off-by Daniel P. Berrangé <[email protected]>---
Changed in v2:
- Fix qapi docs version tag
qapi/misc.json | 6 +++++- vl.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-)qapi/misc.json +5
-1@@ -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:vl.c +4
-0@@ -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;Signature · 1 line
2.21.0
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 10 lines · On Wed, 12 Jun 2019 13:41:25 +0200 Daniel P. Berrangé <[email protected]>…
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 <[email protected]>Signed-off-by Daniel P. Berrangé <[email protected]>
we probably need to allow feed it back to QEMU -cpu directly for all machines (currently it will work only with a handfull of them) something like:
exec.c +8 -5
@@ -999,11 +999,14 @@ const char *parse_cpu_option(const char *cpu_option)exit (1 ); } - oc =cpu_class_by_name (CPU_RESOLVING_TYPE , model_pieces[0 ]); -if (oc ==NULL ) { -error_report ("unable to find CPU model '%s'" , model_pieces[0 ]); -g_strfreev (model_pieces); -exit (EXIT_FAILURE ); + oc =object_class_by_name (model_pieces[0 ]); +if (!oc) { + oc =cpu_class_by_name (CPU_RESOLVING_TYPE , model_pieces[0 ]); +if (oc ==NULL ) { +error_report ("unable to find CPU model '%s'" , model_pieces[0 ]); +g_strfreev (model_pieces); +exit (EXIT_FAILURE ); + } } cpu_type =object_class_get_name (oc);
Quoted 47 lines
---
Changed in v2:
- Fix qapi docs version tag
qapi/misc.json | 6 +++++- vl.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-)qapi/misc.json +5
-1@@ -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:vl.c +4
-0@@ -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;