]> git.proxmox.com Git - qemu.git/commitdiff
block: Drain requests in bdrv_close
authorKevin Wolf <kwolf@redhat.com>
Wed, 11 Apr 2012 09:06:37 +0000 (11:06 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 19 Apr 2012 13:48:52 +0000 (15:48 +0200)
If an AIO request is in flight that refers to a BlockDriverState that
has been closed and possibly even freed, more or less anything could
happen. I have seen segfaults, -EBADF return values and qcow2 sometimes
actually catches the situation in bdrv_close() and abort()s.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
block.c

diff --git a/block.c b/block.c
index c0c90f061b82445212fcc1c90130d34079fda387..4b96654e7d6264a32b393a929c47be3edba2c156 100644 (file)
--- a/block.c
+++ b/block.c
@@ -816,6 +816,8 @@ void bdrv_close(BlockDriverState *bs)
         if (bs->job) {
             block_job_cancel_sync(bs->job);
         }
+        bdrv_drain_all();
+
         if (bs == bs_snapshots) {
             bs_snapshots = NULL;
         }