]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qom: accept any compatible type when setting a link property
authorAnthony Liguori <aliguori@us.ibm.com>
Fri, 23 Dec 2011 14:35:43 +0000 (08:35 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 3 Feb 2012 16:41:08 +0000 (10:41 -0600)
Links had limited utility before as they only allowed a concrete type to be
specified.  Now we can support abstract types and interfaces which means it's
now possible to have a link<PCIDevice>.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom/object.c

index 2506d78e684bb2c2614959ccc4418663dcb12a18..49addefd62fcc00d306156e4eeada908a97e0161 100644 (file)
@@ -735,11 +735,12 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,
         if (target) {
             gchar *target_type;
 
-            target_type = g_strdup_printf("link<%s>",
-                                          object_get_typename(OBJECT(target)));
-            if (strcmp(target_type, type) == 0) {
-                *child = target;
+            target_type = g_strdup(&type[5]);
+            target_type[strlen(target_type) - 2] = 0;
+
+            if (object_dynamic_cast(target, target_type)) {
                 object_ref(target);
+                *child = target;
             } else {
                 error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, type);
             }