Skip to contentSkip to conversation

hw/core/machine: Display CPU model name in 'info cpus' command

PATCH Applied Philippe Mathieu-Daudé 2 participants 7 messages Jul 15, 2025

lore
Share & tools
lore
#0 lore raw

v7 cover hw/core/machine: Display CPU model name in 'info cpus' command

Since v6 [*]:
- Expose QOM type name on QMP (instead of model name)

(R-b tags kept)

[*] https://lore.kernel.org/qemu-devel/[email protected]/

Philippe Mathieu-Daudé (2):
qapi/machine: Add @qom-type field to CpuInfoFast structure hw/core/machine: Display CPU model name in 'info cpus' command

 qapi/machine.json          | 3 +++
 hw/core/machine-hmp-cmds.c | 4 +++-
 hw/core/machine-qmp-cmds.c | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.49.0
#1 lore raw

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

Knowing the QOM type name of a CPU can be useful, in particular to infer its model name.

---
 qapi/machine.json          | 3 +++
 hw/core/machine-qmp-cmds.c | 1 +
 2 files changed, 4 insertions(+)
qapi/machine.json +3 -0
index f712e7da6d6..a3f6fcec4d3 100644
@@ -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',
hw/core/machine-qmp-cmds.c +1 -0
index d82043e1c68..5655bfcfee4 100644
@@ -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;
Signature · 1 line
2.49.0
Reviewed-by on v7 1/2
#2 lore raw

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

Quoted 6 lines · Philippe Mathieu-Daudé

Knowing the QOM type name of a CPU can be useful, in particular to infer its model name.

Quoted 38 lines
---
  qapi/machine.json          | 3 +++
  hw/core/machine-qmp-cmds.c | 1 +
  2 files changed, 4 insertions(+)
qapi/machine.json +3 -0
index f712e7da6d6..a3f6fcec4d3 100644
@@ -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',
hw/core/machine-qmp-cmds.c +1 -0
index d82043e1c68..5655bfcfee4 100644
@@ -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;
#3 lore raw

PATCH v7 2/2 hw/core/machine: Display CPU model name in 'info cpus' command

In reply to Philippe Mathieu-Daudé

Display the CPU model in 'info cpus'. Example before:

 $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
 QEMU 10.0.0 monitor - type 'help' for more information
 (qemu) info cpus
 * CPU #0: thread_id=42924
   CPU #1: thread_id=42924
   CPU #2: thread_id=42924
   CPU #3: thread_id=42924
 (qemu) q

and after:

 $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
 QEMU 10.0.50 monitor - type 'help' for more information
 (qemu) info cpus
 * CPU #0: thread_id=42916 model=cortex-a72
   CPU #1: thread_id=42916 model=cortex-a72
   CPU #2: thread_id=42916 model=cortex-r5f
   CPU #3: thread_id=42916 model=cortex-r5f
 (qemu)
---
 hw/core/machine-hmp-cmds.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/core/machine-hmp-cmds.c +3 -1
index c6325cdcaaa..54b6f5406dc 100644
@@ -32,6 +32,7 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
     cpu_list = qmp_query_cpus_fast(NULL);
 
     for (cpu = cpu_list; cpu; cpu = cpu->next) {
+        g_autofree char *cpu_model = cpu_model_from_type(cpu->value->qom_type);
         int active = ' ';
 
         if (cpu->value->cpu_index == monitor_get_cpu_index(mon)) {
@@ -40,7 +41,8 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
 
         monitor_printf(mon, "%c CPU #%" PRId64 ":", active,
                        cpu->value->cpu_index);
-        monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
+        monitor_printf(mon, " thread_id=%" PRId64 " model=%s\n",
+                       cpu->value->thread_id, cpu_model);
     }
 
     qapi_free_CpuInfoFastList(cpu_list);
Signature · 1 line
2.49.0
Reviewed-by on v7 2/2
#4 lore raw
Quoted 22 lines · Philippe Mathieu-Daudé

Display the CPU model in 'info cpus'. Example before:

  $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
  QEMU 10.0.0 monitor - type 'help' for more information
  (qemu) info cpus
  * CPU #0: thread_id=42924
    CPU #1: thread_id=42924
    CPU #2: thread_id=42924
    CPU #3: thread_id=42924
  (qemu) q

and after:

  $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
  QEMU 10.0.50 monitor - type 'help' for more information
  (qemu) info cpus
  * CPU #0: thread_id=42916 model=cortex-a72
    CPU #1: thread_id=42916 model=cortex-a72
    CPU #2: thread_id=42916 model=cortex-r5f
    CPU #3: thread_id=42916 model=cortex-r5f
  (qemu)
Quoted 4 lines

IIRC, I gave r-b tag before. Anyway,

Quoted 26 lines
---
  hw/core/machine-hmp-cmds.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
hw/core/machine-hmp-cmds.c +3 -1
index c6325cdcaaa..54b6f5406dc 100644
@@ -32,6 +32,7 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
      cpu_list = qmp_query_cpus_fast(NULL);
 
      for (cpu = cpu_list; cpu; cpu = cpu->next) {
+        g_autofree char *cpu_model = cpu_model_from_type(cpu->value->qom_type);
          int active = ' ';
 
          if (cpu->value->cpu_index == monitor_get_cpu_index(mon)) {
@@ -40,7 +41,8 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
 
          monitor_printf(mon, "%c CPU #%" PRId64 ":", active,
                         cpu->value->cpu_index);
-        monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
+        monitor_printf(mon, " thread_id=%" PRId64 " model=%s\n",
+                       cpu->value->thread_id, cpu_model);
      }
 
      qapi_free_CpuInfoFastList(cpu_list);
#5 lore raw
Quoted 23 lines · Xiaoyao Li
Quoted 22 lines · Philippe Mathieu-Daudé

Display the CPU model in 'info cpus'. Example before:

  $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
  QEMU 10.0.0 monitor - type 'help' for more information
  (qemu) info cpus
  * CPU #0: thread_id=42924
    CPU #1: thread_id=42924
    CPU #2: thread_id=42924
    CPU #3: thread_id=42924
  (qemu) q

and after:

  $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
  QEMU 10.0.50 monitor - type 'help' for more information
  (qemu) info cpus
  * CPU #0: thread_id=42916 model=cortex-a72
    CPU #1: thread_id=42916 model=cortex-a72
    CPU #2: thread_id=42916 model=cortex-r5f
    CPU #3: thread_id=42916 model=cortex-r5f
  (qemu)
Quoted 8 lines
Quoted 4 lines

IIRC, I gave r-b tag before. Anyway,

Sorry I missed it and thank you :)