qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/5] qom: allow creating an alias of a child<> prope


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 3/5] qom: allow creating an alias of a child<> property
Date: Wed, 11 Jun 2014 18:49:27 +0200

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 <address@hidden>
---
 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]