summaryrefslogtreecommitdiffstats
path: root/blockdev.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2014-10-21 12:03:52 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2014-11-03 11:41:49 +0000
commit91fddb0db6fee207ccdcca22dd996cf0154a1004 (patch)
treea73cea9d59df57c54d5fd73a6287c7b1e187dd4c /blockdev.c
parent69691e72708603592b1618f1a68d2a3f07db853d (diff)
downloadhqemu-91fddb0db6fee207ccdcca22dd996cf0154a1004.zip
hqemu-91fddb0db6fee207ccdcca22dd996cf0154a1004.tar.gz
blockdev: acquire AioContext in blockdev_mark_auto_del()
When an emulated storage controller is unrealized it will call blockdev_mark_auto_del(). This will cancel any running block job (and that eventually releases its reference to the BDS so it can be freed). Since the block job may be executing in another AioContext we must acquire/release to ensure thread safety. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 1413889440-32577-4-git-send-email-stefanha@redhat.com
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c
index 40fc5d6..741df98 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;
}
OpenPOWER on IntegriCloud