From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6i5L-0004Td-VC for qemu-devel@nongnu.org; Mon, 14 Jul 2014 11:22:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6i5G-0000Yc-2e for qemu-devel@nongnu.org; Mon, 14 Jul 2014 11:22:35 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44333 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6i5F-0000Y2-TH for qemu-devel@nongnu.org; Mon, 14 Jul 2014 11:22:30 -0400 Message-ID: <53C3F5B2.6030102@suse.de> Date: Mon, 14 Jul 2014 17:22:26 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1405262468-8391-1-git-send-email-aik@ozlabs.ru> <53C3916D.7030809@redhat.com> <53C3D744.4020301@ozlabs.ru> In-Reply-To: <53C3D744.4020301@ozlabs.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qom: Make object_child_foreach safe for objects removal List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy , Paolo Bonzini , qemu-devel@nongnu.org Cc: Hu Tao , Alexander Graf Am 14.07.2014 15:12, schrieb Alexey Kardashevskiy: > On 07/14/2014 06:14 PM, Paolo Bonzini wrote: >> Il 13/07/2014 16:41, Alexey Kardashevskiy ha scritto: >>> 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 >>> --- >>> >>> 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 suppos= ed 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)(ObjectClas= s >>> *klass, void *opaque), >>> int object_child_foreach(Object *obj, int (*fn)(Object *child, void >>> *opaque), >>> void *opaque) >>> { >>> - ObjectProperty *prop; >>> + ObjectProperty *prop, *next; >>> int ret =3D 0; >>> >>> - QTAILQ_FOREACH(prop, &obj->properties, node) { >>> + QTAILQ_FOREACH_SAFE(prop, &obj->properties, node, next) { >>> if (object_property_is_child(prop)) { >>> ret =3D fn(prop->opaque, opaque); >>> if (ret !=3D 0) { >>> >> >> The patch is certainly okay, do you need it in 2.1? >=20 >=20 > Nope, I will need it for dynamic DMA windows (VFIO, PPC) which are not = for > 2.1 for sure. Thanks, applied to qom-next so that it doesn't get forgotten. https://github.com/afaerber/qemu-cpu/commits/qom-next Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg