diff --git a/blockdev.c b/blockdev.c index 40fc5d624fcb023e05ab41953b81db2061200393..741df9805fac31709f6a190b06cda51b4651981d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -115,14 +115,21 @@ void blockdev_mark_auto_del(BlockBackend *blk) { DriveInfo *dinfo = blk_legacy_dinfo(blk); BlockDriverState *bs = blk_bs(blk); + AioContext *aio_context; if (!dinfo) { return; } + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + if (bs->job) { block_job_cancel(bs->job); } + + aio_context_release(aio_context); + dinfo->auto_del = 1; }