From 62b4a227a330c76f5a7bac5d0ba903dfd1c3c9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 16 Nov 2023 17:33:12 +0100 Subject: hw/core: Add machine_class_default_cpu_type() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Reviewed-by: Richard Henderson Message-Id: <20231116163726.28952-1-philmd@linaro.org> --- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'hw') diff --git a/hw/core/machine.c b/hw/core/machine.c index 2699bcba53..0198b54b39 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -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) { -- cgit v1.2.3