From: Marcel Apfelbaum <marcel.a@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: peter.maydell@linaro.org, blauwirbel@gmail.com,
mdroth@linux.vnet.ibm.com, mst@redhat.com, armbru@redhat.com,
mtosatti@redhat.com, agraf@suse.de, ehabkost@redhat.com,
qemu-devel@nongnu.org, peter.crosthwaite@petalogix.com,
quintela@redhat.com, aliguori@amazon.com, imammedo@redhat.com,
scottwood@freescale.com, edgar.iglesias@gmail.com,
lcapitulino@redhat.com, afaerber@suse.de, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH RFC V2 8/9] machine-opts: replace qemu_opt_get by QOM QemuMachine queries
Date: Mon, 03 Mar 2014 14:10:52 +0200 [thread overview]
Message-ID: <1393848652.3882.8.camel@localhost.localdomain> (raw)
In-Reply-To: <53145561.1090004@redhat.com>
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);
> > }
> >
>
next prev parent reply other threads:[~2014-03-03 12:10 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-02 13:07 [Qemu-devel] [PATCH RFC V2 0/9] qemu-machine as a QOM object Marcel Apfelbaum
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 1/9] hw/core: introduced qemu machine as " Marcel Apfelbaum
2014-03-03 12:56 ` Michael S. Tsirkin
2014-03-03 17:49 ` Andreas Färber
2014-03-03 19:06 ` Marcel Apfelbaum
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 2/9] vl: use qemu machine QOM class instead of global machines list Marcel Apfelbaum
2014-03-03 12:58 ` Michael S. Tsirkin
2014-03-03 12:57 ` Paolo Bonzini
2014-03-03 13:03 ` Marcel Apfelbaum
2014-03-03 14:52 ` Andreas Färber
2014-03-03 15:05 ` Marcel Apfelbaum
2014-03-03 18:12 ` Andreas Färber
2014-03-03 19:54 ` Marcel Apfelbaum
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 3/9] hw/boards: converted current_machine to be an instance of QemuMachineCLass Marcel Apfelbaum
2014-03-03 10:49 ` Paolo Bonzini
2014-03-03 12:07 ` Marcel Apfelbaum
2014-03-03 12:46 ` Paolo Bonzini
2014-03-03 12:11 ` Marcel Apfelbaum
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 4/9] hw/machine: add qemu machine opts as properties to QemuMachineState Marcel Apfelbaum
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 5/9] qapi: output visitor crashes qemu if it encounters a NULL value Marcel Apfelbaum
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 6/9] vl.c: do not set 'type' property in obj_set_property Marcel Apfelbaum
2014-03-03 10:11 ` Paolo Bonzini
2014-03-03 12:09 ` Marcel Apfelbaum
2014-03-03 12:47 ` Paolo Bonzini
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 7/9] qom: add object_property_is_set Marcel Apfelbaum
2014-03-03 10:13 ` Paolo Bonzini
2014-03-03 12:09 ` Marcel Apfelbaum
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 8/9] machine-opts: replace qemu_opt_get by QOM QemuMachine queries Marcel Apfelbaum
2014-03-03 10:11 ` Paolo Bonzini
2014-03-03 12:10 ` Marcel Apfelbaum [this message]
2014-03-02 13:07 ` [Qemu-devel] [PATCH RFC V2 9/9] hw/core: mapped QemuOpts into QEMUMachineInitArgs fields to remove duplication Marcel Apfelbaum
2014-03-03 10:13 ` Paolo Bonzini
2014-03-03 12:10 ` Marcel Apfelbaum
2014-03-03 10:50 ` [Qemu-devel] [PATCH RFC V2 0/9] qemu-machine as a QOM object Paolo Bonzini
2014-03-03 12:07 ` Marcel Apfelbaum
2014-03-03 12:56 ` Paolo Bonzini
2014-03-03 13:17 ` Marcel Apfelbaum
2014-03-03 14:10 ` Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393848652.3882.8.camel@localhost.localdomain \
--to=marcel.a@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@petalogix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=rth@twiddle.net \
--cc=scottwood@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).