From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4EOg-0000zH-7f for qemu-devel@nongnu.org; Wed, 22 Aug 2012 13:07:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4EOY-0007nE-0m for qemu-devel@nongnu.org; Wed, 22 Aug 2012 13:07:14 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47593 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4EOX-0007my-NC for qemu-devel@nongnu.org; Wed, 22 Aug 2012 13:07:05 -0400 Message-ID: <503511B6.3050401@suse.de> Date: Wed, 22 Aug 2012 19:07:02 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1345604562-27289-1-git-send-email-qemulist@gmail.com> In-Reply-To: <1345604562-27289-1-git-send-email-qemulist@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qom: removal of link property need to release its target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Liu Ping Fan , qemu-devel@nongnu.org, Anthony Liguori Am 22.08.2012 05:02, schrieb Liu Ping Fan: > From: Liu Ping Fan >=20 > Currently, link property's target is only managed by > object_set_link_property(). This will raise such issue that when > the property is finalized, its target has no opportunity to release. >=20 > Fix this issue by introduce object_finalize_link_property() >=20 > Signed-off-by: Liu Ping Fan > --- > qom/object.c | 12 +++++++++++- > 1 files changed, 11 insertions(+), 1 deletions(-) >=20 > diff --git a/qom/object.c b/qom/object.c > index a552be2..76b3d34 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -957,6 +957,16 @@ static void object_set_link_property(Object *obj, = Visitor *v, void *opaque, > } > } > =20 > +static void object_finalize_link_property(Object *obj, const char *nam= e, > + void *opaque) > +{ > + Object **child =3D opaque; > + > + if (*child !=3D NULL) { > + object_unref(*child); > + } > +} The naming is confusing: In ObjectProperty this hook is called "release" and you're not finalizing the value either, just unref'ing, which may or may not lead to the finalizer being called. I'd thus propose "object_release_link_property" for whatever gets decided its implementation should do. Regards, Andreas > + > void object_property_add_link(Object *obj, const char *name, > const char *type, Object **child, > Error **errp) > @@ -968,7 +978,7 @@ void object_property_add_link(Object *obj, const ch= ar *name, > object_property_add(obj, name, full_type, > object_get_link_property, > object_set_link_property, > - NULL, child, errp); > + object_finalize_link_property, child, errp); > =20 > g_free(full_type); > } --=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