提交 fb7c269e 编写于 作者: D Dunrong Huang 提交者: Stefan Hajnoczi

vl.c: Exit QEMU early if no machine is found

We check whether the variable machine is NULL or not before accessing
it. If machine is NULL, exit QEMU with an error, this can avoids a
segfault error.

Markus Armbruster <armbru@redhat.com> adds that the segfault can be
reproduced as follows:

  $ qemu-system-xtensa -cpu help
Signed-off-by: NDunrong Huang <riegamaths@gmail.com>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
上级 3d1d9652
......@@ -3204,6 +3204,11 @@ int main(int argc, char **argv, char **envp)
}
loc_set_none();
if (machine == NULL) {
fprintf(stderr, "No machine found.\n");
exit(1);
}
if (machine->hw_version) {
qemu_set_version(machine->hw_version);
}
......@@ -3246,11 +3251,6 @@ 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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册