[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 7/7] blockdev: acquire AioContext in hmp_commit()
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 7/7] blockdev: acquire AioContext in hmp_commit() |
Date: |
Fri, 6 Nov 2015 17:52:29 +0000 |
This one slipped through. Although we acquire AioContext when
committing all devices we don't for just a single device.
AioContext must be acquired before calling bdrv_*() functions to
synchronize access with other threads that may be using the AioContext.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
blockdev.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 8b8bfa9..97be42f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1120,6 +1120,9 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
if (!strcmp(device, "all")) {
ret = bdrv_commit_all();
} else {
+ BlockDriverState *bs;
+ AioContext *aio_context;
+
blk = blk_by_name(device);
if (!blk) {
monitor_printf(mon, "Device '%s' not found\n", device);
@@ -1129,7 +1132,14 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "Device '%s' has no medium\n", device);
return;
}
- ret = bdrv_commit(blk_bs(blk));
+
+ bs = blk_bs(blk);
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
+ ret = bdrv_commit(bs);
+
+ aio_context_release(aio_context);
}
if (ret < 0) {
monitor_printf(mon, "'commit' error for '%s': %s\n", device,
--
2.5.0
- [Qemu-devel] [PULL 0/7] Block patches, Stefan Hajnoczi, 2015/11/06
- [Qemu-devel] [PULL 1/7] dataplane: simplify indirect descriptor read, Stefan Hajnoczi, 2015/11/06
- [Qemu-devel] [PULL 2/7] dataplane: support non-contigious s/g, Stefan Hajnoczi, 2015/11/06
- [Qemu-devel] [PULL 3/7] aio: Introduce aio_external_disabled, Stefan Hajnoczi, 2015/11/06
- [Qemu-devel] [PULL 4/7] aio: Introduce aio_context_setup, Stefan Hajnoczi, 2015/11/06
- [Qemu-devel] [PULL 5/7] aio: Introduce aio-epoll.c, Stefan Hajnoczi, 2015/11/06
- [Qemu-devel] [PULL 7/7] blockdev: acquire AioContext in hmp_commit(),
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 6/7] monitor: add missed aio_context_acquire into vm_completion call, Stefan Hajnoczi, 2015/11/06
- Re: [Qemu-devel] [PULL 0/7] Block patches, Peter Maydell, 2015/11/06