diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-23 08:35:43 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-03 10:41:08 -0600 |
commit | fe40e627c51e38922b64b02b6163aea4b6aad896 (patch) | |
tree | b79dfdbfcbfdb11857b97db2bd11662324315b2f /qom | |
parent | qom: move properties from qdev to object (diff) | |
download | qemu-kvm-fe40e627c51e38922b64b02b6163aea4b6aad896.tar.gz qemu-kvm-fe40e627c51e38922b64b02b6163aea4b6aad896.tar.bz2 qemu-kvm-fe40e627c51e38922b64b02b6163aea4b6aad896.zip |
qom: accept any compatible type when setting a link property
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>
Diffstat (limited to 'qom')
-rw-r--r-- | qom/object.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/qom/object.c b/qom/object.c index 2506d78e6..49addefd6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -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); } |