From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YrosX-0003cU-HF for qemu-devel@nongnu.org; Mon, 11 May 2015 10:40:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YrosT-0002ny-9V for qemu-devel@nongnu.org; Mon, 11 May 2015 10:40:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YrosT-0002nt-1w for qemu-devel@nongnu.org; Mon, 11 May 2015 10:40:17 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4BEeEl1021076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 11 May 2015 10:40:15 -0400 Message-ID: <5550BF4A.4070409@redhat.com> Date: Mon, 11 May 2015 16:40:10 +0200 From: Laszlo Ersek MIME-Version: 1.0 References: <1431352157-40283-1-git-send-email-pbonzini@redhat.com> <1431352157-40283-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1431352157-40283-12-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 11/31] qom: add object_property_add_const_link List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: kraxel@redhat.com, mst@redhat.com On 05/11/15 15:48, Paolo Bonzini wrote: > Suggested-by: Eduardo Habkost > Signed-off-by: Paolo Bonzini > --- > include/qom/object.h | 18 ++++++++++++++++++ > qom/object.c | 16 ++++++++++++++++ > 2 files changed, 34 insertions(+) > > diff --git a/include/qom/object.h b/include/qom/object.h > index d2d7748..0505f20 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -1290,6 +1290,24 @@ void object_property_add_alias(Object *obj, const char *name, > Error **errp); > > /** > + * object_property_add_const_link: > + * @obj: the object to add a property to > + * @name: the name of the property > + * @target: the object to be referred by the link > + * @errp: if an error occurs, a pointer to an area to store the error > + * > + * Add an unmodifiable link for a property on an object. This function will > + * add a property of type link where TYPE is the type of @target. > + * > + * The caller must ensure that @target stays alive as long as > + * this property exists. In the case @target is a child of @obj, > + * this will be the case. Otherwise, the caller is responsible for > + * taking a reference. > + */ > +void object_property_add_const_link(Object *obj, const char *name, > + Object *target, Error **errp); > + > +/** > * object_property_set_description: > * @obj: the object owning the property > * @name: the name of the property > diff --git a/qom/object.c b/qom/object.c > index b8dff43..ba89518 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -1266,6 +1266,22 @@ out: > g_free(full_type); > } > > +void object_property_add_const_link(Object *obj, const char *name, > + Object *target, Error **errp) > +{ > + char *link_type; > + ObjectProperty *op; > + git-am complained about trailing whitespace on the line above. (Sorry that's all I can "contribute" now; I'll start using the series for developing OVMF further on.) Thanks Laszlo > + link_type = g_strdup_printf("link<%s>", object_get_typename(target)); > + op = object_property_add(obj, name, link_type, > + object_get_child_property, NULL, > + NULL, target, errp); > + if (op != NULL) { > + op->resolve = object_resolve_child_property; > + } > + g_free(link_type); > +} > + > gchar *object_get_canonical_path_component(Object *obj) > { > ObjectProperty *prop = NULL; >