Skip to content

Commit

Permalink
blockjob: query driver-specific info via a new 'query' driver method
Browse files Browse the repository at this point in the history
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <20231031135431.393137-9-f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
foxmox authored and kevmw committed Oct 31, 2023
1 parent 701efc9 commit 59fd825
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions blockjob.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Error **errp)
{
BlockJobInfo *info;
uint64_t progress_current, progress_total;
const BlockJobDriver *drv = block_job_driver(job);

GLOBAL_STATE_CODE();

Expand Down Expand Up @@ -407,6 +408,11 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Error **errp)
g_strdup(error_get_pretty(job->job.err)) :
g_strdup(strerror(-job->job.ret));
}
if (drv->query) {
job_unlock();
drv->query(job, info);
job_lock();
}
return info;
}

Expand Down
5 changes: 5 additions & 0 deletions include/block/blockjob_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ struct BlockJobDriver {
* Note that this can already be called before the job coroutine is running.
*/
void (*change)(BlockJob *job, BlockJobChangeOptions *opts, Error **errp);

/*
* Query information specific to this kind of block job.
*/
void (*query)(BlockJob *job, BlockJobInfo *info);
};

/*
Expand Down

0 comments on commit 59fd825

Please sign in to comment.