qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-ppc] [RFC PATCH v3 16/24] qom: Introduce object_has_no_children()


From: Bharata B Rao
Subject: [Qemu-ppc] [RFC PATCH v3 16/24] qom: Introduce object_has_no_children() API
Date: Fri, 24 Apr 2015 12:17:38 +0530

This QOM API can be used to check of an object has any child objects
associated with it.

Needed by PowerPC CPU hotplug code to release parent CPU core and
socket objects only after ascertaining that they don't have any child
objects.

Signed-off-by: Bharata B Rao <address@hidden>
---
 include/qom/object.h | 11 +++++++++++
 qom/object.c         | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index d2d7748..264e412 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1317,6 +1317,17 @@ int object_child_foreach(Object *obj, int (*fn)(Object 
*child, void *opaque),
                          void *opaque);
 
 /**
+ * object_has_no_children:
+ * @obj: the object which will be checked for children
+ *
+ * Navigate the properties list of the @obj and check for any child
+ * property.
+ *
+ * Returns: true if no child properties are found, else returns false.
+ */
+bool object_has_no_children(Object *obj);
+
+/**
  * container_get:
  * @root: root of the #path, e.g., object_get_root()
  * @path: path to the container
diff --git a/qom/object.c b/qom/object.c
index d167038..0fddf00 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -683,6 +683,18 @@ int object_child_foreach(Object *obj, int (*fn)(Object 
*child, void *opaque),
     return ret;
 }
 
+bool object_has_no_children(Object *obj)
+{
+    ObjectProperty *prop;
+
+    QTAILQ_FOREACH(prop, &obj->properties, node) {
+        if (object_property_is_child(prop)) {
+            return false;
+        }
+    }
+    return true;
+}
+
 static void object_class_get_list_tramp(ObjectClass *klass, void *opaque)
 {
     GSList **list = opaque;
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]