summary refs log tree commit diff stats
path: root/include/sysemu/iothread.h
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2016-09-08 17:28:51 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2016-09-13 11:00:57 +0100
commitdce8921b2baaf95974af8176406881872067adfa (patch)
treee5bbd415db55d1ceb20e5f1f7f8d55ff5dc8a194 /include/sysemu/iothread.h
parente49f827725d53d2fb1b8ec42db96c442d0caf6cd (diff)
downloadfocaccia-qemu-dce8921b2baaf95974af8176406881872067adfa.tar.gz
focaccia-qemu-dce8921b2baaf95974af8176406881872067adfa.zip
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>
Diffstat (limited to 'include/sysemu/iothread.h')
-rw-r--r--include/sysemu/iothread.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
index 2eefea1cc2..68ac2de83a 100644
--- a/include/sysemu/iothread.h
+++ b/include/sysemu/iothread.h
@@ -35,5 +35,6 @@ typedef struct {
 
 char *iothread_get_id(IOThread *iothread);
 AioContext *iothread_get_aio_context(IOThread *iothread);
+void iothread_stop_all(void);
 
 #endif /* IOTHREAD_H */