aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2014-11-19 14:19:42 +0000
committerKevin Wolf <kwolf@redhat.com>2014-12-10 10:25:30 +0100
commit4ef3982a99f9d2634588b4785c8d841605517946 (patch)
treefd5c7e0acef64bef0cbc2bd3154de8b72b83d7fd /blockdev.c
parent2389eeae690b68e9d6a17cb10a5a7c7ec58009a1 (diff)
downloadqemu-4ef3982a99f9d2634588b4785c8d841605517946.zip
qemu-4ef3982a99f9d2634588b4785c8d841605517946.tar.gz
qemu-4ef3982a99f9d2634588b4785c8d841605517946.tar.bz2
blockdev: acquire AioContext in blockdev-snapshot-delete-internal-sync
Add dataplane support to the blockdev-snapshot-delete-internal-sync QMP command. By acquiring the AioContext we avoid race conditions with the dataplane thread which may also be accessing the BlockDriverState. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/blockdev.c b/blockdev.c
index 57910b8..fb9a005 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1105,6 +1105,7 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
Error **errp)
{
BlockDriverState *bs = bdrv_find(device);
+ AioContext *aio_context;
QEMUSnapshotInfo sn;
Error *local_err = NULL;
SnapshotInfo *info = NULL;
@@ -1128,25 +1129,30 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
return NULL;
}
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
ret = bdrv_snapshot_find_by_id_and_name(bs, id, name, &sn, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- return NULL;
+ goto out_aio_context;
}
if (!ret) {
error_setg(errp,
"Snapshot with id '%s' and name '%s' does not exist on "
"device '%s'",
STR_OR_NULL(id), STR_OR_NULL(name), device);
- return NULL;
+ goto out_aio_context;
}
bdrv_snapshot_delete(bs, id, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- return NULL;
+ goto out_aio_context;
}
+ aio_context_release(aio_context);
+
info = g_new0(SnapshotInfo, 1);
info->id = g_strdup(sn.id_str);
info->name = g_strdup(sn.name);
@@ -1157,6 +1163,10 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
info->vm_clock_sec = sn.vm_clock_nsec / 1000000000;
return info;
+
+out_aio_context:
+ aio_context_release(aio_context);
+ return NULL;
}
/* New and old BlockDriverState structs for group snapshots */