pve-qemu-qoup/debian/patches/pve/0020-block-snapshot-qmp_snapshot_drive-add-aiocontext.patch
2017-09-08 09:44:31 +02:00

66 lines
1.8 KiB
Diff

From dccd9887366b5df7eeb8394cc0476536ebc8dd45 Mon Sep 17 00:00:00 2001
From: Alexandre Derumier <aderumier@odiso.com>
Date: Tue, 13 Sep 2016 01:57:56 +0200
Subject: [PATCH 20/28] block: snapshot: qmp_snapshot_drive: add aiocontext
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
savevm-async.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/savevm-async.c b/savevm-async.c
index 97d51d3edd..ece193a065 100644
--- a/savevm-async.c
+++ b/savevm-async.c
@@ -377,6 +377,7 @@ void qmp_snapshot_drive(const char *device, const char *name, Error **errp)
BlockBackend *blk;
BlockDriverState *bs;
QEMUSnapshotInfo sn1, *sn = &sn1;
+ AioContext *aio_context;
int ret;
#ifdef _WIN32
struct _timeb tb;
@@ -403,20 +404,23 @@ void qmp_snapshot_drive(const char *device, const char *name, Error **errp)
return;
}
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
if (bdrv_is_read_only(bs)) {
error_setg(errp, "Node '%s' is read only", device);
- return;
+ goto out;
}
if (!bdrv_can_snapshot(bs)) {
error_setg(errp, QERR_UNSUPPORTED);
- return;
+ goto out;
}
if (bdrv_snapshot_find(bs, sn, name) >= 0) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
"snapshot '%s' already exists", name);
- return;
+ goto out;
}
sn = &sn1;
@@ -441,8 +445,11 @@ void qmp_snapshot_drive(const char *device, const char *name, Error **errp)
if (ret < 0) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
"Error while creating snapshot on '%s'\n", device);
- return;
+ goto out;
}
+
+out:
+ aio_context_release(aio_context);
}
void qmp_delete_drive_snapshot(const char *device, const char *name,
--
2.11.0