aboutsummaryrefslogtreecommitdiff
path: root/block/backup.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2014-10-21 12:03:56 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2014-11-03 11:41:49 +0000
commit761731b1805f6ef64eb615e5b82a0801db3cde78 (patch)
tree47ee44cc4f529564ab876b6e5038bdeb6b5fedff /block/backup.c
parent5b98db0ad3ad2919c71572085d104765bad6c658 (diff)
downloadqemu-761731b1805f6ef64eb615e5b82a0801db3cde78.zip
qemu-761731b1805f6ef64eb615e5b82a0801db3cde78.tar.gz
qemu-761731b1805f6ef64eb615e5b82a0801db3cde78.tar.bz2
block: let backup blockjob run in BDS AioContext
The backup block job must run in the BlockDriverState AioContext so that it works with dataplane. The basics of acquiring the AioContext are easy in blockdev.c. The completion code in block/backup.c must call bdrv_unref() from the main loop. Use block_job_defer_to_main_loop() to achieve that. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 1413889440-32577-8-git-send-email-stefanha@redhat.com
Diffstat (limited to 'block/backup.c')
-rw-r--r--block/backup.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/block/backup.c b/block/backup.c
index e334740..792e655 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -227,9 +227,25 @@ static BlockErrorAction backup_error_action(BackupBlockJob *job,
}
}
+typedef struct {
+ int ret;
+} BackupCompleteData;
+
+static void backup_complete(BlockJob *job, void *opaque)
+{
+ BackupBlockJob *s = container_of(job, BackupBlockJob, common);
+ BackupCompleteData *data = opaque;
+
+ bdrv_unref(s->target);
+
+ block_job_completed(job, data->ret);
+ g_free(data);
+}
+
static void coroutine_fn backup_run(void *opaque)
{
BackupBlockJob *job = opaque;
+ BackupCompleteData *data;
BlockDriverState *bs = job->common.bs;
BlockDriverState *target = job->target;
BlockdevOnError on_target_error = job->on_target_error;
@@ -344,9 +360,10 @@ static void coroutine_fn backup_run(void *opaque)
hbitmap_free(job->bitmap);
bdrv_iostatus_disable(target);
- bdrv_unref(target);
- block_job_completed(&job->common, ret);
+ data = g_malloc(sizeof(*data));
+ data->ret = ret;
+ block_job_defer_to_main_loop(&job->common, backup_complete, data);
}
void backup_start(BlockDriverState *bs, BlockDriverState *target,