aboutsummaryrefslogtreecommitdiff
path: root/hw/block/virtio-blk.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-02-14 18:51:03 +0100
committerKevin Wolf <kwolf@redhat.com>2019-02-25 15:03:19 +0100
commit680f200217748e0920b79ec1d524717c2f50935b (patch)
treece5268b35f4b9878908c78c5e4e5f1a950b99813 /hw/block/virtio-blk.c
parentc90e2a9cfd94bd02d92c53b97f04fd595001de7e (diff)
downloadqemu-680f200217748e0920b79ec1d524717c2f50935b.zip
qemu-680f200217748e0920b79ec1d524717c2f50935b.tar.gz
qemu-680f200217748e0920b79ec1d524717c2f50935b.tar.bz2
virtio-blk: Increase in_flight for request restart BH
virtio_blk_dma_restart_bh() submits new requests, so in order to make sure that these requests are not started inside a drained section of the attached BlockBackend, we need to make sure that draining the BlockBackend waits for the BH to be executed. This BH is still questionable because its scheduled in the main thread instead of the configured iothread. Leave a FIXME comment for this. But with this fix, enabling the data plane at least waits for these requests (in bdrv_set_aio_context()) instead of changing the AioContext under their feet and making them run in the wrong thread, causing crashes and failures (e.g. due to missing locking). Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/block/virtio-blk.c')
-rw-r--r--hw/block/virtio-blk.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index cf7f47e..e11e6e4 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -675,6 +675,7 @@ static void virtio_blk_dma_restart_bh(void *opaque)
if (mrb.num_reqs) {
virtio_blk_submit_multireq(s->blk, &mrb);
}
+ blk_dec_in_flight(s->conf.conf.blk);
aio_context_release(blk_get_aio_context(s->conf.conf.blk));
}
@@ -688,8 +689,11 @@ static void virtio_blk_dma_restart_cb(void *opaque, int running,
}
if (!s->bh) {
+ /* FIXME The data plane is not started yet, so these requests are
+ * processed in the main thread. */
s->bh = aio_bh_new(blk_get_aio_context(s->conf.conf.blk),
virtio_blk_dma_restart_bh, s);
+ blk_inc_in_flight(s->conf.conf.blk);
qemu_bh_schedule(s->bh);
}
}