[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/29] block: acquire AioContext in qmp_block_resize(
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/29] block: acquire AioContext in qmp_block_resize() |
Date: |
Fri, 22 Aug 2014 16:51:37 +0200 |
From: Stefan Hajnoczi <address@hidden>
Make block_resize safe for dataplane where another thread may be running
the BlockDriverState's AioContext.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 8acd264..6a204c6 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1799,6 +1799,7 @@ void qmp_block_resize(bool has_device, const char *device,
{
Error *local_err = NULL;
BlockDriverState *bs;
+ AioContext *aio_context;
int ret;
bs = bdrv_lookup_bs(has_device ? device : NULL,
@@ -1809,19 +1810,22 @@ void qmp_block_resize(bool has_device, const char
*device,
return;
}
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
if (!bdrv_is_first_non_filter(bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "resize");
- return;
+ goto out;
}
if (size < 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
- return;
+ goto out;
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
- return;
+ goto out;
}
/* complete all in-flight operations before resizing the device */
@@ -1847,6 +1851,9 @@ void qmp_block_resize(bool has_device, const char *device,
error_setg_errno(errp, -ret, "Could not resize");
break;
}
+
+out:
+ aio_context_release(aio_context);
}
static void block_job_cb(void *opaque, int ret)
--
1.8.3.1
- [Qemu-devel] [PULL 05/29] runner: Add an argument for test duration, (continued)
- [Qemu-devel] [PULL 05/29] runner: Add an argument for test duration, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 04/29] block: Drop some superfluous casts from void *, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 06/29] runner: Kill a program under test by time-out, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 08/29] qcow2: Use g_try_new0() for cache array, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 07/29] qcow2: Constant cache size in bytes, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 10/29] iotests: Add test for qcow2's cache options, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 09/29] qcow2: Add runtime options for cache sizes, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 11/29] test-coroutine: test cost introduced by coroutine, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 12/29] qemu-iotests: Fix 028 reference output for qed, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 14/29] virtio-blk: allow block_resize with dataplane, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 13/29] block: acquire AioContext in qmp_block_resize(),
Kevin Wolf <=
- [Qemu-devel] [PULL 15/29] virtio-blk: fix reference a pointer which might be freed, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 17/29] blkdebug: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 16/29] block: Add bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 18/29] blkverify: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 19/29] nbd: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 21/29] iotests: Add test for image filename construction, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 22/29] block/vvfat.c: remove debugging code to reinit stderr if NULL, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 20/29] quorum: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 24/29] raw-posix: fix O_DIRECT short reads, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 23/29] block/iscsi: fix memory corruption on iscsi resize, Kevin Wolf, 2014/08/22