qmp: add dump machine type compatibility properties

To control that creating new machine type doesn't affect the previous
types (their compat_props) and to check complex compat_props inheritance
we need qmp command to print machine type compatibility properties.
This patch adds the ability to get list of all the compat_props of the
corresponding supported machines for their comparison via new optional
argument of "query-machines" command. Since information on compatibility
properties can increase the command output by a factor of 40, add an
argument to enable it, default off.

Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240318213550.155573-3-davydov-max@yandex-team.ru>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Maksim Davydov 2024-03-19 00:35:48 +03:00 committed by Philippe Mathieu-Daudé
parent 443df40cad
commit 236e9397b3
3 changed files with 88 additions and 4 deletions

View File

@ -64,7 +64,8 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
return head;
}
MachineInfoList *qmp_query_machines(Error **errp)
MachineInfoList *qmp_query_machines(bool has_compat_props, bool compat_props,
Error **errp)
{
GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
MachineInfoList *mach_list = NULL;
@ -96,6 +97,26 @@ MachineInfoList *qmp_query_machines(Error **errp)
info->default_ram_id = g_strdup(mc->default_ram_id);
}
if (compat_props && mc->compat_props) {
int i;
info->compat_props = NULL;
CompatPropertyList **tail = &(info->compat_props);
info->has_compat_props = true;
for (i = 0; i < mc->compat_props->len; i++) {
GlobalProperty *mt_prop = g_ptr_array_index(mc->compat_props,
i);
CompatProperty *prop;
prop = g_malloc0(sizeof(*prop));
prop->qom_type = g_strdup(mt_prop->driver);
prop->property = g_strdup(mt_prop->property);
prop->value = g_strdup(mt_prop->value);
QAPI_LIST_APPEND(tail, prop);
}
}
QAPI_LIST_PREPEND(mach_list, info);
}

View File

@ -135,6 +135,26 @@
##
{ 'command': 'query-cpus-fast', 'returns': [ 'CpuInfoFast' ] }
##
# @CompatProperty:
#
# Property default values specific to a machine type, for use by
# scripts/compare-machine-types.
#
# @qom-type: name of the QOM type to which the default applies
#
# @property: name of its property to which the default applies
#
# @value: the default value (machine-specific default can overwrite
# the "default" default, to avoid this use -machine none)
#
# Since: 9.1
##
{ 'struct': 'CompatProperty',
'data': { 'qom-type': 'str',
'property': 'str',
'value': 'str' } }
##
# @MachineInfo:
#
@ -166,6 +186,14 @@
#
# @acpi: machine type supports ACPI (since 8.0)
#
# @compat-props: The machine type's compatibility properties. Only
# present when query-machines argument @compat-props is true.
# (since 9.1)
#
# Features:
#
# @unstable: Member @compat-props is experimental.
#
# Since: 1.2
##
{ 'struct': 'MachineInfo',
@ -173,18 +201,53 @@
'*is-default': 'bool', 'cpu-max': 'int',
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
'deprecated': 'bool', '*default-cpu-type': 'str',
'*default-ram-id': 'str', 'acpi': 'bool' } }
'*default-ram-id': 'str', 'acpi': 'bool',
'*compat-props': { 'type': ['CompatProperty'],
'features': ['unstable'] } } }
##
# @query-machines:
#
# Return a list of supported machines
#
# @compat-props: if true, also return compatibility properties.
# (default: false) (since 9.1)
#
# Features:
#
# @unstable: Argument @compat-props is experimental.
#
# Returns: a list of MachineInfo
#
# Since: 1.2
#
# Example:
#
# -> { "execute": "query-machines", "arguments": { "compat-props": true } }
# <- { "return": [
# {
# "hotpluggable-cpus": true,
# "name": "pc-q35-6.2",
# "compat-props": [
# {
# "qom-type": "virtio-mem",
# "property": "unplugged-inaccessible",
# "value": "off"
# }
# ],
# "numa-mem-supported": false,
# "default-cpu-type": "qemu64-x86_64-cpu",
# "cpu-max": 288,
# "deprecated": false,
# "default-ram-id": "pc.ram"
# },
# ...
# }
##
{ 'command': 'query-machines', 'returns': ['MachineInfo'] }
{ 'command': 'query-machines',
'data': { '*compat-props': { 'type': 'bool',
'features': [ 'unstable' ] } },
'returns': ['MachineInfo'] }
##
# @CurrentMachineParams:

View File

@ -46,7 +46,7 @@ static void qos_set_machines_devices_available(void)
MachineInfoList *mach_info;
ObjectTypeInfoList *type_info;
mach_info = qmp_query_machines(&error_abort);
mach_info = qmp_query_machines(false, false, &error_abort);
machines_apply_to_node(mach_info);
qapi_free_MachineInfoList(mach_info);