aboutsummaryrefslogtreecommitdiff
path: root/tests/test-blockjob.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-09-24 14:35:58 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-09-24 14:35:58 +0100
commitd6f71af65410d3e003ba331c5e57eddcf716cbcf (patch)
treec839d777f3d290b8f430e2a64aca44d1ed4271eb /tests/test-blockjob.c
parent539c251b64d2cdd6aeafde1c6283688915c9aad0 (diff)
parente21a1c9831fc80ae3f3c1affdfa43350035d8588 (diff)
Merge remote-tracking branch 'remotes/xanclic/tags/pull-block-2018-08-31-v2' into staging
Block patches: - (Block) job exit refactoring, part 1 (removing job_defer_to_main_loop()) - test-bdrv-drain leak fix # gpg: Signature made Fri 31 Aug 2018 15:30:33 BST # gpg: using RSA key F407DB0061D5CF40 # gpg: Good signature from "Max Reitz <mreitz@redhat.com>" # Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40 * remotes/xanclic/tags/pull-block-2018-08-31-v2: jobs: remove job_defer_to_main_loop jobs: remove ret argument to job_completed; privatize it block/backup: make function variables consistently named jobs: utilize job_exit shim block/mirror: utilize job_exit shim block/commit: utilize job_exit shim jobs: add exit shim jobs: canonize Error object jobs: change start callback to run callback tests: fix bdrv-drain leak Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/test-blockjob.c')
-rw-r--r--tests/test-blockjob.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
index cb42f06e61..ad4a65bc78 100644
--- a/tests/test-blockjob.c
+++ b/tests/test-blockjob.c
@@ -163,11 +163,10 @@ typedef struct CancelJob {
bool completed;
} CancelJob;
-static void cancel_job_completed(Job *job, void *opaque)
+static void cancel_job_exit(Job *job)
{
- CancelJob *s = opaque;
+ CancelJob *s = container_of(job, CancelJob, common.job);
s->completed = true;
- job_completed(job, 0, NULL);
}
static void cancel_job_complete(Job *job, Error **errp)
@@ -176,13 +175,13 @@ static void cancel_job_complete(Job *job, Error **errp)
s->should_complete = true;
}
-static void coroutine_fn cancel_job_start(void *opaque)
+static int coroutine_fn cancel_job_run(Job *job, Error **errp)
{
- CancelJob *s = opaque;
+ CancelJob *s = container_of(job, CancelJob, common.job);
while (!s->should_complete) {
if (job_is_cancelled(&s->common.job)) {
- goto defer;
+ return 0;
}
if (!job_is_ready(&s->common.job) && s->should_converge) {
@@ -192,8 +191,7 @@ static void coroutine_fn cancel_job_start(void *opaque)
job_sleep_ns(&s->common.job, 100000);
}
- defer:
- job_defer_to_main_loop(&s->common.job, cancel_job_completed, s);
+ return 0;
}
static const BlockJobDriver test_cancel_driver = {
@@ -202,7 +200,8 @@ static const BlockJobDriver test_cancel_driver = {
.free = block_job_free,
.user_resume = block_job_user_resume,
.drain = block_job_drain,
- .start = cancel_job_start,
+ .run = cancel_job_run,
+ .exit = cancel_job_exit,
.complete = cancel_job_complete,
},
};