From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Andrey Korolyov <andrey@xdel.ru>,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] block: acquire AioContext in qmp_block_resize()
Date: Mon, 18 Aug 2014 14:52:28 +0100 [thread overview]
Message-ID: <1408369949-3128-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1408369949-3128-1-git-send-email-stefanha@redhat.com>
Make block_resize safe for dataplane where another thread may be running
the BlockDriverState's AioContext.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
blockdev.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 48bd9a3..197b799 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.9.3
next prev parent reply other threads:[~2014-08-18 13:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-18 13:52 [Qemu-devel] [PATCH 0/2] block: support block_resize with dataplane Stefan Hajnoczi
2014-08-18 13:52 ` Stefan Hajnoczi [this message]
2014-08-18 15:54 ` [Qemu-devel] [PATCH 1/2] block: acquire AioContext in qmp_block_resize() Max Reitz
2014-08-18 13:52 ` [Qemu-devel] [PATCH 2/2] virtio-blk: allow block_resize with dataplane Stefan Hajnoczi
2014-08-18 15:54 ` Max Reitz
2014-08-20 9:54 ` [Qemu-devel] [PATCH 0/2] block: support " Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408369949-3128-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=andrey@xdel.ru \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).