[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/10] qom: add, remove of link property need to ref
From: |
Liu Ping Fan |
Subject: |
[Qemu-devel] [PATCH 01/10] qom: add, remove of link property need to ref, unref its target |
Date: |
Fri, 24 Aug 2012 17:49:14 +0800 |
From: Liu Ping Fan <address@hidden>
Currently, link property's target is only managed by
object_set_link_property(). This will raise such issue that when
the property is finalized, its target has no opportunity to release.
Fix this issue by introduce object_finalize_link_property()
In correspond, ref target when adding link prpoerty.
Signed-off-by: Liu Ping Fan <address@hidden>
---
qom/object.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index a552be2..00f98d7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -957,6 +957,16 @@ static void object_set_link_property(Object *obj, Visitor
*v, void *opaque,
}
}
+static void object_finalize_link_property(Object *obj, const char *name,
+ void *opaque)
+{
+ Object **child = opaque;
+
+ if (*child != NULL) {
+ object_unref(*child);
+ }
+}
+
void object_property_add_link(Object *obj, const char *name,
const char *type, Object **child,
Error **errp)
@@ -968,8 +978,10 @@ void object_property_add_link(Object *obj, const char
*name,
object_property_add(obj, name, full_type,
object_get_link_property,
object_set_link_property,
- NULL, child, errp);
-
+ object_finalize_link_property, child, errp);
+ if (*child != NULL) {
+ object_ref(*child);
+ }
g_free(full_type);
}
--
1.7.4.4
- [Qemu-devel] [PATCH 0/10] rework on hot unplug, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 01/10] qom: add, remove of link property need to ref, unref its target,
Liu Ping Fan <=
- [Qemu-devel] [PATCH 02/10] qdev: change iterator callback seq, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 03/10] qom: export object_property_is_child, object_property_is_link, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 04/10] qdev: introduce new interface to remove composite sub-tree, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 05/10] qdev: finalize of qbus, qdev will not the right place to free children, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 06/10] qom: expose object_property_del_child, Liu Ping Fan, 2012/08/24