From d423675c94442dadb4bd751dac876385960ce109 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20F=C3=A4rber?= Date: Thu, 10 Nov 2011 16:35:32 +0100 Subject: [PATCH] vl.c: Fail gracefully if no machine is found MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit machine defaults to find_default_machine(), then gets overridden via -M and machine_parse(). If no -M is specified and find_default_machine() returns NULL (when no machine compiled in), exit with an error. Avoids a segfault when setting machine->max_cpus. Signed-off-by: Andreas Färber Signed-off-by: Anthony Liguori --- vl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vl.c b/vl.c index f169aac1f..16fa222f1 100644 --- a/vl.c +++ b/vl.c @@ -3089,6 +3089,11 @@ int main(int argc, char **argv, char **envp) data_dir = CONFIG_QEMU_DATADIR; } + if (machine == NULL) { + fprintf(stderr, "No machine found.\n"); + exit(1); + } + /* * Default to max_cpus = smp_cpus, in case the user doesn't * specify a max_cpus value. -- 2.39.2