All AIOs including the hanging AIOs need to be drained when resetting
virtio-blk. So it is necessary to disable I/O hang before resetting
and enable I/O hang again after resetting if I/O hang is enabled.
Signed-off-by: Ying Fang <fangying1@huawei.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
---
hw/block/virtio-blk.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 2204ba149e..11837a54f5 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -892,6 +892,10 @@ static void virtio_blk_reset(VirtIODevice *vdev)
AioContext *ctx;
VirtIOBlockReq *req;
+ if (blk_iohang_is_enabled(s->blk)) {
+ blk_rehandle_disable(s->blk);
+ }
+
ctx = blk_get_aio_context(s->blk);
aio_context_acquire(ctx);
blk_drain(s->blk);
@@ -909,6 +913,10 @@ static void virtio_blk_reset(VirtIODevice *vdev)
assert(!s->dataplane_started);
blk_set_enable_write_cache(s->blk, s->original_wce);
+
+ if (blk_iohang_is_enabled(s->blk)) {
+ blk_rehandle_enable(s->blk);
+ }
}
/* coalesce internal state, copy to pci i/o region 0
--
2.23.0