aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-04-11 23:30:20 +0200
committerAndreas Färber <afaerber@suse.de>2012-06-18 15:14:36 +0200
commit32efc535b86626646442de7fe5793f3a47f4ce91 (patch)
tree0bc63c4a030217c49f98d14b5d56fbefccabd4b3 /qom
parent5d9d3f4757897fe5c376e25e944c08f36c412907 (diff)
downloadqemu-32efc535b86626646442de7fe5793f3a47f4ce91.zip
qemu-32efc535b86626646442de7fe5793f3a47f4ce91.tar.gz
qemu-32efc535b86626646442de7fe5793f3a47f4ce91.tar.bz2
qom: Add object_child_foreach()
A utility function that will be used to implement hierarchical realization. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> [AF: Drop unrelated whitespace change, add Returns: in documentation] [AF: Use new object_property_is_child() helper.] Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c
index 105c649..7a70d52 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -607,6 +607,23 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
}
+int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
+ void *opaque)
+{
+ ObjectProperty *prop;
+ int ret = 0;
+
+ QTAILQ_FOREACH(prop, &obj->properties, node) {
+ if (object_property_is_child(prop)) {
+ ret = fn(prop->opaque, opaque);
+ if (ret != 0) {
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
static void object_class_get_list_tramp(ObjectClass *klass, void *opaque)
{
GSList **list = opaque;