[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/8] machine: Print supported CPU models instead of typenames
From: |
Gavin Shan |
Subject: |
[PATCH v2 3/8] machine: Print supported CPU models instead of typenames |
Date: |
Wed, 26 Jul 2023 10:32:00 +1000 |
The supported CPU models instead of typenames should be printed when
the user specified CPU type isn't supported in is_cpu_type_supported(),
to be consistent with the CPU model specified by user through '-cpu
<model>' option.
Correct the error messages to print CPU models, maintained in the newly
added mc->valid_cpu_models because there is no fixed pattern for the
conversion between CPU model and typename. Besides, mc->valid_cpu_types
and mc->valid_cpu_models are further constified since we're here.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
hw/core/machine.c | 10 ++++++----
hw/m68k/q800.c | 8 +++++++-
include/hw/boards.h | 3 ++-
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index fe110e9b0a..858f8ede89 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1362,6 +1362,8 @@ static void is_cpu_type_supported(MachineState *machine,
Error **errp)
* type is provided through '-cpu' option.
*/
if (mc->valid_cpu_types && machine->cpu_type) {
+ assert(mc->valid_cpu_models && mc->valid_cpu_models[0]);
+
for (i = 0; mc->valid_cpu_types[i]; i++) {
if (object_class_dynamic_cast(oc, mc->valid_cpu_types[i])) {
break;
@@ -1371,10 +1373,10 @@ 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]);
- for (i = 1; mc->valid_cpu_types[i]; i++) {
- error_append_hint(errp, ", %s", mc->valid_cpu_types[i]);
+ error_append_hint(errp, "The valid models are: %s",
+ mc->valid_cpu_models[0]);
+ for (i = 1; mc->valid_cpu_models[i]; i++) {
+ error_append_hint(errp, ", %s", mc->valid_cpu_models[i]);
}
error_append_hint(errp, "\n");
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index b770b71d54..1e360674a7 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -596,11 +596,16 @@ static GlobalProperty hw_compat_q800[] = {
};
static const size_t hw_compat_q800_len = G_N_ELEMENTS(hw_compat_q800);
-static const char *q800_machine_valid_cpu_types[] = {
+static const char * const q800_machine_valid_cpu_types[] = {
M68K_CPU_TYPE_NAME("m68040"),
NULL
};
+static const char * const q800_machine_valid_cpu_models[] = {
+ "m68040",
+ NULL
+};
+
static void q800_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -609,6 +614,7 @@ static void q800_machine_class_init(ObjectClass *oc, void
*data)
mc->init = q800_machine_init;
mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
mc->valid_cpu_types = q800_machine_valid_cpu_types;
+ mc->valid_cpu_models = q800_machine_valid_cpu_models;
mc->max_cpus = 1;
mc->block_default_type = IF_SCSI;
mc->default_ram_id = "m68k_mac.ram";
diff --git a/include/hw/boards.h b/include/hw/boards.h
index ed83360198..81747b0788 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -268,7 +268,8 @@ struct MachineClass {
bool has_hotpluggable_cpus;
bool ignore_memory_transaction_failures;
int numa_mem_align_shift;
- const char **valid_cpu_types;
+ const char * const *valid_cpu_types;
+ const char * const *valid_cpu_models;
strList *allowed_dynamic_sysbus_devices;
bool auto_enable_numa_with_memhp;
bool auto_enable_numa_with_memdev;
--
2.41.0
[PATCH v2 4/8] hw/arm/virt: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/07/25
[PATCH v2 5/8] hw/arm/virt: Unsupported host CPU model on TCG, Gavin Shan, 2023/07/25
[PATCH v2 6/8] hw/arm/sbsa-ref: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/07/25
[PATCH v2 7/8] hw/arm: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/07/25