|
|
9ae3a8 |
From cfb7a42b4241cf1a8dea0f33947c66671923f694 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 6 Aug 2013 13:17:05 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 12/28] Simplify -machine option queries with qemu_get_machine_opts()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1375795025-28674-7-git-send-email-armbru@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 52996
|
|
|
9ae3a8 |
O-Subject: [PATCH 7.0 qemu-kvm 6/6] Simplify -machine option queries with qemu_get_machine_opts()
|
|
|
9ae3a8 |
Bugzilla: 980782
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The previous two commits fixed bugs in -machine option queries. I
|
|
|
9ae3a8 |
can't find fault with the remaining queries, but let's use
|
|
|
9ae3a8 |
qemu_get_machine_opts() everywhere, for consistency, simplicity and
|
|
|
9ae3a8 |
robustness.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Message-id: 1372943363-24081-7-git-send-email-armbru@redhat.com
|
|
|
9ae3a8 |
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
|
|
|
9ae3a8 |
(cherry picked from commit 2ff3de685a875ece3ee21256736c0a9dbf39dc4c)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
device_tree.c | 28 ++++++++++------------------
|
|
|
9ae3a8 |
exec.c | 12 ++++--------
|
|
|
9ae3a8 |
hw/arm/boot.c | 8 +-------
|
|
|
9ae3a8 |
hw/ppc/e500.c | 12 +++---------
|
|
|
9ae3a8 |
hw/ppc/spapr.c | 28 ++++++++++------------------
|
|
|
9ae3a8 |
vl.c | 22 ++++++----------------
|
|
|
9ae3a8 |
6 files changed, 34 insertions(+), 76 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
device_tree.c | 28 ++++++++++------------------
|
|
|
9ae3a8 |
exec.c | 12 ++++--------
|
|
|
9ae3a8 |
hw/arm/boot.c | 8 +-------
|
|
|
9ae3a8 |
hw/ppc/e500.c | 12 +++---------
|
|
|
9ae3a8 |
hw/ppc/spapr.c | 28 ++++++++++------------------
|
|
|
9ae3a8 |
vl.c | 22 ++++++----------------
|
|
|
9ae3a8 |
6 files changed, 34 insertions(+), 76 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/device_tree.c b/device_tree.c
|
|
|
9ae3a8 |
index 56af24b..77cbe04 100644
|
|
|
9ae3a8 |
--- a/device_tree.c
|
|
|
9ae3a8 |
+++ b/device_tree.c
|
|
|
9ae3a8 |
@@ -21,6 +21,7 @@
|
|
|
9ae3a8 |
#include "config.h"
|
|
|
9ae3a8 |
#include "qemu-common.h"
|
|
|
9ae3a8 |
#include "sysemu/device_tree.h"
|
|
|
9ae3a8 |
+#include "sysemu/sysemu.h"
|
|
|
9ae3a8 |
#include "hw/loader.h"
|
|
|
9ae3a8 |
#include "qemu/option.h"
|
|
|
9ae3a8 |
#include "qemu/config-file.h"
|
|
|
9ae3a8 |
@@ -239,14 +240,10 @@ uint32_t qemu_devtree_alloc_phandle(void *fdt)
|
|
|
9ae3a8 |
* which phandle id to start allocting phandles.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
if (!phandle) {
|
|
|
9ae3a8 |
- QemuOpts *machine_opts;
|
|
|
9ae3a8 |
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (machine_opts) {
|
|
|
9ae3a8 |
- const char *phandle_start;
|
|
|
9ae3a8 |
- phandle_start = qemu_opt_get(machine_opts, "phandle_start");
|
|
|
9ae3a8 |
- if (phandle_start) {
|
|
|
9ae3a8 |
- phandle = strtoul(phandle_start, NULL, 0);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ const char *phandle_start = qemu_opt_get(qemu_get_machine_opts(),
|
|
|
9ae3a8 |
+ "phandle_start");
|
|
|
9ae3a8 |
+ if (phandle_start) {
|
|
|
9ae3a8 |
+ phandle = strtoul(phandle_start, NULL, 0);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -307,15 +304,10 @@ int qemu_devtree_add_subnode(void *fdt, const char *name)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void qemu_devtree_dumpdtb(void *fdt, int size)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- QemuOpts *machine_opts;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (machine_opts) {
|
|
|
9ae3a8 |
- const char *dumpdtb = qemu_opt_get(machine_opts, "dumpdtb");
|
|
|
9ae3a8 |
- if (dumpdtb) {
|
|
|
9ae3a8 |
- /* Dump the dtb to a file and quit */
|
|
|
9ae3a8 |
- exit(g_file_set_contents(dumpdtb, fdt, size, NULL) ? 0 : 1);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ const char *dumpdtb = qemu_opt_get(qemu_get_machine_opts(), "dumpdtb");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (dumpdtb) {
|
|
|
9ae3a8 |
+ /* Dump the dtb to a file and quit */
|
|
|
9ae3a8 |
+ exit(g_file_set_contents(dumpdtb, fdt, size, NULL) ? 0 : 1);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/exec.c b/exec.c
|
|
|
9ae3a8 |
index aec65c5..ee22b9b 100644
|
|
|
9ae3a8 |
--- a/exec.c
|
|
|
9ae3a8 |
+++ b/exec.c
|
|
|
9ae3a8 |
@@ -31,6 +31,7 @@
|
|
|
9ae3a8 |
#include "hw/qdev.h"
|
|
|
9ae3a8 |
#include "qemu/osdep.h"
|
|
|
9ae3a8 |
#include "sysemu/kvm.h"
|
|
|
9ae3a8 |
+#include "sysemu/sysemu.h"
|
|
|
9ae3a8 |
#include "hw/xen/xen.h"
|
|
|
9ae3a8 |
#include "qemu/timer.h"
|
|
|
9ae3a8 |
#include "qemu/config-file.h"
|
|
|
9ae3a8 |
@@ -979,12 +980,10 @@ ram_addr_t last_ram_offset(void)
|
|
|
9ae3a8 |
static void qemu_ram_setup_dump(void *addr, ram_addr_t size)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
- QemuOpts *machine_opts;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Use MADV_DONTDUMP, if user doesn't want the guest memory in the core */
|
|
|
9ae3a8 |
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (machine_opts &&
|
|
|
9ae3a8 |
- !qemu_opt_get_bool(machine_opts, "dump-guest-core", true)) {
|
|
|
9ae3a8 |
+ if (!qemu_opt_get_bool(qemu_get_machine_opts(),
|
|
|
9ae3a8 |
+ "dump-guest-core", true)) {
|
|
|
9ae3a8 |
ret = qemu_madvise(addr, size, QEMU_MADV_DONTDUMP);
|
|
|
9ae3a8 |
if (ret) {
|
|
|
9ae3a8 |
perror("qemu_madvise");
|
|
|
9ae3a8 |
@@ -1031,10 +1030,7 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int memory_try_enable_merging(void *addr, size_t len)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- QemuOpts *opts;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (opts && !qemu_opt_get_bool(opts, "mem-merge", true)) {
|
|
|
9ae3a8 |
+ if (!qemu_opt_get_bool(qemu_get_machine_opts(), "mem-merge", true)) {
|
|
|
9ae3a8 |
/* disabled by the user */
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
|
|
|
9ae3a8 |
index 6bffc3d..6436109 100644
|
|
|
9ae3a8 |
--- a/hw/arm/boot.c
|
|
|
9ae3a8 |
+++ b/hw/arm/boot.c
|
|
|
9ae3a8 |
@@ -365,7 +365,6 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
|
|
|
9ae3a8 |
uint64_t elf_entry;
|
|
|
9ae3a8 |
hwaddr entry;
|
|
|
9ae3a8 |
int big_endian;
|
|
|
9ae3a8 |
- QemuOpts *machine_opts;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Load the kernel. */
|
|
|
9ae3a8 |
if (!info->kernel_filename) {
|
|
|
9ae3a8 |
@@ -373,12 +372,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
|
|
|
9ae3a8 |
exit(1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (machine_opts) {
|
|
|
9ae3a8 |
- info->dtb_filename = qemu_opt_get(machine_opts, "dtb");
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- info->dtb_filename = NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!info->secondary_cpu_reset_hook) {
|
|
|
9ae3a8 |
info->secondary_cpu_reset_hook = default_reset_secondary;
|
|
|
9ae3a8 |
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
|
|
|
9ae3a8 |
index c9ae512..ef3e571 100644
|
|
|
9ae3a8 |
--- a/hw/ppc/e500.c
|
|
|
9ae3a8 |
+++ b/hw/ppc/e500.c
|
|
|
9ae3a8 |
@@ -137,7 +137,6 @@ static int ppce500_load_device_tree(CPUPPCState *env,
|
|
|
9ae3a8 |
uint32_t clock_freq = 400000000;
|
|
|
9ae3a8 |
uint32_t tb_freq = 400000000;
|
|
|
9ae3a8 |
int i;
|
|
|
9ae3a8 |
- const char *toplevel_compat = NULL; /* user override */
|
|
|
9ae3a8 |
char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus";
|
|
|
9ae3a8 |
char soc[128];
|
|
|
9ae3a8 |
char mpic[128];
|
|
|
9ae3a8 |
@@ -158,14 +157,9 @@ static int ppce500_load_device_tree(CPUPPCState *env,
|
|
|
9ae3a8 |
0x0, 0xe1000000,
|
|
|
9ae3a8 |
0x0, 0x10000,
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
- QemuOpts *machine_opts;
|
|
|
9ae3a8 |
- const char *dtb_file = NULL;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (machine_opts) {
|
|
|
9ae3a8 |
- dtb_file = qemu_opt_get(machine_opts, "dtb");
|
|
|
9ae3a8 |
- toplevel_compat = qemu_opt_get(machine_opts, "dt_compatible");
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ QemuOpts *machine_opts = qemu_get_machine_opts();
|
|
|
9ae3a8 |
+ const char *dtb_file = qemu_opt_get(machine_opts, "dtb");
|
|
|
9ae3a8 |
+ const char *toplevel_compat = qemu_opt_get(machine_opts, "dt_compatible");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (dtb_file) {
|
|
|
9ae3a8 |
char *filename;
|
|
|
9ae3a8 |
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
|
|
|
9ae3a8 |
index c96ac81..6a46488 100644
|
|
|
9ae3a8 |
--- a/hw/ppc/spapr.c
|
|
|
9ae3a8 |
+++ b/hw/ppc/spapr.c
|
|
|
9ae3a8 |
@@ -678,27 +678,19 @@ static void spapr_cpu_reset(void *opaque)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void spapr_create_nvram(sPAPREnvironment *spapr)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- QemuOpts *machine_opts;
|
|
|
9ae3a8 |
- DeviceState *dev;
|
|
|
9ae3a8 |
+ DeviceState *dev = qdev_create(&spapr->vio_bus->bus, "spapr-nvram");
|
|
|
9ae3a8 |
+ const char *drivename = qemu_opt_get(qemu_get_machine_opts(), "nvram");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- dev = qdev_create(&spapr->vio_bus->bus, "spapr-nvram");
|
|
|
9ae3a8 |
+ if (drivename) {
|
|
|
9ae3a8 |
+ BlockDriverState *bs;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (machine_opts) {
|
|
|
9ae3a8 |
- const char *drivename;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- drivename = qemu_opt_get(machine_opts, "nvram");
|
|
|
9ae3a8 |
- if (drivename) {
|
|
|
9ae3a8 |
- BlockDriverState *bs;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- bs = bdrv_find(drivename);
|
|
|
9ae3a8 |
- if (!bs) {
|
|
|
9ae3a8 |
- fprintf(stderr, "No such block device \"%s\" for nvram\n",
|
|
|
9ae3a8 |
- drivename);
|
|
|
9ae3a8 |
- exit(1);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- qdev_prop_set_drive_nofail(dev, "drive", bs);
|
|
|
9ae3a8 |
+ bs = bdrv_find(drivename);
|
|
|
9ae3a8 |
+ if (!bs) {
|
|
|
9ae3a8 |
+ fprintf(stderr, "No such block device \"%s\" for nvram\n",
|
|
|
9ae3a8 |
+ drivename);
|
|
|
9ae3a8 |
+ exit(1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+ qdev_prop_set_drive_nofail(dev, "drive", bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qdev_init_nofail(dev);
|
|
|
9ae3a8 |
diff --git a/vl.c b/vl.c
|
|
|
9ae3a8 |
index 0ed9257..d424af7 100644
|
|
|
9ae3a8 |
--- a/vl.c
|
|
|
9ae3a8 |
+++ b/vl.c
|
|
|
9ae3a8 |
@@ -1037,15 +1037,9 @@ static int parse_sandbox(QemuOpts *opts, void *opaque)
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-/*********QEMU USB setting******/
|
|
|
9ae3a8 |
bool usb_enabled(bool default_usb)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- QemuOpts *mach_opts;
|
|
|
9ae3a8 |
- mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (mach_opts) {
|
|
|
9ae3a8 |
- return qemu_opt_get_bool(mach_opts, "usb", default_usb);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- return default_usb;
|
|
|
9ae3a8 |
+ return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", default_usb);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#ifndef _WIN32
|
|
|
9ae3a8 |
@@ -4136,14 +4130,10 @@ int main(int argc, char **argv, char **envp)
|
|
|
9ae3a8 |
qtest_init();
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
|
|
|
9ae3a8 |
- if (machine_opts) {
|
|
|
9ae3a8 |
- kernel_filename = qemu_opt_get(machine_opts, "kernel");
|
|
|
9ae3a8 |
- initrd_filename = qemu_opt_get(machine_opts, "initrd");
|
|
|
9ae3a8 |
- kernel_cmdline = qemu_opt_get(machine_opts, "append");
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- kernel_filename = initrd_filename = kernel_cmdline = NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ machine_opts = qemu_get_machine_opts();
|
|
|
9ae3a8 |
+ kernel_filename = qemu_opt_get(machine_opts, "kernel");
|
|
|
9ae3a8 |
+ initrd_filename = qemu_opt_get(machine_opts, "initrd");
|
|
|
9ae3a8 |
+ kernel_cmdline = qemu_opt_get(machine_opts, "append");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!kernel_cmdline) {
|
|
|
9ae3a8 |
kernel_cmdline = "";
|
|
|
9ae3a8 |
@@ -4161,7 +4151,7 @@ int main(int argc, char **argv, char **envp)
|
|
|
9ae3a8 |
exit(1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (!linux_boot && machine_opts && qemu_opt_get(machine_opts, "dtb")) {
|
|
|
9ae3a8 |
+ if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) {
|
|
|
9ae3a8 |
fprintf(stderr, "-dtb only allowed with -kernel option\n");
|
|
|
9ae3a8 |
exit(1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|