qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>, qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Richard Henderson <rth@twiddle.net>,
	Jason Wang <jasowang@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH for-2.8] qtail: clean up direct access to tqe_prev field
Date: Mon, 1 Aug 2016 12:05:07 +0200	[thread overview]
Message-ID: <051c17de-51b7-1474-16b5-0b4aa29ea4b8@redhat.com> (raw)
In-Reply-To: <1469450832-84343-1-git-send-email-imammedo@redhat.com>



On 25/07/2016 14:47, Igor Mammedov wrote:
> instead of accessing tqe_prev field dircetly outside
> of queue.h use macros to check if element is in list
> and make sure that afer element is removed from list
> tqe_prev field could be used to do the same check.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> The patch is split from as cleanup is not urgent
>   [PATCH 0/6] Fix migration issues with arbitrary cpu-hot(un)plug
> and made on top of
>   [PATCH v2 0/6] Fix migration issues with arbitrary cpu-hot(un)plug
> 
> posting it to list so that it won't be forgotten or lost
> and affected people could review it at there leisure time.
> 
> ---
>  include/qemu/queue.h | 2 ++
>  blockdev.c           | 2 +-
>  exec.c               | 3 +--
>  net/filter.c         | 2 +-
>  4 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/include/qemu/queue.h b/include/qemu/queue.h
> index c2b6c81..342073f 100644
> --- a/include/qemu/queue.h
> +++ b/include/qemu/queue.h
> @@ -407,6 +407,7 @@ struct {                                                                \
>          else                                                            \
>                  (head)->tqh_last = (elm)->field.tqe_prev;               \
>          *(elm)->field.tqe_prev = (elm)->field.tqe_next;                 \
> +        (elm)->field.tqe_prev = NULL;                                   \
>  } while (/*CONSTCOND*/0)
>  
>  #define QTAILQ_FOREACH(var, head, field)                                \
> @@ -430,6 +431,7 @@ struct {                                                                \
>  #define QTAILQ_EMPTY(head)               ((head)->tqh_first == NULL)
>  #define QTAILQ_FIRST(head)               ((head)->tqh_first)
>  #define QTAILQ_NEXT(elm, field)          ((elm)->field.tqe_next)
> +#define QTAILQ_IN_USE(elm, field)        ((elm)->field.tqe_prev != NULL)
>  
>  #define QTAILQ_LAST(head, headname) \
>          (*(((struct headname *)((head)->tqh_last))->tqh_last))
> diff --git a/blockdev.c b/blockdev.c
> index eafeba9..0b73158 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -4031,7 +4031,7 @@ void qmp_x_blockdev_del(bool has_id, const char *id,
>              goto out;
>          }
>  
> -        if (!blk && !bs->monitor_list.tqe_prev) {
> +        if (!blk && !QTAILQ_IN_USE(bs, monitor_list)) {
>              error_setg(errp, "Node %s is not owned by the monitor",
>                         bs->node_name);
>              goto out;
> diff --git a/exec.c b/exec.c
> index 50e3ee2..8e8416b 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -614,14 +614,13 @@ void cpu_exec_exit(CPUState *cpu)
>      CPUClass *cc = CPU_GET_CLASS(cpu);
>  
>      cpu_list_lock();
> -    if (cpu->node.tqe_prev == NULL) {
> +    if (!QTAILQ_IN_USE(cpu, node)) {
>          /* there is nothing to undo since cpu_exec_init() hasn't been called */
>          cpu_list_unlock();
>          return;
>      }
>  
>      QTAILQ_REMOVE(&cpus, cpu, node);
> -    cpu->node.tqe_prev = NULL;
>      cpu->cpu_index = UNASSIGNED_CPU_INDEX;
>      cpu_list_unlock();
>  
> diff --git a/net/filter.c b/net/filter.c
> index 888fe6d..1dfd2ca 100644
> --- a/net/filter.c
> +++ b/net/filter.c
> @@ -239,7 +239,7 @@ static void netfilter_finalize(Object *obj)
>      }
>  
>      if (nf->netdev && !QTAILQ_EMPTY(&nf->netdev->filters) &&
> -        nf->next.tqe_prev) {
> +        QTAILQ_IN_USE(nf, next)) {
>          QTAILQ_REMOVE(&nf->netdev->filters, nf, next);
>      }
>      g_free(nf->netdev_id);
> 

Looks good, thanks!

Paolo

      reply	other threads:[~2016-08-01 10:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25 12:47 [Qemu-devel] [PATCH for-2.8] qtail: clean up direct access to tqe_prev field Igor Mammedov
2016-08-01 10:05 ` Paolo Bonzini [this message]

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=051c17de-51b7-1474-16b5-0b4aa29ea4b8@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).