All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Liu Ping Fan <pingfank@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/9] object: remove object_finalize
Date: Mon, 27 Aug 2012 17:01:03 +0200	[thread overview]
Message-ID: <503B8BAF.5080809@suse.de> (raw)
In-Reply-To: <1345996298-4892-5-git-send-email-aliguori@us.ibm.com>

Am 26.08.2012 17:51, schrieb Anthony Liguori:
> Callers should just use object_unref
> 
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  hw/qdev.c             |    4 ----
>  include/qemu/object.h |    9 ---------
>  qom/object.c          |    2 +-
>  3 files changed, 1 insertions(+), 14 deletions(-)
> 
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 6b61daa..fdee91f 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -678,13 +678,9 @@ static void device_initfn(Object *obj)
>  static void device_finalize(Object *obj)
>  {
>      DeviceState *dev = DEVICE(obj);
> -    BusState *bus;
>      DeviceClass *dc = DEVICE_GET_CLASS(dev);
>  
>      if (dev->state == DEV_STATE_INITIALIZED) {
> -        while (dev->num_child_bus) {
> -            bus = QLIST_FIRST(&dev->child_bus);
> -        }
>          if (qdev_get_vmsd(dev)) {
>              vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
>          }

This seems to answer my remark on 3/9, should've been squashed into that
one.

> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index 487adcd..8bc9935 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -490,15 +490,6 @@ void object_initialize_with_type(void *data, Type type);
>  void object_initialize(void *obj, const char *typename);
>  
>  /**
> - * object_finalize:
> - * @obj: The object to finalize.
> - *
> - * This function destroys and object without freeing the memory associated with
> - * it.
> - */
> -void object_finalize(void *obj);
> -
> -/**
>   * object_dynamic_cast:
>   * @obj: The object to cast.
>   * @typename: The @typename to cast to.
> diff --git a/qom/object.c b/qom/object.c
> index 44135c3..1144f79 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -375,7 +375,7 @@ static void object_deinit(Object *obj, TypeImpl *type)
>      }
>  }
>  
> -void object_finalize(void *data)
> +static void object_finalize(void *data)
>  {
>      Object *obj = data;
>      TypeImpl *ti = obj->class->type;

This is what I was referring to with breaking the encapsulation on 3/9:
When we have a PHB with embedded PCIDevice on its PCIBus, as
demonstrated with i440fx and prep_pci, then when doing object_delete()
on the whole thing I expect the main object's finalizer to call
object_finalize() on its embedded childs, forcing their uninit or an
assert if a programming error. Not just an unref that might or might not
finalize it.

If however finalize is called only at refcount 0 then who will unref the
self-created children? Finalize would never be called due to pending
references by its children...

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2012-08-27 15:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-26 15:51 [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 1/9] savevm: don't rely on paths if we can store a DeviceState object Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 2/9] object: automatically free objects based on a release function Anthony Liguori
2012-08-27 13:31   ` Andreas Färber
2012-08-26 15:51 ` [Qemu-devel] [PATCH 3/9] qbus: remove glib_allocated/qom_allocated and use release hook to free memory Anthony Liguori
2012-08-27 14:02   ` Andreas Färber
2012-08-27 14:22     ` Anthony Liguori
2012-08-27 14:43       ` Andreas Färber
2012-08-26 15:51 ` [Qemu-devel] [PATCH 4/9] object: remove object_finalize Anthony Liguori
2012-08-27 15:01   ` Andreas Färber [this message]
2012-08-27 15:49     ` Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 5/9] object: add support for nullable child properties Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 6/9] qdev: make devices created with device_add nullable so they can be deleted Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 7/9] qdev: add notifier for when the device loses its parent bus (eject) Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 8/9] qdev: make qdev_set_parent_bus() just set a link property Anthony Liguori
2012-08-27  7:22   ` liu ping fan
2012-08-27 13:12     ` Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 9/9] hotplug: refactor hotplug to leverage new QOM functions Anthony Liguori
2012-08-27  7:22   ` liu ping fan
2012-08-27  7:22 ` [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug liu ping fan
2012-08-27 11:46   ` Andreas Färber
2012-08-27 12:09     ` Paolo Bonzini
2012-08-27 13:15       ` Anthony Liguori
2012-10-09 17:15 ` Vasilis Liaskovitis

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=503B8BAF.5080809@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=pingfank@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.