From patchwork Wed Jun 11 16:49:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 358805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8FE5B14007E for ; Thu, 12 Jun 2014 02:51:57 +1000 (EST) Received: from localhost ([::1]:48536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wulkh-0008LT-Hd for incoming@patchwork.ozlabs.org; Wed, 11 Jun 2014 12:51:55 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4QWnYR2bSKhjH+qzPomplIoI2I+yuJXcqkPCayWbaZc=; b=LABmb2Fx24HyYW3AAuJbIY7aUSGbaNvQzlwNIPfWNfowevdXblpZ465XsjtVkkoiHq xIWpugbNH/MKNYad9xRufzdvRngYQRn6L43mKDR+pKzi9GavYRj5tBm/Puc71z10UjpP lJwnyBtNSt8YHYKzlitF8opuIcltowzEmzHux16p2mzgQIl4d+TYLYbUd7C3DViSyjoJ bjhxpCzYO+HMbh84HYPjzKl0urg3I35KcKNGy09HGyR/9eSpMf1vqO85dbwKdRdKcwmd /rc1xxzt9qAmsZl4eVgimzG+l/FRdbsBPq2pGChnhLSOu+Z1h29UK9IsG7HGFL1Ku/wn ZbFA== X-Received: by 10.194.176.37 with SMTP id cf5mr26817677wjc.79.1402505378810; Wed, 11 Jun 2014 09:49:38 -0700 (PDT) Received: from playground.station (net-37-117-132-7.cust.vodafonedsl.it. [37.117.132.7]) by mx.google.com with ESMTPSA id m2sm60433375eey.36.2014.06.11.09.49.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 09:49:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 11 Jun 2014 18:49:27 +0200 Message-Id: <1402505369-12526-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1402505369-12526-1-git-send-email-pbonzini@redhat.com> References: <1402505369-12526-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::233 Cc: mtosatti@redhat.com, afaerber@suse.de, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 3/5] qom: allow creating an alias of a child<> property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Peter Crosthwaite --- 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)