From 58d620cb1d511be7a6521e76a6cd54ebbbbae2b7 Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Mon, 7 Nov 2016 11:47:50 +0100 Subject: [PATCH 45/48] qmp_delete_drive_snapshot : add aiocontext this fix snapshot delete of qcow2 with iothread enabled Signed-off-by: Alexandre Derumier --- savevm-async.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/savevm-async.c b/savevm-async.c index 5913a90..3adf89f 100644 --- a/savevm-async.c +++ b/savevm-async.c @@ -427,6 +427,7 @@ void qmp_delete_drive_snapshot(const char *device, const char *name, BlockDriverState *bs; QEMUSnapshotInfo sn1, *sn = &sn1; Error *local_err = NULL; + AioContext *aio_context; int ret; @@ -443,22 +444,28 @@ void qmp_delete_drive_snapshot(const char *device, const char *name, return; } + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + if (!bdrv_can_snapshot(bs)) { error_setg(errp, QERR_UNSUPPORTED); - return; + goto out; } if (bdrv_snapshot_find(bs, sn, name) < 0) { /* return success if snapshot does not exists */ - return; + goto out; } ret = bdrv_snapshot_delete(bs, NULL, name, &local_err); if (ret < 0) { error_set(errp, ERROR_CLASS_GENERIC_ERROR, "Error while deleting snapshot on '%s'\n", device); - return; + goto out; } + +out: + aio_context_release(aio_context); } static ssize_t loadstate_get_buffer(void *opaque, uint8_t *buf, int64_t pos, -- 2.1.4