job: Add job_drain()

block_job_drain() contains a blk_drain() call which cannot be moved to
Job, so add a new JobDriver callback JobDriver.drain which has a common
implementation for all BlockJobs. In addition to this we keep the
existing BlockJobDriver.drain callback that is called by the common
drain implementation for all block jobs.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Kevin Wolf
2018-04-20 17:00:29 +02:00
parent 004e95df98
commit b69f777dd9
11 changed files with 55 additions and 10 deletions

View File

@ -167,6 +167,13 @@ struct JobDriver {
*/
void (*user_resume)(Job *job);
/*
* If the callback is not NULL, it will be invoked when the job has to be
* synchronously cancelled or completed; it should drain any activities
* as required to ensure progress.
*/
void (*drain)(Job *job);
/**
* If the callback is not NULL, it will be invoked when all the jobs
* belonging to the same transaction complete; or upon this job's
@ -325,6 +332,12 @@ bool job_user_paused(Job *job);
*/
void job_user_resume(Job *job, Error **errp);
/*
* Drain any activities as required to ensure progress. This can be called in a
* loop to synchronously complete a job.
*/
void job_drain(Job *job);
/**
* Get the next element from the list of block jobs after @job, or the
* first one if @job is %NULL.