diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-04-24 16:13:52 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-05-23 14:30:51 +0200 |
commit | 3d70ff53b6bf90d9eec6f97024ec9895f6799d9e (patch) | |
tree | 947adf7d4422c78235ff4b8f2a31fac0085efc9a /tests | |
parent | 7eaa8fb57da96301f4a8ce176ad503f80efc7cc0 (diff) | |
download | qemu-3d70ff53b6bf90d9eec6f97024ec9895f6799d9e.zip |
job: Move completion and cancellation to Job
This moves the top-level job completion and cancellation functions from
BlockJob to Job.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-bdrv-drain.c | 5 | ||||
-rw-r--r-- | tests/test-blockjob-txn.c | 14 | ||||
-rw-r--r-- | tests/test-blockjob.c | 21 |
3 files changed, 19 insertions, 21 deletions
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index b428aaca68..3600ffd3fb 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -498,8 +498,7 @@ typedef struct TestBlockJob { static void test_job_completed(Job *job, void *opaque) { - BlockJob *bjob = container_of(job, BlockJob, job); - block_job_completed(bjob, 0); + job_completed(job, 0); } static void coroutine_fn test_job_start(void *opaque) @@ -593,7 +592,7 @@ static void test_blockjob_common(enum drain_type drain_type) g_assert_false(job->job.paused); g_assert_false(job->job.busy); /* We're in job_sleep_ns() */ - ret = block_job_complete_sync(job, &error_abort); + ret = job_complete_sync(&job->job, &error_abort); g_assert_cmpint(ret, ==, 0); blk_unref(blk_src); diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index 6ee31d59ad..34ee179574 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -34,7 +34,7 @@ static void test_block_job_complete(Job *job, void *opaque) rc = -ECANCELED; } - block_job_completed(bjob, rc); + job_completed(job, rc); bdrv_unref(bs); } @@ -130,7 +130,7 @@ static void test_single_job(int expected) job_start(&job->job); if (expected == -ECANCELED) { - block_job_cancel(job, false); + job_cancel(&job->job, false); } while (result == -EINPROGRESS) { @@ -176,10 +176,10 @@ static void test_pair_jobs(int expected1, int expected2) job_txn_unref(txn); if (expected1 == -ECANCELED) { - block_job_cancel(job1, false); + job_cancel(&job1->job, false); } if (expected2 == -ECANCELED) { - block_job_cancel(job2, false); + job_cancel(&job2->job, false); } while (result1 == -EINPROGRESS || result2 == -EINPROGRESS) { @@ -232,13 +232,13 @@ static void test_pair_jobs_fail_cancel_race(void) job_start(&job1->job); job_start(&job2->job); - block_job_cancel(job1, false); + job_cancel(&job1->job, false); /* Now make job2 finish before the main loop kicks jobs. This simulates * the race between a pending kick and another job completing. */ - block_job_enter(job2); - block_job_enter(job2); + job_enter(&job2->job); + job_enter(&job2->job); while (result1 == -EINPROGRESS || result2 == -EINPROGRESS) { aio_poll(qemu_get_aio_context(), true); diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index 1e052c2e9c..46a78739aa 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -165,10 +165,9 @@ typedef struct CancelJob { static void cancel_job_completed(Job *job, void *opaque) { - BlockJob *bjob = container_of(job, BlockJob, job); CancelJob *s = opaque; s->completed = true; - block_job_completed(bjob, 0); + job_completed(job, 0); } static void cancel_job_complete(Job *job, Error **errp) @@ -232,7 +231,7 @@ static void cancel_common(CancelJob *s) BlockBackend *blk = s->blk; JobStatus sts = job->job.status; - block_job_cancel_sync(job); + job_cancel_sync(&job->job); if (sts != JOB_STATUS_CREATED && sts != JOB_STATUS_CONCLUDED) { BlockJob *dummy = job; block_job_dismiss(&dummy, &error_abort); @@ -275,7 +274,7 @@ static void test_cancel_paused(void) assert(job->job.status == JOB_STATUS_RUNNING); job_user_pause(&job->job, &error_abort); - block_job_enter(job); + job_enter(&job->job); assert(job->job.status == JOB_STATUS_PAUSED); cancel_common(s); @@ -292,7 +291,7 @@ static void test_cancel_ready(void) assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; - block_job_enter(job); + job_enter(&job->job); assert(job->job.status == JOB_STATUS_READY); cancel_common(s); @@ -309,11 +308,11 @@ static void test_cancel_standby(void) assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; - block_job_enter(job); + job_enter(&job->job); assert(job->job.status == JOB_STATUS_READY); job_user_pause(&job->job, &error_abort); - block_job_enter(job); + job_enter(&job->job); assert(job->job.status == JOB_STATUS_STANDBY); cancel_common(s); @@ -330,11 +329,11 @@ static void test_cancel_pending(void) assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; - block_job_enter(job); + job_enter(&job->job); assert(job->job.status == JOB_STATUS_READY); job_complete(&job->job, &error_abort); - block_job_enter(job); + job_enter(&job->job); while (!s->completed) { aio_poll(qemu_get_aio_context(), true); } @@ -354,11 +353,11 @@ static void test_cancel_concluded(void) assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; - block_job_enter(job); + job_enter(&job->job); assert(job->job.status == JOB_STATUS_READY); job_complete(&job->job, &error_abort); - block_job_enter(job); + job_enter(&job->job); while (!s->completed) { aio_poll(qemu_get_aio_context(), true); } |