From: Rohitashv Kumar <[email protected]> find_default_machine() returns the single machine whose class sets is_default. When QEMU is built with that machine compiled out there is no default at all, and starting QEMU without -machine fails with "No machine specified, and there is no default".
Add an is_default_fallback flag to MachineClass. When no is_default machine is present, find_default_machine() returns the machine that advertises itself as the fallback default. This changes nothing when the primary default machine is built in: the is_default machine always wins. Signed-off-by: Rohitashv Kumar <[email protected]> --- include/hw/core/boards.h | 1 + system/vl.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h index 29c68931..36c72e0c 100644 --- a/include/hw/core/boards.h +++ b/include/hw/core/boards.h @@ -294,6 +294,7 @@ struct MachineClass { pci_allow_0_address:1; bool auto_create_sdcard; bool is_default; + bool is_default_fallback; const char *default_machine_opts; const char *default_boot_order; const char *default_display; diff --git a/system/vl.c b/system/vl.c index 061cbdf8..b1123fe2 100644 --- a/system/vl.c +++ b/system/vl.c @@ -862,6 +862,7 @@ static MachineClass *find_default_machine(GSList *machines) { GSList *el; MachineClass *default_machineclass = NULL; + MachineClass *fallback_machineclass = NULL; for (el = machines; el; el = el->next) { MachineClass *mc = el->data; @@ -869,10 +870,14 @@ static MachineClass *find_default_machine(GSList *machines) if (mc->is_default) { assert(default_machineclass == NULL && "Multiple default machines"); default_machineclass = mc; + } else if (mc->is_default_fallback) { + assert(fallback_machineclass == NULL && + "Multiple fallback default machines"); + fallback_machineclass = mc; } } - return default_machineclass; + return default_machineclass ? default_machineclass : fallback_machineclass; } static void version(void) -- 2.47.3
