From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjjXv-0005Fw-Tv for qemu-devel@nongnu.org; Tue, 13 Sep 2016 04:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjjXr-0006BB-0U for qemu-devel@nongnu.org; Tue, 13 Sep 2016 04:58:27 -0400 Date: Tue, 13 Sep 2016 16:58:19 +0800 From: Fam Zheng Message-ID: <20160913085819.GA22052@lemon> References: <1473326931-9699-1-git-send-email-famz@redhat.com> <20160913083914.GA2710@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160913083914.GA2710@stefanha-x1.localdomain> Subject: Re: [Qemu-devel] [PATCH] iothread: Stop threads before main() quits List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Paolo Bonzini , qemu-stable@nongnu.org On Tue, 09/13 09:39, Stefan Hajnoczi wrote: > On Thu, Sep 08, 2016 at 05:28:51PM +0800, Fam Zheng wrote: > > Right after main_loop ends, we release various things but keep iothread > > alive. The latter is not prepared to the sudden change of resources. > > > > Specifically, after bdrv_close_all(), virtio-scsi dataplane get a > > surprise at the empty BlockBackend: > > > > (gdb) bt > > at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:543 > > at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:577 > > > > It is because the d->conf.blk->root is set to NULL, then > > blk_get_aio_context() returns qemu_aio_context, whereas s->ctx is still > > pointing to the iothread: > > > > hw/scsi/virtio-scsi.c:543: > > > > if (s->dataplane_started) { > > assert(blk_get_aio_context(d->conf.blk) == s->ctx); > > } > > > > To fix this, let's stop iothreads before doing bdrv_close_all(). > > Did you consider blk_add_remove_bs_notifier()? It gets called during > bdrv_close_all() and would let virtio-scsi survive any other case where > the same thing happens. There is already another case (eject): https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg02243.html And I don't know how to fix it with blk_add_remove_bs_notifier. Could you elaborate? Fam