@@ -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
@@ -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;
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 <bharata@linux.vnet.ibm.com> --- include/qom/object.h | 11 +++++++++++ qom/object.c | 12 ++++++++++++ 2 files changed, 23 insertions(+)