]> git.ipfire.org Git - thirdparty/qemu.git/commit
iothread: Stop threads before main() quits
authorFam Zheng <famz@redhat.com>
Thu, 8 Sep 2016 09:28:51 +0000 (17:28 +0800)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 20 Sep 2016 16:38:26 +0000 (11:38 -0500)
commit12664c5a1c1d9e75c36db2bde258c69c25d6c1ff
treee24a306ed7f1ec82873f2e24a508f34db7532d10
parentd90481343f93581ab6f3415ee35663cc8f2da1f5
iothread: Stop threads before main() quits

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().

Cc: qemu-stable@nongnu.org
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1473326931-9699-1-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit dce8921b2baaf95974af8176406881872067adfa)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
include/sysemu/iothread.h
iothread.c
vl.c