[PATCH] qapi: Add 'acpi' field to 'query-machines' output

Peter Krempa posted 1 patch 1 year, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/c556e203447618f5e1020878b1781428b16ad97e.1677511289.git.pkrempa@redhat.com
Maintainers: Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
There is a newer version of this series
hw/core/machine-qmp-cmds.c | 1 +
include/hw/boards.h        | 3 +++
qapi/machine.json          | 4 +++-
3 files changed, 7 insertions(+), 1 deletion(-)
[PATCH] qapi: Add 'acpi' field to 'query-machines' output
Posted by Peter Krempa 1 year, 2 months ago
Report which machine types support ACPI so that management applications
can properly use the 'acpi' property even on platforms such as ARM where
support for ACPI depends on the machine type and thus checking presence
of '-machine acpi=' in 'query-command-line-options' is insufficient.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---

Libvirt intends to use this information to unbreak configs of ARM
machines with machine type which doesn't support ACPI. Historically
we'd use '-no-acpi' as the default was to enable ACPI. Conversion
to the modern equivalent '-machine acpi=' unfortunately didn't really
allow to fix the logic for this specific case whithout additional
information.

Libvirt patches are posted as:
https://listman.redhat.com/archives/libvir-list/2023-February/238153.html

 hw/core/machine-qmp-cmds.c | 1 +
 include/hw/boards.h        | 3 +++
 qapi/machine.json          | 4 +++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 2d904747c0..b98ff15089 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -102,6 +102,7 @@ MachineInfoList *qmp_query_machines(Error **errp)
         info->hotpluggable_cpus = mc->has_hotpluggable_cpus;
         info->numa_mem_supported = mc->numa_mem_supported;
         info->deprecated = !!mc->deprecation_reason;
+        info->acpi = !!object_class_property_find(OBJECT_CLASS(mc), "acpi");
         if (mc->default_cpu_type) {
             info->default_cpu_type = g_strdup(mc->default_cpu_type);
         }
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 6fbbfd56c8..c18b444bef 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -174,6 +174,8 @@ typedef struct {
  *    index @idx in @ms->possible_cpus[]
  * @has_hotpluggable_cpus:
  *    If true, board supports CPUs creation with -device/device_add.
+ * @has_acpi:
+ *    Machine type has support for ACPI.
  * @default_cpu_type:
  *    specifies default CPU_TYPE, which will be used for parsing target
  *    specific features and for creating CPUs if CPU name wasn't provided
@@ -262,6 +264,7 @@ struct MachineClass {
     bool rom_file_has_mr;
     int minimum_page_bits;
     bool has_hotpluggable_cpus;
+    bool has_acpi;
     bool ignore_memory_transaction_failures;
     int numa_mem_align_shift;
     const char **valid_cpu_types;
diff --git a/qapi/machine.json b/qapi/machine.json
index b9228a5e46..f82a00963b 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -155,6 +155,8 @@
 #
 # @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
 #
+# @acpi: machine type supports acpi (since 8.0)
+#
 # Since: 1.2
 ##
 { 'struct': 'MachineInfo',
@@ -162,7 +164,7 @@
             '*is-default': 'bool', 'cpu-max': 'int',
             'hotpluggable-cpus': 'bool',  'numa-mem-supported': 'bool',
             'deprecated': 'bool', '*default-cpu-type': 'str',
-            '*default-ram-id': 'str' } }
+            '*default-ram-id': 'str', 'acpi': 'bool' } }

 ##
 # @query-machines:
-- 
2.39.2
Re: [PATCH] qapi: Add 'acpi' field to 'query-machines' output
Posted by Markus Armbruster 1 year, 2 months ago
Peter Krempa <pkrempa@redhat.com> writes:

> Report which machine types support ACPI so that management applications
> can properly use the 'acpi' property even on platforms such as ARM where
> support for ACPI depends on the machine type and thus checking presence
> of '-machine acpi=' in 'query-command-line-options' is insufficient.
>
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>

[...]

> diff --git a/qapi/machine.json b/qapi/machine.json
> index b9228a5e46..f82a00963b 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -155,6 +155,8 @@
>  #
>  # @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
>  #
> +# @acpi: machine type supports acpi (since 8.0)

supports ACPI

> +#
>  # Since: 1.2
>  ##
>  { 'struct': 'MachineInfo',
> @@ -162,7 +164,7 @@
>              '*is-default': 'bool', 'cpu-max': 'int',
>              'hotpluggable-cpus': 'bool',  'numa-mem-supported': 'bool',
>              'deprecated': 'bool', '*default-cpu-type': 'str',
> -            '*default-ram-id': 'str' } }
> +            '*default-ram-id': 'str', 'acpi': 'bool' } }
>
>  ##
>  # @query-machines:


With that
Acked-by: Markus Armbruster <armbru@redhat.com>