hw/core: Add machine_class_default_cpu_type()

Add a helper to return a machine default CPU type.

If this machine is restricted to a single CPU type,
use it as default, obviously.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231116163726.28952-1-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2023-11-16 17:33:12 +01:00
parent 4b26aa9f3a
commit 62b4a227a3
3 changed files with 15 additions and 1 deletions

View file

@ -1390,6 +1390,14 @@ out:
return r;
}
const char *machine_class_default_cpu_type(MachineClass *mc)
{
if (mc->valid_cpu_types && !mc->valid_cpu_types[1]) {
/* Only a single CPU type allowed: use it as default. */
return mc->valid_cpu_types[0];
}
return mc->default_cpu_type;
}
void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp)
{