[PATCH-for-10.1 v7 1/2] qapi/machine: Add @qom-type field to CpuInfoFast structure

Philippe Mathieu-Daudé posted 2 patches 4 months ago
Maintainers: Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
[PATCH-for-10.1 v7 1/2] qapi/machine: Add @qom-type field to CpuInfoFast structure
Posted by Philippe Mathieu-Daudé 4 months ago
Knowing the QOM type name of a CPU can be useful,
in particular to infer its model name.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 qapi/machine.json          | 3 +++
 hw/core/machine-qmp-cmds.c | 1 +
 2 files changed, 4 insertions(+)

diff --git a/qapi/machine.json b/qapi/machine.json
index f712e7da6d6..a3f6fcec4d3 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -76,6 +76,8 @@
 #
 # @cpu-index: index of the virtual CPU
 #
+# @qom-type: QOM type name of the CPU (since 10.1)
+#
 # @qom-path: path to the CPU object in the QOM tree
 #
 # @thread-id: ID of the underlying host thread
@@ -89,6 +91,7 @@
 ##
 { 'union'         : 'CpuInfoFast',
   'base'          : { 'cpu-index'    : 'int',
+                      'qom-type'     : 'str',
                       'qom-path'     : 'str',
                       'thread-id'    : 'int',
                       '*props'       : 'CpuInstanceProperties',
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index d82043e1c68..5655bfcfee4 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -47,6 +47,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
         value->cpu_index = cpu->cpu_index;
         value->qom_path = object_get_canonical_path(OBJECT(cpu));
         value->thread_id = cpu->thread_id;
+        value->qom_type = g_strdup(object_get_typename(OBJECT(cpu)));
 
         if (mc->cpu_index_to_instance_props) {
             CpuInstanceProperties *props;
-- 
2.49.0


Re: [PATCH-for-10.1 v7 1/2] qapi/machine: Add @qom-type field to CpuInfoFast structure
Posted by Xiaoyao Li 4 months ago
On 7/15/2025 5:06 PM, Philippe Mathieu-Daudé wrote:
> Knowing the QOM type name of a CPU can be useful,
> in particular to infer its model name.
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>

> ---
>   qapi/machine.json          | 3 +++
>   hw/core/machine-qmp-cmds.c | 1 +
>   2 files changed, 4 insertions(+)
> 
> diff --git a/qapi/machine.json b/qapi/machine.json
> index f712e7da6d6..a3f6fcec4d3 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -76,6 +76,8 @@
>   #
>   # @cpu-index: index of the virtual CPU
>   #
> +# @qom-type: QOM type name of the CPU (since 10.1)
> +#
>   # @qom-path: path to the CPU object in the QOM tree
>   #
>   # @thread-id: ID of the underlying host thread
> @@ -89,6 +91,7 @@
>   ##
>   { 'union'         : 'CpuInfoFast',
>     'base'          : { 'cpu-index'    : 'int',
> +                      'qom-type'     : 'str',
>                         'qom-path'     : 'str',
>                         'thread-id'    : 'int',
>                         '*props'       : 'CpuInstanceProperties',
> diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
> index d82043e1c68..5655bfcfee4 100644
> --- a/hw/core/machine-qmp-cmds.c
> +++ b/hw/core/machine-qmp-cmds.c
> @@ -47,6 +47,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
>           value->cpu_index = cpu->cpu_index;
>           value->qom_path = object_get_canonical_path(OBJECT(cpu));
>           value->thread_id = cpu->thread_id;
> +        value->qom_type = g_strdup(object_get_typename(OBJECT(cpu)));
>   
>           if (mc->cpu_index_to_instance_props) {
>               CpuInstanceProperties *props;