From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuQpJ-0000nN-In for qemu-devel@nongnu.org; Tue, 10 Jun 2014 14:31:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuQpA-00074H-HO for qemu-devel@nongnu.org; Tue, 10 Jun 2014 14:31:17 -0400 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:38993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuQpA-000743-AP for qemu-devel@nongnu.org; Tue, 10 Jun 2014 14:31:08 -0400 Received: by mail-wg0-f45.google.com with SMTP id l18so1964660wgh.16 for ; Tue, 10 Jun 2014 11:31:07 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53974EE7.7090000@redhat.com> Date: Tue, 10 Jun 2014 20:31:03 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1401967435-17751-1-git-send-email-pbonzini@redhat.com> <1401967435-17751-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1401967435-17751-3-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] qom: add object_property_add_alias List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.crosthwaite@xilinx.com, mtosatti@redhat.com, afaerber@suse.de Il 05/06/2014 13:23, Paolo Bonzini ha scritto: > Similar to object_property_add_link, alias properties provide an > alternative, non-canonical path to an object. In fact, external > observers cannot distinguish alias properties from other links. > > Aliases differ from links in that they are immutable and typically > managed by the target of the alias in order to add a link to itself > at a well-known location. For example, a real-time clock device might > add a link to itself at "/machine/rtc". Such well-known locations can > then expose a standard set of properties that can be accessed via the > "qom-get" and "qom-set" commands. Heh, another object_property_add_alias is in flight (from Stefan, for dataplane). Luckily it is possible to share the more generic alias property implementation for object aliases too, with just an extra NULL argument before the Error**. I'll post the patches as soon as Andreas comes back. Paolo > +void object_property_add_alias(Object *obj, const char *name, > + Object *dest, Error **errp); > + > typedef enum { > /* Unref the link pointer when the property is deleted */ > OBJ_PROP_LINK_UNREF_ON_RELEASE = 0x1, > diff --git a/qom/object.c b/qom/object.c > index fcdd0da..46d60c8 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -1036,6 +1036,19 @@ out: > g_free(type); > } > > +void object_property_add_alias(Object *obj, const char *name, > + Object *dest, Error **errp) > +{ > + gchar *type; > + > + type = g_strdup_printf("link<%s>", object_get_typename(OBJECT(dest))); > + > + object_property_add_full(obj, name, type, object_get_child_property, NULL, > + object_resolve_child_property, > + NULL, dest, errp); > + g_free(type); > +} > + > void object_property_allow_set_link(Object *obj, const char *name, > Object *val, Error **errp) > { >