From: Kevin Wolf Date: Wed, 11 Apr 2012 09:06:37 +0000 (+0200) Subject: block: Drain requests in bdrv_close X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1405^2~17^2~582^2~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7094f12f868fc1b75b105bcc676e15964dab77af;p=sdk%2Femulator%2Fqemu.git block: Drain requests in bdrv_close 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 Reviewed-by: Paolo Bonzini --- diff --git a/block.c b/block.c index c0c90f061b..4b96654e7d 100644 --- 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; }