From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T60oT-0006cU-IC for qemu-devel@nongnu.org; Mon, 27 Aug 2012 11:01:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T60oM-0005lr-Um for qemu-devel@nongnu.org; Mon, 27 Aug 2012 11:01:13 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35079 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T60oM-0005lM-Lc for qemu-devel@nongnu.org; Mon, 27 Aug 2012 11:01:06 -0400 Message-ID: <503B8BAF.5080809@suse.de> Date: Mon, 27 Aug 2012 17:01:03 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1345996298-4892-1-git-send-email-aliguori@us.ibm.com> <1345996298-4892-5-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1345996298-4892-5-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 4/9] object: remove object_finalize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Paolo Bonzini , Liu Ping Fan , qemu-devel@nongnu.org Am 26.08.2012 17:51, schrieb Anthony Liguori: > Callers should just use object_unref >=20 > Signed-off-by: Anthony Liguori > --- > hw/qdev.c | 4 ---- > include/qemu/object.h | 9 --------- > qom/object.c | 2 +- > 3 files changed, 1 insertions(+), 14 deletions(-) >=20 > 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 =3D DEVICE(obj); > - BusState *bus; > DeviceClass *dc =3D DEVICE_GET_CLASS(dev); > =20 > if (dev->state =3D=3D DEV_STATE_INITIALIZED) { > - while (dev->num_child_bus) { > - bus =3D 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); > =20 > /** > - * object_finalize: > - * @obj: The object to finalize. > - * > - * This function destroys and object without freeing the memory associ= ated 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 *ty= pe) > } > } > =20 > -void object_finalize(void *data) > +static void object_finalize(void *data) > { > Object *obj =3D data; > TypeImpl *ti =3D 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 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg