aboutsummaryrefslogtreecommitdiff
path: root/block/mirror.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2018-08-29 21:57:26 -0400
committerMax Reitz <mreitz@redhat.com>2018-08-31 16:28:33 +0200
commitf67432a2019caf05b57a146bf45c1024a5cb608e (patch)
tree8fac71ab094f84d2fe97941428fe69f3a3195844 /block/mirror.c
parent7b43db3cd08f722d743c443ac3713195875d0301 (diff)
jobs: change start callback to run callback
Presently we codify the entry point for a job as the "start" callback, but a more apt name would be "run" to clarify the idea that when this function returns we consider the job to have "finished," except for any cleanup which occurs in separate callbacks later. As part of this clarification, change the signature to include an error object and a return code. The error ptr is not yet used, and the return code while captured, will be overwritten by actions in the job_completed function. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20180830015734.19765-2-jsnow@redhat.com Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/mirror.c')
-rw-r--r--block/mirror.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/block/mirror.c b/block/mirror.c
index 6cc10df5c9..691763db41 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -812,9 +812,9 @@ static int mirror_flush(MirrorBlockJob *s)
return ret;
}
-static void coroutine_fn mirror_run(void *opaque)
+static int coroutine_fn mirror_run(Job *job, Error **errp)
{
- MirrorBlockJob *s = opaque;
+ MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
MirrorExitData *data;
BlockDriverState *bs = s->mirror_top_bs->backing->bs;
BlockDriverState *target_bs = blk_bs(s->target);
@@ -1041,7 +1041,9 @@ immediate_exit:
if (need_drain) {
bdrv_drained_begin(bs);
}
+
job_defer_to_main_loop(&s->common.job, mirror_exit, data);
+ return ret;
}
static void mirror_complete(Job *job, Error **errp)
@@ -1138,7 +1140,7 @@ static const BlockJobDriver mirror_job_driver = {
.free = block_job_free,
.user_resume = block_job_user_resume,
.drain = block_job_drain,
- .start = mirror_run,
+ .run = mirror_run,
.pause = mirror_pause,
.complete = mirror_complete,
},
@@ -1154,7 +1156,7 @@ static const BlockJobDriver commit_active_job_driver = {
.free = block_job_free,
.user_resume = block_job_user_resume,
.drain = block_job_drain,
- .start = mirror_run,
+ .run = mirror_run,
.pause = mirror_pause,
.complete = mirror_complete,
},