update to 2.7
[pve-qemu-kvm.git] / debian / patches / pve / 0042-qmp_snapshot_drive-add-aiocontext.patch
blob2d84418ec0f3f7492ee4c8ac92d85c1552698d99
1 From fa4f5325137a86bbbdc3f477a2a171a43ea80a7a Mon Sep 17 00:00:00 2001
2 From: Alexandre Derumier <aderumier@odiso.com>
3 Date: Tue, 13 Sep 2016 01:57:56 +0200
4 Subject: [PATCH 42/42] qmp_snapshot_drive: add aiocontext
6 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
7 ---
8 savevm-async.c | 15 +++++++++++----
9 1 file changed, 11 insertions(+), 4 deletions(-)
11 diff --git a/savevm-async.c b/savevm-async.c
12 index fddb18c..a158249 100644
13 --- a/savevm-async.c
14 +++ b/savevm-async.c
15 @@ -372,6 +372,7 @@ void qmp_snapshot_drive(const char *device, const char *name, Error **errp)
16 BlockBackend *blk;
17 BlockDriverState *bs;
18 QEMUSnapshotInfo sn1, *sn = &sn1;
19 + AioContext *aio_context;
20 int ret;
21 #ifdef _WIN32
22 struct _timeb tb;
23 @@ -398,20 +399,23 @@ void qmp_snapshot_drive(const char *device, const char *name, Error **errp)
24 return;
27 + aio_context = bdrv_get_aio_context(bs);
28 + aio_context_acquire(aio_context);
30 if (bdrv_is_read_only(bs)) {
31 error_setg(errp, "Node '%s' is read only", device);
32 - return;
33 + goto out;
36 if (!bdrv_can_snapshot(bs)) {
37 error_setg(errp, QERR_UNSUPPORTED);
38 - return;
39 + goto out;
42 if (bdrv_snapshot_find(bs, sn, name) >= 0) {
43 error_set(errp, ERROR_CLASS_GENERIC_ERROR,
44 "snapshot '%s' already exists", name);
45 - return;
46 + goto out;
49 sn = &sn1;
50 @@ -436,8 +440,11 @@ void qmp_snapshot_drive(const char *device, const char *name, Error **errp)
51 if (ret < 0) {
52 error_set(errp, ERROR_CLASS_GENERIC_ERROR,
53 "Error while creating snapshot on '%s'\n", device);
54 - return;
55 + goto out;
58 +out:
59 + aio_context_release(aio_context);
62 void qmp_delete_drive_snapshot(const char *device, const char *name,
63 --
64 2.1.4