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