qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	QEMU <qemu-devel@nongnu.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	xen-devel@lists.xenproject.org,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
Date: Thu, 13 Dec 2018 13:06:54 +0100	[thread overview]
Message-ID: <20181213130654.1eb72eb1@redhat.com> (raw)
In-Reply-To: <CAJ+F1CJ55pcq6OZdnSBVNGQwRSE=gQD0swPeHw_Roj2qVOnxSA@mail.gmail.com>

On Wed, 12 Dec 2018 16:00:06 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> On Mon, Dec 10, 2018 at 8:55 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Mon, 10 Dec 2018 17:45:22 +0100
> > Igor Mammedov <imammedo@redhat.com> wrote:
> >  
> > > On Tue,  4 Dec 2018 18:20:11 +0400
> > > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> > >  
> > > > Instead of registering compat properties as globals, let's keep them
> > > > in their own array, to avoid mixing with user globals.
> > > >
> > > > Introduce object_apply_global_props() function, to apply compatibility
> > > > properties from a GPtrArray.
> > > >
> > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > > ---
> > > >  include/hw/qdev-core.h | 10 ++++++++++
> > > >  include/qom/object.h   |  3 +++
> > > >  include/sysemu/accel.h |  4 +---
> > > >  accel/accel.c          | 12 ------------
> > > >  hw/core/qdev.c         |  9 +++++++++
> > > >  hw/xen/xen-common.c    |  9 ++++++---
> > > >  qom/object.c           | 25 +++++++++++++++++++++++++
> > > >  vl.c                   |  1 -
> > > >  8 files changed, 54 insertions(+), 19 deletions(-)
> > > >  
> > > [...]  
> > > > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> > > > index 6ec14c73ca..4532aa8632 100644
> > > > --- a/hw/xen/xen-common.c
> > > > +++ b/hw/xen/xen-common.c
> > > > @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
> > > >          .driver = "migration",
> > > >          .property = "send-section-footer",
> > > >          .value = "off",
> > > > -    },
> > > > -    { /* end of list */ },
> > > > +    }
> > > >  };
> > > >
> > > >  static void xen_accel_class_init(ObjectClass *oc, void *data)
> > > >  {
> > > >      AccelClass *ac = ACCEL_CLASS(oc);
> > > > +
> > > >      ac->name = "Xen";
> > > >      ac->init_machine = xen_init;
> > > >      ac->setup_post = xen_setup_post;
> > > >      ac->allowed = &xen_allowed;
> > > > -    ac->global_props = xen_compat_props;
> > > > +    ac->compat_props = g_ptr_array_new();  
> > > where is matching free for that?  
> > can we at least annotate it somehow so that valgrind won't complain about this leak?  
> 
> If you check my commits on qemu, you should see that I do care (too
> much?) about leaks :)
> 
> In this case though, I don't see valgrind or asan complaining, I guess
> it's still a reachable reference.
> Do you think a FIXME comment would be helpful?
I've looked at other cases were we leak, and well we leak a lot so it's
probably futile exercise. But the comment won't hurt and will work as remainder.


> (/me wish we had a proper object system, GObject, but that ship as
> long sailed..)
> 
> >  
> > >  
> > > > +
> > > > +    compat_props_add(ac->compat_props,
> > > > +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
> > > >  }
> > > >
> > > >  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> > > > diff --git a/qom/object.c b/qom/object.c
> > > > index 17921c0a71..dbdab0aead 100644
> > > > --- a/qom/object.c
> > > > +++ b/qom/object.c
> > > > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> > > >      }
> > > >  }
> > > >
> > > > +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> > > > +{
> > > > +    Error *err = NULL;
> > > > +    int i;
> > > > +
> > > > +    if (!props) {
> > > > +        return;
> > > > +    }
> > > > +
> > > > +    for (i = 0; i < props->len; i++) {
> > > > +        GlobalProperty *p = g_ptr_array_index(props, i);
> > > > +
> > > > +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> > > > +            continue;
> > > > +        }
> > > > +        p->used = true;
> > > > +        object_property_parse(obj, p->value, p->property, &err);
> > > > +        if (err != NULL) {
> > > > +            error_prepend(&err, "can't apply global %s.%s=%s: ",
> > > > +                          p->driver, p->property, p->value);
> > > > +            error_propagate(errp, err);
> > > > +        }
> > > > +    }
> > > > +}
> > > > +
> > > >  static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
> > > >  {
> > > >      Object *obj = data;
> > > > diff --git a/vl.c b/vl.c
> > > > index a5ae5f23d2..88ba658572 100644
> > > > --- a/vl.c
> > > > +++ b/vl.c
> > > > @@ -2968,7 +2968,6 @@ static void user_register_global_props(void)
> > > >   */
> > > >  static void register_global_properties(MachineState *ms)
> > > >  {
> > > > -    accel_register_compat_props(ms->accelerator);
> > > >      machine_register_compat_props(ms);
> > > >      user_register_global_props();
> > > >  }  
> > >
> > >  
> >
> >  
> 
> 

  reply	other threads:[~2018-12-13 12:07 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 01/19] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 02/19] qom: make interface types abstract Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 03/19] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 04/19] accel: register global_props like machine globals Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 05/19] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 06/19] qom: remove unimplemented class_finalize Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals Marc-André Lureau
2018-12-10 16:45   ` Igor Mammedov
2018-12-10 16:54     ` Igor Mammedov
2018-12-12 12:00       ` Marc-André Lureau
2018-12-13 12:06         ` Igor Mammedov [this message]
2018-12-11 13:14   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine " Marc-André Lureau
2018-12-10 17:31   ` Eduardo Habkost
2018-12-11 12:07     ` Marc-André Lureau
2018-12-11 14:02       ` Eduardo Habkost
2018-12-11 14:23   ` Eduardo Habkost
2018-12-11 14:30     ` Marc-André Lureau
2018-12-11 15:52       ` Igor Mammedov
2018-12-11 17:43         ` Eduardo Habkost
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 09/19] hw: remove SET_MACHINE_COMPAT Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 10/19] qdev: make a separate helper function to apply compat properties Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 11/19] qdev: all globals are now user-provided Marc-André Lureau
2018-12-10 17:00   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray Marc-André Lureau
2018-12-10 17:05   ` Igor Mammedov
2018-12-11 12:12     ` Marc-André Lureau
2018-12-11 13:03       ` Igor Mammedov
2018-12-11 13:04   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty Marc-André Lureau
2018-12-10 17:20   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props() Marc-André Lureau
2018-12-10 17:28   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data() Marc-André Lureau
2018-12-11 16:02   ` Igor Mammedov
2018-12-12 18:48     ` Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init() Marc-André Lureau
2018-12-11 13:43   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 17/19] hw/i386: add pc-i440fx-4.0 & pc-q35-4.0 Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 18/19] hw/arm/virt: add virt-4.0 machine type Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 19/19] hostmem: use object id for memory region name with >= 4.0 Marc-André Lureau
2018-12-04 14:22 ` [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
2018-12-10 17:07 ` Eduardo Habkost
2018-12-10 17:31   ` Igor Mammedov
2018-12-10 17:39     ` Eduardo Habkost
2018-12-11 15:11       ` Igor Mammedov

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=20181213130654.1eb72eb1@redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=anthony.perard@citrix.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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).