[PATCH-for-10.1 v7 2/2] hw/core/machine: Display CPU model name in 'info cpus' command

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 2/2] hw/core/machine: Display CPU model name in 'info cpus' command
Posted by Philippe Mathieu-Daudé 4 months ago
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)

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

diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index c6325cdcaaa..54b6f5406dc 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -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);
-- 
2.49.0


Re: [PATCH-for-10.1 v7 2/2] hw/core/machine: Display CPU model name in 'info cpus' command
Posted by Xiaoyao Li 4 months ago
On 7/15/2025 5:06 PM, Philippe Mathieu-Daudé wrote:
> 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)
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> Tested-by: Zhao Liu <zhao1.liu@intel.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

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

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

> ---
>   hw/core/machine-hmp-cmds.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
> index c6325cdcaaa..54b6f5406dc 100644
> --- a/hw/core/machine-hmp-cmds.c
> +++ b/hw/core/machine-hmp-cmds.c
> @@ -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);


Re: [PATCH-for-10.1 v7 2/2] hw/core/machine: Display CPU model name in 'info cpus' command
Posted by Philippe Mathieu-Daudé 4 months ago
On 15/7/25 11:30, Xiaoyao Li wrote:
> On 7/15/2025 5:06 PM, Philippe Mathieu-Daudé wrote:
>> 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)
>>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>> Tested-by: Zhao Liu <zhao1.liu@intel.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> IIRC, I gave r-b tag before. Anyway,
> 
> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>

Sorry I missed it and thank you :)