From patchwork Thu Nov 10 15:35:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: vl.c: Fail gracefully if no machine is found Date: Thu, 10 Nov 2011 05:35:32 -0000 From: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 124909 Message-Id: <1320939332-31871-1-git-send-email-andreas.faerber@web.de> To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= 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 --- vl.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index f169aac..16fa222 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.