From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypfb0-00089O-IF for qemu-devel@nongnu.org; Tue, 05 May 2015 12:21:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ypfax-0004vU-Ak for qemu-devel@nongnu.org; Tue, 05 May 2015 12:21:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypfax-0004vK-2f for qemu-devel@nongnu.org; Tue, 05 May 2015 12:21:19 -0400 Message-ID: <5548EDEE.4010100@redhat.com> Date: Tue, 05 May 2015 18:21:02 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1430489347-13772-1-git-send-email-ehabkost@redhat.com> <1430489347-13772-2-git-send-email-ehabkost@redhat.com> <5543C2BC.8020208@redhat.com> <20150505160654.GG25766@thinpad.lan.raisama.net> In-Reply-To: <20150505160654.GG25766@thinpad.lan.raisama.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 1/2] qom: Implement object_property_add_const_link() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mimu@linux.vnet.ibm.com, qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, bharata@linux.vnet.ibm.com, cornelia.huck@de.ibm.com, Igor Mammedov , =?windows-1252?Q?Andreas_F=E4rber?= , david@gibson.dropbear.id.au On 05/05/2015 18:06, Eduardo Habkost wrote: > On Fri, May 01, 2015 at 08:15:24PM +0200, Paolo Bonzini wrote: >> > On 01/05/2015 16:09, Eduardo Habkost wrote: >>> > > +void object_property_add_const_link(Object *obj, const char *name, >>> > > + const char *type, Object *child, >>> > > + ObjectPropertyLinkFlags flags, >>> > > + Error **errp) >>> > > +{ >>> > > + Object **childp = g_new0(Object*, 1); >>> > > + >>> > > + *childp = child; >>> > > + object_property_add_link(obj, name, type, childp, NULL, >>> > > + flags | OBJ_PROP_LINK_FREE_CHILD_POINTER, errp); >>> > > +} >>> > > + >> > >> > This works, but is the extra functionality needed, compared to >> > an alias? Namely, when is flags going to be != 0? > Flags is going to be != 0 if the caller grabs a reference to the target > object (to ensure it won't disappear) and wants it to be automatically > dropped when the property is removed. It is not strictly necessary, but > I thought it could be useful. > > But to be honest, I don't love the flags argument in > object_property_add_link(), either. I mean: why do we need flags in > object_property_add_link() and not in object_property_add_alias()? > >> > >> > FWIW, here is my ./.. patch. I'm all for adding a helper like >> > object_property_add_const_link on top if we go for it. > Looks good to me. > >> > >> > Another possibility is to not introduce any of our patches and reuse >> > the child<> getter and resolve functions in >> > object_property_add_const_link. > Using the "." property would allow object_property_add_const_link() to > be a one-liner, so it sounds better to me. > You don't need this function anymore though, right? So I'll just adjust my series to use object_property_add_const_link(). Paolo