qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org
Cc: "Alexander Graf" <agraf@suse.de>, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] qom: Make object_child_foreach safe for objects removal
Date: Mon, 14 Jul 2014 10:14:37 +0200	[thread overview]
Message-ID: <53C3916D.7030809@redhat.com> (raw)
In-Reply-To: <1405262468-8391-1-git-send-email-aik@ozlabs.ru>

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 <aik@ozlabs.ru>
> ---
>
> 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) {
>

The patch is certainly okay, do you need it in 2.1?

Paolo

  parent reply	other threads:[~2014-07-14  8:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 14:41 [Qemu-devel] [PATCH] qom: Make object_child_foreach safe for objects removal Alexey Kardashevskiy
2014-07-14  3:08 ` Hu Tao
2014-07-14  8:14 ` Paolo Bonzini [this message]
2014-07-14 13:12   ` Alexey Kardashevskiy
2014-07-14 15:22     ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53C3916D.7030809@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).