qemu-riscv.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, qemu-arm@nongnu.org,
	"Maksim Davydov" <davydov-max@yandex-team.ru>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Alexander Bulekov" <alxndr@bu.edu>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Bandan Das" <bsd@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Darren Kenny" <darren.kenny@oracle.com>,
	"Qiuhao Li" <Qiuhao.Li@outlook.com>,
	"Laurent Vivier" <lvivier@redhat.com>
Subject: [PULL 02/22] qmp: add dump machine type compatibility properties
Date: Thu, 25 Apr 2024 13:01:35 +0200	[thread overview]
Message-ID: <20240425110157.20328-3-philmd@linaro.org> (raw)
In-Reply-To: <20240425110157.20328-1-philmd@linaro.org>

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



  parent reply	other threads:[~2024-04-25 11:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 11:01 [PULL 00/22] Misc HW patches for 2024-04-25 Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 01/22] qom: add default value Philippe Mathieu-Daudé
2024-04-25 11:01 ` Philippe Mathieu-Daudé [this message]
2024-04-25 11:01 ` [PULL 03/22] python/qemu/machine: add method to retrieve QEMUMachine::binary field Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 04/22] scripts: add script to compare compatibility properties Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 05/22] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 06/22] target/i386: Move APIC related code to cpu-apic.c Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 07/22] hw/misc/applesmc: Simplify DeviceReset handler Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 08/22] hw/misc/imx: Replace sprintf() by snprintf() Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 09/22] hw/riscv/virt: Replace sprintf by g_strdup_printf Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 10/22] hw: Fix problem with the A*MPCORE switches in the Kconfig files Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 11/22] hw: Add a Kconfig switch for the TYPE_CPU_CLUSTER device Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 12/22] hw/cxl/cxl-cdat: Make ct3_load_cdat() return boolean Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 13/22] hw/cxl/cxl-cdat: Make ct3_build_cdat() " Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 14/22] hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() " Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 15/22] hw/elf_ops: Rename elf_ops.h -> elf_ops.h.inc Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 16/22] hw/xtensa: Include missing 'exec/cpu-common.h' in 'bootparam.h' Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 17/22] hw/misc : Correct 5 spaces indents in stm32l4x5_exti Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 18/22] hw/i386/pc_sysfw: Remove unused parameter from pc_isa_bios_init() Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 19/22] hw/core/machine: Introduce the module as a CPU topology level Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 20/22] hw/core/machine: Support modules in -smp Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 21/22] hw/core: Introduce module-id as the topology subindex Philippe Mathieu-Daudé
2024-04-25 11:01 ` [PULL 22/22] hw/core: Support module-id in numa configuration Philippe Mathieu-Daudé
2024-04-26  2:40 ` [PULL 00/22] Misc HW patches for 2024-04-25 Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240425110157.20328-3-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=Qiuhao.Li@outlook.com \
    --cc=alxndr@bu.edu \
    --cc=armbru@redhat.com \
    --cc=bsd@redhat.com \
    --cc=darren.kenny@oracle.com \
    --cc=davydov-max@yandex-team.ru \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=lvivier@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    --cc=wangyanan55@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).