qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] qom: Make object_child_foreach safe for objects rem


From: Alexey Kardashevskiy
Subject: [Qemu-devel] [PATCH] qom: Make object_child_foreach safe for objects removal
Date: Mon, 14 Jul 2014 00:41:08 +1000

Current object_child_foreach() uses QTAILQ_FOREACH() to walk
through children and that makes children removal from the callback
impossible.

This makes object_child_foreach() use QTAILQ_FOREACH_SAFE().

Signed-off-by: Alexey Kardashevskiy <address@hidden>
---

The problem I am trying to solve is:
there is a PHB with multiple DMA windows a.k.a. sPAPRTCETable's which are
QOM children of PHB. One of RTAS functions is "reset" which is supposed to
remove all windows (now just one) except the default one.

I could call QTAILQ_FOREACH_SAFE in sPAPR PHB code but 
object_property_is_child()
is static and we probably do not want to make it public.


---
 qom/object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index 0e8267b..4a814dc 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -678,10 +678,10 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, 
void *opaque),
 int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
                          void *opaque)
 {
-    ObjectProperty *prop;
+    ObjectProperty *prop, *next;
     int ret = 0;
 
-    QTAILQ_FOREACH(prop, &obj->properties, node) {
+    QTAILQ_FOREACH_SAFE(prop, &obj->properties, node, next) {
         if (object_property_is_child(prop)) {
             ret = fn(prop->opaque, opaque);
             if (ret != 0) {
-- 
2.0.0




reply via email to

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