From patchwork Fri Oct 12 01:50:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 10637709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05569112B for ; Fri, 12 Oct 2018 01:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E693C2C374 for ; Fri, 12 Oct 2018 01:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAC5B2C42D; Fri, 12 Oct 2018 01:51:43 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 7B4082C42A for ; Fri, 12 Oct 2018 01:51:43 +0000 (UTC) Received: from localhost ([::1]:37910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAmcA-0000EN-RM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Oct 2018 21:51:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAmb8-00085d-Fz for qemu-devel@nongnu.org; Thu, 11 Oct 2018 21:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAmb5-0004c1-6R for qemu-devel@nongnu.org; Thu, 11 Oct 2018 21:50:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAmb4-0004al-Lj for qemu-devel@nongnu.org; Thu, 11 Oct 2018 21:50:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1081332B66B; Fri, 12 Oct 2018 01:50:32 +0000 (UTC) Received: from magic.redhat.com (ovpn-12-86.pek2.redhat.com [10.72.12.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1CD982F54; Fri, 12 Oct 2018 01:50:30 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2018 09:50:25 +0800 Message-Id: <20181012015026.17441-2-famz@redhat.com> In-Reply-To: <20181012015026.17441-1-famz@redhat.com> References: <20181012015026.17441-1-famz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 12 Oct 2018 01:50:32 +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] [PULL 1/2] iothread: fix crash with invalid properties 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau -object iothread,id=foo,? will crash qemu: qemu-system-x86_64:qemu-thread-posix.c:128: qemu_cond_destroy: Assertion `cond->initialized' failed. Use thread_id != -1 to check if iothread_complete() finished successfully and the mutex/cond have been initialized. Signed-off-by: Marc-André Lureau Message-Id: <20180821100716.13803-1-marcandre.lureau@redhat.com> Signed-off-by: Fam Zheng --- iothread.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iothread.c b/iothread.c index aff1281257..2fb1cdf55d 100644 --- a/iothread.c +++ b/iothread.c @@ -110,6 +110,7 @@ static void iothread_instance_init(Object *obj) IOThread *iothread = IOTHREAD(obj); iothread->poll_max_ns = IOTHREAD_POLL_MAX_NS_DEFAULT; + iothread->thread_id = -1; } static void iothread_instance_finalize(Object *obj) @@ -117,6 +118,11 @@ static void iothread_instance_finalize(Object *obj) IOThread *iothread = IOTHREAD(obj); iothread_stop(iothread); + + if (iothread->thread_id != -1) { + qemu_cond_destroy(&iothread->init_done_cond); + qemu_mutex_destroy(&iothread->init_done_lock); + } /* * Before glib2 2.33.10, there is a glib2 bug that GSource context * pointer may not be cleared even if the context has already been @@ -135,8 +141,6 @@ static void iothread_instance_finalize(Object *obj) g_main_context_unref(iothread->worker_context); iothread->worker_context = NULL; } - qemu_cond_destroy(&iothread->init_done_cond); - qemu_mutex_destroy(&iothread->init_done_lock); } static void iothread_complete(UserCreatable *obj, Error **errp) @@ -147,7 +151,6 @@ static void iothread_complete(UserCreatable *obj, Error **errp) iothread->stopping = false; iothread->running = true; - iothread->thread_id = -1; iothread->ctx = aio_context_new(&local_error); if (!iothread->ctx) { error_propagate(errp, local_error); From patchwork Fri Oct 12 01:50:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 10637711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86D403CF1 for ; Fri, 12 Oct 2018 01:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74A232C420 for ; Fri, 12 Oct 2018 01:51:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 696502C42C; Fri, 12 Oct 2018 01:51:44 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 7B2FE2C429 for ; Fri, 12 Oct 2018 01:51:43 +0000 (UTC) Received: from localhost ([::1]:37909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAmcA-0000E0-F8 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Oct 2018 21:51:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAmb8-00085e-G1 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 21:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAmb5-0004cG-E9 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 21:50:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAmb5-0004bU-5x for qemu-devel@nongnu.org; Thu, 11 Oct 2018 21:50:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCF423082E71; Fri, 12 Oct 2018 01:50:33 +0000 (UTC) Received: from magic.redhat.com (ovpn-12-86.pek2.redhat.com [10.72.12.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91D9F82F54; Fri, 12 Oct 2018 01:50:32 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2018 09:50:26 +0800 Message-Id: <20181012015026.17441-3-famz@redhat.com> In-Reply-To: <20181012015026.17441-1-famz@redhat.com> References: <20181012015026.17441-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 12 Oct 2018 01:50:33 +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] [PULL 2/2] nvme: correct locking around completion 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event. Signed-off-by: Paolo Bonzini Message-Id: <20180814062739.19640-1-pbonzini@redhat.com> Signed-off-by: Fam Zheng --- block/nvme.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 781d77d6d2..29294038fc 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n) BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier); trace_nvme_handle_event(s); - aio_context_acquire(s->aio_context); event_notifier_test_and_clear(n); nvme_poll_queues(s); - aio_context_release(s->aio_context); } static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)