Skip to content

Commit

Permalink
vl: make qemu_get_machine_opts static
Browse files Browse the repository at this point in the history
Machine options can be retrieved as properties of the machine object.
Encourage that by removing the "easy" accessor to machine options.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Dec 15, 2020
1 parent 55810e9 commit f2ce39b
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 39 deletions.
11 changes: 4 additions & 7 deletions accel/kvm/kvm-all.c
Expand Up @@ -2013,7 +2013,6 @@ static int kvm_init(MachineState *ms)
const KVMCapabilityInfo *missing_cap;
int ret;
int type = 0;
const char *kvm_type;
uint64_t dirty_log_manual_caps;

s = KVM_STATE(ms->accelerator);
Expand Down Expand Up @@ -2069,13 +2068,11 @@ static int kvm_init(MachineState *ms)
}
s->as = g_new0(struct KVMAs, s->nr_as);

kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type");
if (mc->kvm_type) {
if (object_property_find(OBJECT(current_machine), "kvm-type")) {
g_autofree char *kvm_type = object_property_get_str(OBJECT(current_machine),
"kvm-type",
&error_abort);
type = mc->kvm_type(ms, kvm_type);
} else if (kvm_type) {
ret = -EINVAL;
fprintf(stderr, "Invalid argument kvm-type=%s\n", kvm_type);
goto err;
}

do {
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/boot.c
Expand Up @@ -1299,7 +1299,7 @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms, struct arm_boot_info *info)
info->kernel_filename = ms->kernel_filename;
info->kernel_cmdline = ms->kernel_cmdline;
info->initrd_filename = ms->initrd_filename;
info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
info->dtb_filename = ms->dtb;
info->dtb_limit = 0;

/* Load the kernel. */
Expand Down
9 changes: 4 additions & 5 deletions hw/microblaze/boot.c
Expand Up @@ -34,6 +34,7 @@
#include "sysemu/device_tree.h"
#include "sysemu/reset.h"
#include "sysemu/sysemu.h"
#include "hw/boards.h"
#include "hw/loader.h"
#include "elf.h"
#include "qemu/cutils.h"
Expand Down Expand Up @@ -116,16 +117,14 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
const char *dtb_filename,
void (*machine_cpu_reset)(MicroBlazeCPU *))
{
QemuOpts *machine_opts;
const char *kernel_filename;
const char *kernel_cmdline;
const char *dtb_arg;
char *filename = NULL;

machine_opts = qemu_get_machine_opts();
kernel_filename = qemu_opt_get(machine_opts, "kernel");
kernel_cmdline = qemu_opt_get(machine_opts, "append");
dtb_arg = qemu_opt_get(machine_opts, "dtb");
kernel_filename = current_machine->kernel_filename;
kernel_cmdline = current_machine->kernel_cmdline;
dtb_arg = current_machine->dtb;
/* default to pcbios dtb as passed by machine_init */
if (!dtb_arg && dtb_filename) {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_filename);
Expand Down
9 changes: 4 additions & 5 deletions hw/nios2/boot.c
Expand Up @@ -39,6 +39,7 @@
#include "sysemu/device_tree.h"
#include "sysemu/reset.h"
#include "sysemu/sysemu.h"
#include "hw/boards.h"
#include "hw/loader.h"
#include "elf.h"

Expand Down Expand Up @@ -120,16 +121,14 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
const char *dtb_filename,
void (*machine_cpu_reset)(Nios2CPU *))
{
QemuOpts *machine_opts;
const char *kernel_filename;
const char *kernel_cmdline;
const char *dtb_arg;
char *filename = NULL;

machine_opts = qemu_get_machine_opts();
kernel_filename = qemu_opt_get(machine_opts, "kernel");
kernel_cmdline = qemu_opt_get(machine_opts, "append");
dtb_arg = qemu_opt_get(machine_opts, "dtb");
kernel_filename = current_machine->kernel_filename;
kernel_cmdline = current_machine->kernel_cmdline;
dtb_arg = current_machine->dtb;
/* default to pcbios dtb as passed by machine_init */
if (!dtb_arg) {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_filename);
Expand Down
5 changes: 2 additions & 3 deletions hw/ppc/e500.c
Expand Up @@ -343,9 +343,8 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms,
pmc->pci_pio_base >> 32, pmc->pci_pio_base,
0x0, 0x10000,
};
QemuOpts *machine_opts = qemu_get_machine_opts();
const char *dtb_file = qemu_opt_get(machine_opts, "dtb");
const char *toplevel_compat = qemu_opt_get(machine_opts, "dt_compatible");
const char *dtb_file = machine->dtb;
const char *toplevel_compat = machine->dt_compatible;

if (dtb_file) {
char *filename;
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/virtex_ml507.c
Expand Up @@ -152,7 +152,7 @@ static int xilinx_load_device_tree(hwaddr addr,
int r;
const char *dtb_filename;

dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
dtb_filename = current_machine->dtb;
if (dtb_filename) {
fdt = load_device_tree(dtb_filename, &fdt_size);
if (!fdt) {
Expand Down
6 changes: 2 additions & 4 deletions hw/riscv/sifive_u.c
Expand Up @@ -100,14 +100,12 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
int cpu;
uint32_t *cells;
char *nodename;
const char *dtb_filename;
char ethclk_names[] = "pclk\0hclk";
uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1;
uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle;

dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
if (dtb_filename) {
fdt = s->fdt = load_device_tree(dtb_filename, &s->fdt_size);
if (ms->dtb) {
fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size);
if (!fdt) {
error_report("load_device_tree() failed");
exit(1);
Expand Down
6 changes: 2 additions & 4 deletions hw/riscv/virt.c
Expand Up @@ -181,7 +181,6 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
{
void *fdt;
int i, cpu, socket;
const char *dtb_filename;
MachineState *mc = MACHINE(s);
uint64_t addr, size;
uint32_t *clint_cells, *plic_cells;
Expand All @@ -195,9 +194,8 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
hwaddr flashsize = virt_memmap[VIRT_FLASH].size / 2;
hwaddr flashbase = virt_memmap[VIRT_FLASH].base;

dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
if (dtb_filename) {
fdt = s->fdt = load_device_tree(dtb_filename, &s->fdt_size);
if (mc->dtb) {
fdt = s->fdt = load_device_tree(mc->dtb, &s->fdt_size);
if (!fdt) {
error_report("load_device_tree() failed");
exit(1);
Expand Down
9 changes: 4 additions & 5 deletions hw/xtensa/xtfpga.c
Expand Up @@ -233,11 +233,10 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
qemu_irq *extints;
DriveInfo *dinfo;
PFlashCFI01 *flash = NULL;
QemuOpts *machine_opts = qemu_get_machine_opts();
const char *kernel_filename = qemu_opt_get(machine_opts, "kernel");
const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
const char *dtb_filename = qemu_opt_get(machine_opts, "dtb");
const char *initrd_filename = qemu_opt_get(machine_opts, "initrd");
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *dtb_filename = machine->dtb;
const char *initrd_filename = machine->initrd_filename;
const unsigned system_io_size = 224 * MiB;
uint32_t freq = 10000000;
int n;
Expand Down
2 changes: 0 additions & 2 deletions include/sysemu/sysemu.h
Expand Up @@ -104,8 +104,6 @@ typedef void QEMUBootSetHandler(void *opaque, const char *boot_order,
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
void qemu_boot_set(const char *boot_order, Error **errp);

QemuOpts *qemu_get_machine_opts(void);

bool defaults_enabled(void);

void qemu_init(int argc, char **argv, char **envp);
Expand Down
2 changes: 1 addition & 1 deletion softmmu/device_tree.c
Expand Up @@ -526,7 +526,7 @@ int qemu_fdt_add_subnode(void *fdt, const char *name)

void qemu_fdt_dumpdtb(void *fdt, int size)
{
const char *dumpdtb = qemu_opt_get(qemu_get_machine_opts(), "dumpdtb");
const char *dumpdtb = current_machine->dumpdtb;

if (dumpdtb) {
/* Dump the dtb to a file and quit */
Expand Down
2 changes: 1 addition & 1 deletion softmmu/vl.c
Expand Up @@ -481,7 +481,7 @@ static QemuOptsList qemu_fw_cfg_opts = {
*
* Returns: machine options (never null).
*/
QemuOpts *qemu_get_machine_opts(void)
static QemuOpts *qemu_get_machine_opts(void)
{
return qemu_find_opts_singleton("machine");
}
Expand Down

0 comments on commit f2ce39b

Please sign in to comment.