diff mbox series

virtio-blk: Add blk_drain() to virtio_blk_device_unrealize()

Message ID 20191018142856.31870-1-jusual@redhat.com (mailing list archive)
State New, archived
Headers show
Series virtio-blk: Add blk_drain() to virtio_blk_device_unrealize() | expand

Commit Message

Julia Suvorova Oct. 18, 2019, 2:28 p.m. UTC
QEMU does not wait for completed I/O requests, assuming that the guest
driver will reset the device before calling unrealize(). This does not
happen on Windows, and QEMU crashes in virtio_notify(), getting the
result of a completed I/O request on hot-unplugged device.

Signed-off-by: Julia Suvorova <jusual@redhat.com>
---
 hw/block/virtio-blk.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stefan Hajnoczi Oct. 21, 2019, 3:17 p.m. UTC | #1
On Fri, Oct 18, 2019 at 04:28:56PM +0200, Julia Suvorova wrote:
> QEMU does not wait for completed I/O requests, assuming that the guest
> driver will reset the device before calling unrealize(). This does not
> happen on Windows, and QEMU crashes in virtio_notify(), getting the
> result of a completed I/O request on hot-unplugged device.
> 
> Signed-off-by: Julia Suvorova <jusual@redhat.com>
> ---
>  hw/block/virtio-blk.c | 1 +
>  1 file changed, 1 insertion(+)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox series

Patch

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index ed2ddebd2b..14e9f85b8b 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1207,6 +1207,7 @@  static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOBlock *s = VIRTIO_BLK(dev);
 
+    blk_drain(s->blk);
     virtio_blk_data_plane_destroy(s->dataplane);
     s->dataplane = NULL;
     qemu_del_vm_change_state_handler(s->change);