When resetting virtio-blk, we have to drain all AIOs but do not care about the results. So it is necessary to disable I/O hang before resetting virtio-blk, and enable it after resetting.
Signed-off-by: Jiahui Cen <cenjia...@huawei.com> Signed-off-by: Ying Fang <fangyi...@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 bac2d6fa2b..f96e4ac274 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -899,6 +899,10 @@ static void virtio_blk_reset(VirtIODevice *vdev) AioContext *ctx; VirtIOBlockReq *req; + if (blk_iohang_is_enabled(s->blk)) { + blk_rehandle_pause(s->blk); + } + ctx = blk_get_aio_context(s->blk); aio_context_acquire(ctx); blk_drain(s->blk); @@ -916,6 +920,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_unpause(s->blk); + } } /* coalesce internal state, copy to pci i/o region 0 -- 2.28.0