[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/22] qom: accept any compatible type when setting
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 18/22] qom: accept any compatible type when setting a link property |
Date: |
Wed, 1 Feb 2012 13:50:59 -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 <address@hidden>
---
qom/object.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 2506d78..49addef 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);
}
--
1.7.4.1
- [Qemu-devel] [PATCH 20/22] info qdm: do not require a parent_bus to be set, (continued)
- [Qemu-devel] [PATCH 20/22] info qdm: do not require a parent_bus to be set, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 21/22] object: sure up reference counting, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 09/22] qdev: register all types natively through QEMU Object Model, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 22/22] container: make a decendent of Object, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 19/22] qdev: implement cleanup logic in finalize, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 14/22] qdev: refactor away qdev_create_from_info, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 13/22] qdev: split out common init to instance_init, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 18/22] qom: accept any compatible type when setting a link property,
Anthony Liguori <=
- Re: [Qemu-devel] [PATCH 00/22] qom: use Type system to register all devices (v2), Anthony Liguori, 2012/02/03