From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wulih-0004mx-60 for qemu-devel@nongnu.org; Wed, 11 Jun 2014 12:50:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuliW-0002Zd-EH for qemu-devel@nongnu.org; Wed, 11 Jun 2014 12:49:51 -0400 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:35675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuliW-0002ZF-7n for qemu-devel@nongnu.org; Wed, 11 Jun 2014 12:49:40 -0400 Received: by mail-wg0-f51.google.com with SMTP id x12so3242wgg.34 for ; Wed, 11 Jun 2014 09:49:38 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 11 Jun 2014 18:49:27 +0200 Message-Id: <1402505369-12526-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1402505369-12526-1-git-send-email-pbonzini@redhat.com> References: <1402505369-12526-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/5] qom: allow creating an alias of a child<> property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mtosatti@redhat.com, afaerber@suse.de, stefanha@redhat.com An object must have a single parent, so creating an alias of a child<> property breaks assumptions about objects having a single canonical path. Fix this problem by turning these aliases into links. Signed-off-by: Paolo Bonzini --- qom/object.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index e146ae5..ddf781e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1575,22 +1575,31 @@ void object_property_add_alias(Object *obj, const char *name, { AliasProperty *prop; ObjectProperty *target_prop; + gchar *prop_type; target_prop = object_property_find(target_obj, target_name, errp); if (!target_prop) { return; } + if (object_property_is_child(target_prop)) { + prop_type = g_strdup_printf("link%s", target_prop->type + 5); + } else { + prop_type = g_strdup(target_prop->type); + } + prop = g_malloc(sizeof(*prop)); prop->target_obj = target_obj; prop->target_name = target_name; - object_property_add_full(obj, name, target_prop->type, + object_property_add_full(obj, name, prop_type, property_get_alias, property_set_alias, property_resolve_alias, property_release_alias, prop, errp); + + g_free(prop_type); } static void object_instance_init(Object *obj) -- 1.8.3.1