From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlXTx-00082Y-A5 for qemu-devel@nongnu.org; Fri, 24 Apr 2015 02:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlXTs-0005EC-GR for qemu-devel@nongnu.org; Fri, 24 Apr 2015 02:53:01 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:43961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlXTr-0005Do-RT for qemu-devel@nongnu.org; Fri, 24 Apr 2015 02:52:56 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 24 Apr 2015 16:52:53 +1000 From: Bharata B Rao Date: Fri, 24 Apr 2015 12:17:38 +0530 Message-Id: <1429858066-12088-17-git-send-email-bharata@linux.vnet.ibm.com> In-Reply-To: <1429858066-12088-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1429858066-12088-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC PATCH v3 16/24] qom: Introduce object_has_no_children() API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, Bharata B Rao , mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au 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 --- 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