From patchwork Mon Jul 25 12:47:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 9245573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81EF2607D3 for ; Mon, 25 Jul 2016 12:47:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 722E72705B for ; Mon, 25 Jul 2016 12:47:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6687D27813; Mon, 25 Jul 2016 12:47:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E1ED2705B for ; Mon, 25 Jul 2016 12:47:54 +0000 (UTC) Received: from localhost ([::1]:60425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRfIX-0001yU-5s for patchwork-qemu-devel@patchwork.kernel.org; Mon, 25 Jul 2016 08:47:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRfI6-0001xO-Eb for qemu-devel@nongnu.org; Mon, 25 Jul 2016 08:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRfI4-0005x2-FA for qemu-devel@nongnu.org; Mon, 25 Jul 2016 08:47:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46768) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRfHy-0005wG-Pv; Mon, 25 Jul 2016 08:47:18 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 042086438B; Mon, 25 Jul 2016 12:47:18 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6PClFIR013976; Mon, 25 Jul 2016 08:47:15 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 25 Jul 2016 14:47:12 +0200 Message-Id: <1469450832-84343-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 25 Jul 2016 12:47:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.8] qtail: clean up direct access to tqe_prev field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "open list:Block layer core" , Peter Crosthwaite , Jason Wang , Markus Armbruster , Max Reitz , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);