[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 27/32] machine: Print CPU model name instead of CPU type name
From: |
Gavin Shan |
Subject: |
[PATCH v3 27/32] machine: Print CPU model name instead of CPU type name |
Date: |
Thu, 7 Sep 2023 10:35:48 +1000 |
The names of supported CPU models instead of CPU types should be
printed when the user specified CPU type isn't supported, to be
consistent with the output from '-cpu ?'.
Correct the error messages to print CPU model names instead of CPU
type names.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
hw/core/machine.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 93a327927f..6b701526ae 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1357,6 +1357,7 @@ static void is_cpu_type_supported(MachineState *machine,
Error **errp)
MachineClass *mc = MACHINE_GET_CLASS(machine);
ObjectClass *oc = object_class_by_name(machine->cpu_type);
CPUClass *cc;
+ char *model;
int i;
/*
@@ -1373,11 +1374,18 @@ static void is_cpu_type_supported(MachineState
*machine, Error **errp)
/* The user specified CPU type isn't valid */
if (!mc->valid_cpu_types[i]) {
- error_setg(errp, "Invalid CPU type: %s", machine->cpu_type);
- error_append_hint(errp, "The valid types are: %s",
- mc->valid_cpu_types[0]);
+ model = cpu_model_from_type(machine->cpu_type);
+ error_setg(errp, "Invalid CPU type: %s", model);
+ g_free(model);
+
+ model = cpu_model_from_type(mc->valid_cpu_types[0]);
+ error_append_hint(errp, "The valid types are: %s", model);
+ g_free(model);
+
for (i = 1; mc->valid_cpu_types[i]; i++) {
- error_append_hint(errp, ", %s", mc->valid_cpu_types[i]);
+ model = cpu_model_from_type(mc->valid_cpu_types[i]);
+ error_append_hint(errp, ", %s", model);
+ g_free(model);
}
error_append_hint(errp, "\n");
--
2.41.0
- [PATCH v3 18/32] target/sparc: Improve sparc_cpu_class_by_name(), (continued)
- [PATCH v3 18/32] target/sparc: Improve sparc_cpu_class_by_name(), Gavin Shan, 2023/09/06
- [PATCH v3 19/32] target/xtensa: Improve xtensa_cpu_class_by_name(), Gavin Shan, 2023/09/06
- [PATCH v3 20/32] target/hppa: Implement hppa_cpu_list(), Gavin Shan, 2023/09/06
- [PATCH v3 21/32] target/microblaze: Implement microblaze_cpu_list(), Gavin Shan, 2023/09/06
- [PATCH v3 22/32] target/nios2: Implement nios2_cpu_list(), Gavin Shan, 2023/09/06
- [PATCH v3 23/32] Mark cpu_list() supported on all targets, Gavin Shan, 2023/09/06
- [PATCH v3 24/32] machine: Constify MachineClass::valid_cpu_types[i], Gavin Shan, 2023/09/06
- [PATCH v3 25/32] machine: Use error handling when CPU type is checked, Gavin Shan, 2023/09/06
- [PATCH v3 26/32] machine: Introduce helper is_cpu_type_supported(), Gavin Shan, 2023/09/06
- [PATCH v3 27/32] machine: Print CPU model name instead of CPU type name,
Gavin Shan <=
- [PATCH v3 28/32] hw/arm/virt: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/09/06
- [PATCH v3 29/32] hw/arm/virt: Hide host CPU model for tcg, Gavin Shan, 2023/09/06
- [PATCH v3 30/32] hw/arm/sbsa-ref: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/09/06