virtio-blk: Add blk_drain() to virtio_blk_device_unrealize()
authorJulia Suvorova <jusual@redhat.com>
Fri, 18 Oct 2019 14:28:56 +0000 (16:28 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 25 Oct 2019 12:38:24 +0000 (14:38 +0200)
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>
Message-Id: <20191018142856.31870-1-jusual@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw/block/virtio-blk.c

index ed2ddebd2bc124b86a62e83ec12c0b55c1c56bd2..14e9f85b8b7ef1dddde060733f23e9afcba69699 100644 (file)
@@ -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);