diff mbox

[RFC,V2,8/9] machine-opts: replace qemu_opt_get by QOM QemuMachine queries

Message ID 1393765632-2753-9-git-send-email-marcel.a@redhat.com
State New
Headers show

Commit Message

Marcel Apfelbaum March 2, 2014, 1:07 p.m. UTC
It is cleaner to query current_machine's properties than
accessing QemuOpts from the code.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 device_tree.c         |  9 +++++----
 exec.c                | 21 ++++++++++++++++++---
 hw/arm/boot.c         |  3 ++-
 hw/microblaze/boot.c  | 13 +++++++------
 hw/ppc/e500.c         | 21 +++++++++++++--------
 hw/ppc/spapr.c        | 14 +++++++++-----
 hw/ppc/virtex_ml507.c |  3 ++-
 kvm-all.c             | 11 +++++++++--
 target-i386/kvm.c     | 10 ++++++++--
 vl.c                  | 26 ++++++++++++++++++--------
 10 files changed, 91 insertions(+), 40 deletions(-)

Comments

Paolo Bonzini March 3, 2014, 10:11 a.m. UTC | #1
Il 02/03/2014 14:07, Marcel Apfelbaum ha scritto:
> @@ -1182,10 +1183,17 @@ ram_addr_t last_ram_offset(void)
>  static void qemu_ram_setup_dump(void *addr, ram_addr_t size)
>  {
>      int ret;
> +    bool dump_guest_core = true;
> +
> +    if (object_property_is_set(OBJECT(current_machine),
> +                               "dump-guest-core", &error_abort)) {
> +        dump_guest_core = object_property_get_bool(OBJECT(current_machine),
> +                                                   "dump-guest-core",
> +                                                   &error_abort);
> +    }

You do not need object_property_is_set.  You can just initialize the 
field to true in the instance_init function.  Same for mem_merge.

> @@ -563,11 +565,14 @@ static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr,
>      mpic = g_new(qemu_irq, 256);
>
>      if (kvm_enabled()) {
> -        QemuOpts *machine_opts = qemu_get_machine_opts();
> -        bool irqchip_allowed = qemu_opt_get_bool(machine_opts,
> -                                                "kernel_irqchip", true);
> -        bool irqchip_required = qemu_opt_get_bool(machine_opts,
> -                                                  "kernel_irqchip", false);
> +        bool irqchip_allowed = true;
> +        bool irqchip_required = false;
> +        if (object_property_is_set(OBJECT(current_machine),
> +                                   "kernel_irqchip", &error_abort)) {
> +            irqchip_allowed = object_property_get_bool(OBJECT(current_machine),
> +                                                       "kernel_irqchip", &error_abort);
> +            irqchip_required = irqchip_allowed;
> +        }

Alternatively, you could have three properties: kernel_irqchip, 
write-only (no getter); kernel-irqchip-allowed; kernel-irqchip-required. 
  Setting irqchip writes to both kernel-irqchip-allowed and 
kernel-irqchip-required.  kernel-irqchip-allowed and 
kernel-irqchip-required are initialized to true and false respectively 
in the instance_init.


> diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> index bdb057e..8651167 100644
> --- a/hw/ppc/virtex_ml507.c
> +++ b/hw/ppc/virtex_ml507.c
> @@ -145,7 +145,8 @@ 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 = object_property_get_str(OBJECT(current_machine),
> +                                           "dtb", &error_abort);
>      if (dtb_filename) {
>          fdt = load_device_tree(dtb_filename, &fdt_size);
>          if (!fdt) {
> diff --git a/kvm-all.c b/kvm-all.c
> index 2ca9143..e483c3c 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -22,7 +22,7 @@
>
>  #include "qemu-common.h"
>  #include "qemu/atomic.h"
> -#include "qemu/option.h"
> +#include "hw/boards.h"
>  #include "qemu/config-file.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/hw.h"
> @@ -1292,8 +1292,15 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
>  static int kvm_irqchip_create(KVMState *s)
>  {
>      int ret;
> +    bool irqchip_allowed = true;
>
> -    if (!qemu_opt_get_bool(qemu_get_machine_opts(), "kernel_irqchip", true) ||
> +    if (object_property_is_set(OBJECT(current_machine),
> +                               "kernel_irqchip", &error_abort)) {
> +        irqchip_allowed = object_property_get_bool(OBJECT(current_machine),
> +                                                   "kernel_irqchip", &error_abort);
> +    }
> +
> +    if (!irqchip_allowed ||
>          !kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
>          return 0;
>      }
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index e555040..ca7e6bc 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -33,6 +33,7 @@
>  #include "exec/ioport.h"
>  #include <asm/hyperv.h>
>  #include "hw/pci/pci.h"
> +#include "hw/boards.h"
>
>  //#define DEBUG_KVM
>
> @@ -853,8 +854,13 @@ int kvm_arch_init(KVMState *s)
>      }
>      qemu_register_reset(kvm_unpoison_all, NULL);
>
> -    shadow_mem = qemu_opt_get_size(qemu_get_machine_opts(),
> -                                   "kvm_shadow_mem", -1);
> +    shadow_mem = -1;
> +    if (object_property_is_set(OBJECT(current_machine),
> +                               "kvm_shadow_mem", &error_abort)) {
> +        shadow_mem = object_property_get_int(OBJECT(current_machine),
> +                                             "kvm_shadow_mem", &error_abort);
> +    }

This can also be simply initialized in the instance_init function.

Paolo

> +
>      if (shadow_mem != -1) {
>          shadow_mem /= 4096;
>          ret = kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem);
> diff --git a/vl.c b/vl.c
> index dc206e1..007342c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2624,7 +2624,8 @@ static int configure_accelerator(void)
>      bool accel_initialised = false;
>      bool init_failed = false;
>
> -    p = qemu_opt_get(qemu_get_machine_opts(), "accel");
> +    p = object_property_get_str(OBJECT(current_machine),
> +                                "accel", &error_abort);
>      if (p == NULL) {
>          /* Use the default "accelerator", tcg */
>          p = "tcg";
> @@ -4077,6 +4078,12 @@ int main(int argc, char **argv, char **envp)
>          exit(0);
>      }
>
> +    machine_opts = qemu_get_machine_opts();
> +    if (qemu_opt_foreach(machine_opts, object_set_property, current_machine, 1) < 0) {
> +        object_unref(OBJECT(current_machine));
> +        exit(1);
> +    }
> +
>      configure_accelerator();
>
>      if (qtest_chrdev) {
> @@ -4089,12 +4096,14 @@ int main(int argc, char **argv, char **envp)
>          }
>      }
>
> -    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");
> -    bios_name = qemu_opt_get(machine_opts, "firmware");
> -
> +    kernel_filename = object_property_get_str(OBJECT(current_machine),
> +                                              "kernel", &error_abort);
> +    initrd_filename = object_property_get_str(OBJECT(current_machine),
> +                                              "initrd", &error_abort);
> +    kernel_cmdline = object_property_get_str(OBJECT(current_machine),
> +                                             "append", &error_abort);
> +    bios_name = object_property_get_str(OBJECT(current_machine),
> +                                        "firmware", &error_abort);
>      boot_order = machine->default_boot_order;
>      opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
>      if (opts) {
> @@ -4135,7 +4144,8 @@ int main(int argc, char **argv, char **envp)
>          exit(1);
>      }
>
> -    if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) {
> +    if (!linux_boot && object_property_get_str(OBJECT(current_machine),
> +                                               "dtb", &error_abort)) {
>          fprintf(stderr, "-dtb only allowed with -kernel option\n");
>          exit(1);
>      }
>
Marcel Apfelbaum March 3, 2014, 12:10 p.m. UTC | #2
On Mon, 2014-03-03 at 11:11 +0100, Paolo Bonzini wrote:
> Il 02/03/2014 14:07, Marcel Apfelbaum ha scritto:
> > @@ -1182,10 +1183,17 @@ ram_addr_t last_ram_offset(void)
> >  static void qemu_ram_setup_dump(void *addr, ram_addr_t size)
> >  {
> >      int ret;
> > +    bool dump_guest_core = true;
> > +
> > +    if (object_property_is_set(OBJECT(current_machine),
> > +                               "dump-guest-core", &error_abort)) {
> > +        dump_guest_core = object_property_get_bool(OBJECT(current_machine),
> > +                                                   "dump-guest-core",
> > +                                                   &error_abort);
> > +    }
> 
> You do not need object_property_is_set.  You can just initialize the 
> field to true in the instance_init function.  Same for mem_merge.
Sure, I can. I was just trying to leave the current functionality "as is",
is some other code will assume "false" as default.
But I can go for required/allowed getters as you suggested, thanks.

> 
> > @@ -563,11 +565,14 @@ static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr,
> >      mpic = g_new(qemu_irq, 256);
> >
> >      if (kvm_enabled()) {
> > -        QemuOpts *machine_opts = qemu_get_machine_opts();
> > -        bool irqchip_allowed = qemu_opt_get_bool(machine_opts,
> > -                                                "kernel_irqchip", true);
> > -        bool irqchip_required = qemu_opt_get_bool(machine_opts,
> > -                                                  "kernel_irqchip", false);
> > +        bool irqchip_allowed = true;
> > +        bool irqchip_required = false;
> > +        if (object_property_is_set(OBJECT(current_machine),
> > +                                   "kernel_irqchip", &error_abort)) {
> > +            irqchip_allowed = object_property_get_bool(OBJECT(current_machine),
> > +                                                       "kernel_irqchip", &error_abort);
> > +            irqchip_required = irqchip_allowed;
> > +        }
> 
> Alternatively, you could have three properties: kernel_irqchip, 
> write-only (no getter); kernel-irqchip-allowed; kernel-irqchip-required. 
>   Setting irqchip writes to both kernel-irqchip-allowed and 
> kernel-irqchip-required.  kernel-irqchip-allowed and 
> kernel-irqchip-required are initialized to true and false respectively 
> in the instance_init.
The functionality will not be affected if I use your idea,
both implementations are not "clean", but at least yours does not require
an extra QOM method.

Thanks,
Marcel

> 
> 
> > diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> > index bdb057e..8651167 100644
> > --- a/hw/ppc/virtex_ml507.c
> > +++ b/hw/ppc/virtex_ml507.c
> > @@ -145,7 +145,8 @@ 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 = object_property_get_str(OBJECT(current_machine),
> > +                                           "dtb", &error_abort);
> >      if (dtb_filename) {
> >          fdt = load_device_tree(dtb_filename, &fdt_size);
> >          if (!fdt) {
> > diff --git a/kvm-all.c b/kvm-all.c
> > index 2ca9143..e483c3c 100644
> > --- a/kvm-all.c
> > +++ b/kvm-all.c
> > @@ -22,7 +22,7 @@
> >
> >  #include "qemu-common.h"
> >  #include "qemu/atomic.h"
> > -#include "qemu/option.h"
> > +#include "hw/boards.h"
> >  #include "qemu/config-file.h"
> >  #include "sysemu/sysemu.h"
> >  #include "hw/hw.h"
> > @@ -1292,8 +1292,15 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
> >  static int kvm_irqchip_create(KVMState *s)
> >  {
> >      int ret;
> > +    bool irqchip_allowed = true;
> >
> > -    if (!qemu_opt_get_bool(qemu_get_machine_opts(), "kernel_irqchip", true) ||
> > +    if (object_property_is_set(OBJECT(current_machine),
> > +                               "kernel_irqchip", &error_abort)) {
> > +        irqchip_allowed = object_property_get_bool(OBJECT(current_machine),
> > +                                                   "kernel_irqchip", &error_abort);
> > +    }
> > +
> > +    if (!irqchip_allowed ||
> >          !kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
> >          return 0;
> >      }
> > diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> > index e555040..ca7e6bc 100644
> > --- a/target-i386/kvm.c
> > +++ b/target-i386/kvm.c
> > @@ -33,6 +33,7 @@
> >  #include "exec/ioport.h"
> >  #include <asm/hyperv.h>
> >  #include "hw/pci/pci.h"
> > +#include "hw/boards.h"
> >
> >  //#define DEBUG_KVM
> >
> > @@ -853,8 +854,13 @@ int kvm_arch_init(KVMState *s)
> >      }
> >      qemu_register_reset(kvm_unpoison_all, NULL);
> >
> > -    shadow_mem = qemu_opt_get_size(qemu_get_machine_opts(),
> > -                                   "kvm_shadow_mem", -1);
> > +    shadow_mem = -1;
> > +    if (object_property_is_set(OBJECT(current_machine),
> > +                               "kvm_shadow_mem", &error_abort)) {
> > +        shadow_mem = object_property_get_int(OBJECT(current_machine),
> > +                                             "kvm_shadow_mem", &error_abort);
> > +    }
> 
> This can also be simply initialized in the instance_init function.
Sure, thanks

> 
> Paolo
> 
> > +
> >      if (shadow_mem != -1) {
> >          shadow_mem /= 4096;
> >          ret = kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem);
> > diff --git a/vl.c b/vl.c
> > index dc206e1..007342c 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -2624,7 +2624,8 @@ static int configure_accelerator(void)
> >      bool accel_initialised = false;
> >      bool init_failed = false;
> >
> > -    p = qemu_opt_get(qemu_get_machine_opts(), "accel");
> > +    p = object_property_get_str(OBJECT(current_machine),
> > +                                "accel", &error_abort);
> >      if (p == NULL) {
> >          /* Use the default "accelerator", tcg */
> >          p = "tcg";
> > @@ -4077,6 +4078,12 @@ int main(int argc, char **argv, char **envp)
> >          exit(0);
> >      }
> >
> > +    machine_opts = qemu_get_machine_opts();
> > +    if (qemu_opt_foreach(machine_opts, object_set_property, current_machine, 1) < 0) {
> > +        object_unref(OBJECT(current_machine));
> > +        exit(1);
> > +    }
> > +
> >      configure_accelerator();
> >
> >      if (qtest_chrdev) {
> > @@ -4089,12 +4096,14 @@ int main(int argc, char **argv, char **envp)
> >          }
> >      }
> >
> > -    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");
> > -    bios_name = qemu_opt_get(machine_opts, "firmware");
> > -
> > +    kernel_filename = object_property_get_str(OBJECT(current_machine),
> > +                                              "kernel", &error_abort);
> > +    initrd_filename = object_property_get_str(OBJECT(current_machine),
> > +                                              "initrd", &error_abort);
> > +    kernel_cmdline = object_property_get_str(OBJECT(current_machine),
> > +                                             "append", &error_abort);
> > +    bios_name = object_property_get_str(OBJECT(current_machine),
> > +                                        "firmware", &error_abort);
> >      boot_order = machine->default_boot_order;
> >      opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
> >      if (opts) {
> > @@ -4135,7 +4144,8 @@ int main(int argc, char **argv, char **envp)
> >          exit(1);
> >      }
> >
> > -    if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) {
> > +    if (!linux_boot && object_property_get_str(OBJECT(current_machine),
> > +                                               "dtb", &error_abort)) {
> >          fprintf(stderr, "-dtb only allowed with -kernel option\n");
> >          exit(1);
> >      }
> >
>
diff mbox

Patch

diff --git a/device_tree.c b/device_tree.c
index ca83504..11dfdb4 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -23,7 +23,7 @@ 
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
 #include "hw/loader.h"
-#include "qemu/option.h"
+#include "hw/boards.h"
 #include "qemu/config-file.h"
 
 #include <libfdt.h>
@@ -244,8 +244,8 @@  uint32_t qemu_fdt_alloc_phandle(void *fdt)
      * which phandle id to start allocting phandles.
      */
     if (!phandle) {
-        phandle = qemu_opt_get_number(qemu_get_machine_opts(),
-                                      "phandle_start", 0);
+        phandle = object_property_get_int(OBJECT(current_machine),
+                                          "phandle_start", &error_abort);
     }
 
     if (!phandle) {
@@ -305,7 +305,8 @@  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 = object_property_get_str(OBJECT(current_machine),
+                                                  "dumpdtb", &error_abort);
 
     if (dumpdtb) {
         /* Dump the dtb to a file and quit */
diff --git a/exec.c b/exec.c
index b69fd29..790287c 100644
--- a/exec.c
+++ b/exec.c
@@ -43,6 +43,7 @@ 
 #else /* !CONFIG_USER_ONLY */
 #include "sysemu/xen-mapcache.h"
 #include "trace.h"
+#include "hw/boards.h"
 #endif
 #include "exec/cpu-all.h"
 
@@ -1182,10 +1183,17 @@  ram_addr_t last_ram_offset(void)
 static void qemu_ram_setup_dump(void *addr, ram_addr_t size)
 {
     int ret;
+    bool dump_guest_core = true;
+
+    if (object_property_is_set(OBJECT(current_machine),
+                               "dump-guest-core", &error_abort)) {
+        dump_guest_core = object_property_get_bool(OBJECT(current_machine),
+                                                   "dump-guest-core",
+                                                   &error_abort);
+    }
 
     /* Use MADV_DONTDUMP, if user doesn't want the guest memory in the core */
-    if (!qemu_opt_get_bool(qemu_get_machine_opts(),
-                           "dump-guest-core", true)) {
+    if (!dump_guest_core) {
         ret = qemu_madvise(addr, size, QEMU_MADV_DONTDUMP);
         if (ret) {
             perror("qemu_madvise");
@@ -1232,7 +1240,14 @@  void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev)
 
 static int memory_try_enable_merging(void *addr, size_t len)
 {
-    if (!qemu_opt_get_bool(qemu_get_machine_opts(), "mem-merge", true)) {
+    bool mem_merge = true;
+    if (object_property_is_set(OBJECT(current_machine),
+                               "mem-merge", &error_abort)) {
+        mem_merge = object_property_get_bool(OBJECT(current_machine),
+                                             "mem-merge", &error_abort);
+    }
+
+    if (!mem_merge) {
         /* disabled by the user */
         return 0;
     }
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index dc62918..384b7e6 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -468,7 +468,8 @@  void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
         kernel_load_offset = KERNEL_LOAD_ADDR;
     }
 
-    info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
+    info->dtb_filename = object_property_get_str(OBJECT(current_machine),
+                                                 "dtb", &error_abort);
 
     if (!info->secondary_cpu_reset_hook) {
         info->secondary_cpu_reset_hook = default_reset_secondary;
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 48d9e7a..eace912 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -24,7 +24,7 @@ 
  * THE SOFTWARE.
  */
 
-#include "qemu/option.h"
+#include "hw/boards.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "qemu-common.h"
@@ -109,15 +109,16 @@  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;
 
-    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 = object_property_get_str(OBJECT(current_machine),
+                                              "kernel", &error_abort);
+    kernel_cmdline = object_property_get_str(OBJECT(current_machine),
+                                              "append", &error_abort);
+    dtb_arg = object_property_get_str(OBJECT(current_machine),
+                                      "dtb", &error_abort);
     if (dtb_arg) { /* Preference a -dtb argument */
         dtb_filename = dtb_arg;
     } else { /* default to pcbios dtb as passed by machine_init */
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index b37ce9d..ca9a0c1 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -159,9 +159,11 @@  static int ppce500_load_device_tree(QEMUMachineInitArgs *args,
             0x0, 0xe1000000,
             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 = object_property_get_str(OBJECT(current_machine),
+                                                  "dtb", &error_abort);
+    const char *toplevel_compat = object_property_get_str(OBJECT(current_machine),
+                                                          "dt_compatible",
+                                                          &error_abort);
 
     if (dtb_file) {
         char *filename;
@@ -563,11 +565,14 @@  static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr,
     mpic = g_new(qemu_irq, 256);
 
     if (kvm_enabled()) {
-        QemuOpts *machine_opts = qemu_get_machine_opts();
-        bool irqchip_allowed = qemu_opt_get_bool(machine_opts,
-                                                "kernel_irqchip", true);
-        bool irqchip_required = qemu_opt_get_bool(machine_opts,
-                                                  "kernel_irqchip", false);
+        bool irqchip_allowed = true;
+        bool irqchip_required = false;
+        if (object_property_is_set(OBJECT(current_machine),
+                                   "kernel_irqchip", &error_abort)) {
+            irqchip_allowed = object_property_get_bool(OBJECT(current_machine),
+                                                       "kernel_irqchip", &error_abort);
+            irqchip_required = irqchip_allowed;
+        }
 
         if (irqchip_allowed) {
             dev = ppce500_init_mpic_kvm(params, irqs);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 93d02c1e..a176f8f 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -169,11 +169,15 @@  static XICSState *xics_system_init(int nr_servers, int nr_irqs)
     XICSState *icp = NULL;
 
     if (kvm_enabled()) {
-        QemuOpts *machine_opts = qemu_get_machine_opts();
-        bool irqchip_allowed = qemu_opt_get_bool(machine_opts,
-                                                "kernel_irqchip", true);
-        bool irqchip_required = qemu_opt_get_bool(machine_opts,
-                                                  "kernel_irqchip", false);
+        bool irqchip_allowed = true;
+        bool irqchip_required = false;
+        if (object_property_is_set(OBJECT(current_machine),
+                                   "kernel_irqchip", &error_abort)) {
+            irqchip_allowed = object_property_get_bool(OBJECT(current_machine),
+                                                       "kernel_irqchip", &error_abort);
+            irqchip_required = irqchip_allowed;
+        }
+
         if (irqchip_allowed) {
             icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs);
         }
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index bdb057e..8651167 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -145,7 +145,8 @@  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 = object_property_get_str(OBJECT(current_machine),
+                                           "dtb", &error_abort);
     if (dtb_filename) {
         fdt = load_device_tree(dtb_filename, &fdt_size);
         if (!fdt) {
diff --git a/kvm-all.c b/kvm-all.c
index 2ca9143..e483c3c 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -22,7 +22,7 @@ 
 
 #include "qemu-common.h"
 #include "qemu/atomic.h"
-#include "qemu/option.h"
+#include "hw/boards.h"
 #include "qemu/config-file.h"
 #include "sysemu/sysemu.h"
 #include "hw/hw.h"
@@ -1292,8 +1292,15 @@  int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
 static int kvm_irqchip_create(KVMState *s)
 {
     int ret;
+    bool irqchip_allowed = true;
 
-    if (!qemu_opt_get_bool(qemu_get_machine_opts(), "kernel_irqchip", true) ||
+    if (object_property_is_set(OBJECT(current_machine),
+                               "kernel_irqchip", &error_abort)) {
+        irqchip_allowed = object_property_get_bool(OBJECT(current_machine),
+                                                   "kernel_irqchip", &error_abort);
+    }
+
+    if (!irqchip_allowed ||
         !kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
         return 0;
     }
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index e555040..ca7e6bc 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -33,6 +33,7 @@ 
 #include "exec/ioport.h"
 #include <asm/hyperv.h>
 #include "hw/pci/pci.h"
+#include "hw/boards.h"
 
 //#define DEBUG_KVM
 
@@ -853,8 +854,13 @@  int kvm_arch_init(KVMState *s)
     }
     qemu_register_reset(kvm_unpoison_all, NULL);
 
-    shadow_mem = qemu_opt_get_size(qemu_get_machine_opts(),
-                                   "kvm_shadow_mem", -1);
+    shadow_mem = -1;
+    if (object_property_is_set(OBJECT(current_machine),
+                               "kvm_shadow_mem", &error_abort)) {
+        shadow_mem = object_property_get_int(OBJECT(current_machine),
+                                             "kvm_shadow_mem", &error_abort);
+    }
+
     if (shadow_mem != -1) {
         shadow_mem /= 4096;
         ret = kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem);
diff --git a/vl.c b/vl.c
index dc206e1..007342c 100644
--- a/vl.c
+++ b/vl.c
@@ -2624,7 +2624,8 @@  static int configure_accelerator(void)
     bool accel_initialised = false;
     bool init_failed = false;
 
-    p = qemu_opt_get(qemu_get_machine_opts(), "accel");
+    p = object_property_get_str(OBJECT(current_machine),
+                                "accel", &error_abort);
     if (p == NULL) {
         /* Use the default "accelerator", tcg */
         p = "tcg";
@@ -4077,6 +4078,12 @@  int main(int argc, char **argv, char **envp)
         exit(0);
     }
 
+    machine_opts = qemu_get_machine_opts();
+    if (qemu_opt_foreach(machine_opts, object_set_property, current_machine, 1) < 0) {
+        object_unref(OBJECT(current_machine));
+        exit(1);
+    }
+
     configure_accelerator();
 
     if (qtest_chrdev) {
@@ -4089,12 +4096,14 @@  int main(int argc, char **argv, char **envp)
         }
     }
 
-    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");
-    bios_name = qemu_opt_get(machine_opts, "firmware");
-
+    kernel_filename = object_property_get_str(OBJECT(current_machine),
+                                              "kernel", &error_abort);
+    initrd_filename = object_property_get_str(OBJECT(current_machine),
+                                              "initrd", &error_abort);
+    kernel_cmdline = object_property_get_str(OBJECT(current_machine),
+                                             "append", &error_abort);
+    bios_name = object_property_get_str(OBJECT(current_machine),
+                                        "firmware", &error_abort);
     boot_order = machine->default_boot_order;
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     if (opts) {
@@ -4135,7 +4144,8 @@  int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
-    if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) {
+    if (!linux_boot && object_property_get_str(OBJECT(current_machine),
+                                               "dtb", &error_abort)) {
         fprintf(stderr, "-dtb only allowed with -kernel option\n");
         exit(1);
     }