Simplify -machine option queries with qemu_get_machine_opts()

The previous two commits fixed bugs in -machine option queries.  I
can't find fault with the remaining queries, but let's use
qemu_get_machine_opts() everywhere, for consistency, simplicity and
robustness.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1372943363-24081-7-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Markus Armbruster 2013-07-04 15:09:22 +02:00 committed by Anthony Liguori
parent 7bccd94026
commit 2ff3de685a
6 changed files with 33 additions and 75 deletions

22
vl.c
View file

@ -1036,15 +1036,9 @@ static int parse_sandbox(QemuOpts *opts, void *opaque)
return 0;
}
/*********QEMU USB setting******/
bool usb_enabled(bool default_usb)
{
QemuOpts *mach_opts;
mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (mach_opts) {
return qemu_opt_get_bool(mach_opts, "usb", default_usb);
}
return default_usb;
return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", default_usb);
}
#ifndef _WIN32
@ -4095,14 +4089,10 @@ int main(int argc, char **argv, char **envp)
qtest_init();
}
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (machine_opts) {
kernel_filename = qemu_opt_get(machine_opts, "kernel");
initrd_filename = qemu_opt_get(machine_opts, "initrd");
kernel_cmdline = qemu_opt_get(machine_opts, "append");
} else {
kernel_filename = initrd_filename = kernel_cmdline = NULL;
}
machine_opts = qemu_get_machine_opts();
kernel_filename = qemu_opt_get(machine_opts, "kernel");
initrd_filename = qemu_opt_get(machine_opts, "initrd");
kernel_cmdline = qemu_opt_get(machine_opts, "append");
if (!boot_order) {
boot_order = machine->boot_order;
@ -4145,7 +4135,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
if (!linux_boot && machine_opts && qemu_opt_get(machine_opts, "dtb")) {
if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) {
fprintf(stderr, "-dtb only allowed with -kernel option\n");
exit(1);
}