[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/22] qmp: add dump machine type compatibility properties
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 02/22] qmp: add dump machine type compatibility properties |
Date: |
Thu, 25 Apr 2024 13:01:35 +0200 |
From: Maksim Davydov <davydov-max@yandex-team.ru>
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>
---
qapi/machine.json | 67 +++++++++++++++++++++++++++++++++++--
hw/core/machine-qmp-cmds.c | 23 ++++++++++++-
tests/qtest/fuzz/qos_fuzz.c | 2 +-
3 files changed, 88 insertions(+), 4 deletions(-)
diff --git a/qapi/machine.json b/qapi/machine.json
index 2df407e877..3e9cc3f17d 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -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:
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index c20829b9ae..5972100b1f 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -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);
}
diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c
index e403d373a0..b71e945c5f 100644
--- a/tests/qtest/fuzz/qos_fuzz.c
+++ b/tests/qtest/fuzz/qos_fuzz.c
@@ -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);
--
2.41.0
- [PULL 00/22] Misc HW patches for 2024-04-25, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 01/22] qom: add default value, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 02/22] qmp: add dump machine type compatibility properties,
Philippe Mathieu-Daudé <=
- [PULL 03/22] python/qemu/machine: add method to retrieve QEMUMachine::binary field, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 04/22] scripts: add script to compare compatibility properties, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 05/22] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 07/22] hw/misc/applesmc: Simplify DeviceReset handler, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 08/22] hw/misc/imx: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/25
- [PULL 06/22] target/i386: Move APIC related code to cpu-apic.c, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 14/22] hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() return boolean, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 19/22] hw/core/machine: Introduce the module as a CPU topology level, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 18/22] hw/i386/pc_sysfw: Remove unused parameter from pc_isa_bios_init(), Philippe Mathieu-Daudé, 2024/04/25
- [PULL 09/22] hw/riscv/virt: Replace sprintf by g_strdup_printf, Philippe Mathieu-Daudé, 2024/04/25