mirror of https://github.com/xemu-project/xemu.git
vl: Simplify machine_parse()
Exploit that argument @name is nerver null. Check is_help_option() first, because that's what we do elsewhere. If we (foolishly!) defined a machine named "help", -machine help would now print help instead of selecting the machine named "help". Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Wei Yang <richardw.yang@linux.intel.com> Message-Id: <20190405064121.23662-5-richardw.yang@linux.intel.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
f2c9302138
commit
12cb82fdf0
22
vl.c
22
vl.c
|
@ -2576,19 +2576,10 @@ static gint machine_class_cmp(gconstpointer a, gconstpointer b)
|
||||||
|
|
||||||
static MachineClass *machine_parse(const char *name, GSList *machines)
|
static MachineClass *machine_parse(const char *name, GSList *machines)
|
||||||
{
|
{
|
||||||
MachineClass *mc = NULL;
|
MachineClass *mc;
|
||||||
GSList *el;
|
GSList *el;
|
||||||
|
|
||||||
if (name) {
|
if (is_help_option(name)) {
|
||||||
mc = find_machine(name, machines);
|
|
||||||
}
|
|
||||||
if (mc) {
|
|
||||||
return mc;
|
|
||||||
}
|
|
||||||
if (name && !is_help_option(name)) {
|
|
||||||
error_report("unsupported machine type");
|
|
||||||
error_printf("Use -machine help to list supported machines\n");
|
|
||||||
} else {
|
|
||||||
printf("Supported machines are:\n");
|
printf("Supported machines are:\n");
|
||||||
machines = g_slist_sort(machines, machine_class_cmp);
|
machines = g_slist_sort(machines, machine_class_cmp);
|
||||||
for (el = machines; el; el = el->next) {
|
for (el = machines; el; el = el->next) {
|
||||||
|
@ -2600,9 +2591,16 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
|
||||||
mc->is_default ? " (default)" : "",
|
mc->is_default ? " (default)" : "",
|
||||||
mc->deprecation_reason ? " (deprecated)" : "");
|
mc->deprecation_reason ? " (deprecated)" : "");
|
||||||
}
|
}
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(!name || !is_help_option(name));
|
mc = find_machine(name, machines);
|
||||||
|
if (!mc) {
|
||||||
|
error_report("unsupported machine type");
|
||||||
|
error_printf("Use -machine help to list supported machines\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return mc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_add_exit_notifier(Notifier *notify)
|
void qemu_add_exit_notifier(Notifier *notify)
|
||||||
|
|
Loading…
Reference in New Issue