From df9a31650505278e72c6b453f1679f66eac6e633 Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Thu, 6 May 2021 17:13:53 +0300 Subject: [PATCH] blockjob: implement and use block_job_get_aio_context We are going to drop BlockJob.blk. So let's retrieve block job context from underlying job instead of main node. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- blockdev.c | 6 +++--- blockjob.c | 5 +++++ include/block/blockjob.h | 7 +++++++ qemu-img.c | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 0eb2823b1b..b5ff9b854e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3315,7 +3315,7 @@ static BlockJob *find_block_job(const char *id, AioContext **aio_context, return NULL; } - *aio_context = blk_get_aio_context(job->blk); + *aio_context = block_job_get_aio_context(job); aio_context_acquire(*aio_context); return job; @@ -3420,7 +3420,7 @@ void qmp_block_job_finalize(const char *id, Error **errp) * automatically acquires the new one), so make sure we release the correct * one. */ - aio_context = blk_get_aio_context(job->blk); + aio_context = block_job_get_aio_context(job); job_unref(&job->job); aio_context_release(aio_context); } @@ -3711,7 +3711,7 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp) if (block_job_is_internal(job)) { continue; } - aio_context = blk_get_aio_context(job->blk); + aio_context = block_job_get_aio_context(job); aio_context_acquire(aio_context); value = block_job_query(job, errp); aio_context_release(aio_context); diff --git a/blockjob.c b/blockjob.c index 4bad1408cb..70bc3105a6 100644 --- a/blockjob.c +++ b/blockjob.c @@ -547,3 +547,8 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockdevOnError on_err, } return action; } + +AioContext *block_job_get_aio_context(BlockJob *job) +{ + return job->job.aio_context; +} diff --git a/include/block/blockjob.h b/include/block/blockjob.h index d200f33c10..3b84805140 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -173,4 +173,11 @@ bool block_job_is_internal(BlockJob *job); */ const BlockJobDriver *block_job_driver(BlockJob *job); +/* + * block_job_get_aio_context: + * + * Returns aio context associated with a block job. + */ +AioContext *block_job_get_aio_context(BlockJob *job); + #endif diff --git a/qemu-img.c b/qemu-img.c index f036a1d428..21ba1e6800 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -902,7 +902,7 @@ static void common_block_job_cb(void *opaque, int ret) static void run_block_job(BlockJob *job, Error **errp) { uint64_t progress_current, progress_total; - AioContext *aio_context = blk_get_aio_context(job->blk); + AioContext *aio_context = block_job_get_aio_context(job); int ret = 0; aio_context_acquire(aio_context);