job: Add job_dismiss()
This moves block_job_dismiss() to the Job layer. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
198c49cc8d
commit
5f9a6a08e8
10
blockdev.c
10
blockdev.c
@ -3915,14 +3915,16 @@ void qmp_block_job_finalize(const char *id, Error **errp)
|
||||
void qmp_block_job_dismiss(const char *id, Error **errp)
|
||||
{
|
||||
AioContext *aio_context;
|
||||
BlockJob *job = find_block_job(id, &aio_context, errp);
|
||||
BlockJob *bjob = find_block_job(id, &aio_context, errp);
|
||||
Job *job;
|
||||
|
||||
if (!job) {
|
||||
if (!bjob) {
|
||||
return;
|
||||
}
|
||||
|
||||
trace_qmp_block_job_dismiss(job);
|
||||
block_job_dismiss(&job, errp);
|
||||
trace_qmp_block_job_dismiss(bjob);
|
||||
job = &bjob->job;
|
||||
job_dismiss(&job, errp);
|
||||
aio_context_release(aio_context);
|
||||
}
|
||||
|
||||
|
13
blockjob.c
13
blockjob.c
@ -242,19 +242,6 @@ int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n)
|
||||
return ratelimit_calculate_delay(&job->limit, n);
|
||||
}
|
||||
|
||||
void block_job_dismiss(BlockJob **jobptr, Error **errp)
|
||||
{
|
||||
BlockJob *job = *jobptr;
|
||||
/* similarly to _complete, this is QMP-interface only. */
|
||||
assert(job->job.id);
|
||||
if (job_apply_verb(&job->job, JOB_VERB_DISMISS, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
job_do_dismiss(&job->job);
|
||||
*jobptr = NULL;
|
||||
}
|
||||
|
||||
void block_job_progress_update(BlockJob *job, uint64_t done)
|
||||
{
|
||||
job->offset += done;
|
||||
|
@ -140,15 +140,6 @@ void block_job_remove_all_bdrv(BlockJob *job);
|
||||
*/
|
||||
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp);
|
||||
|
||||
/**
|
||||
* block_job_dismiss:
|
||||
* @job: The job to be dismissed.
|
||||
* @errp: Error object.
|
||||
*
|
||||
* Remove a concluded job from the query list.
|
||||
*/
|
||||
void block_job_dismiss(BlockJob **job, Error **errp);
|
||||
|
||||
/**
|
||||
* block_job_progress_update:
|
||||
* @job: The job that has made progress
|
||||
|
@ -487,6 +487,12 @@ int job_complete_sync(Job *job, Error **errp);
|
||||
*/
|
||||
void job_finalize(Job *job, Error **errp);
|
||||
|
||||
/**
|
||||
* Remove the concluded @job from the query list and resets the passed pointer
|
||||
* to %NULL. Returns an error if the job is not actually concluded.
|
||||
*/
|
||||
void job_dismiss(Job **job, Error **errp);
|
||||
|
||||
typedef void JobDeferToMainLoopFn(Job *job, void *opaque);
|
||||
|
||||
/**
|
||||
@ -515,6 +521,5 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
|
||||
|
||||
/* TODO To be removed from the public interface */
|
||||
void job_state_transition(Job *job, JobStatus s1);
|
||||
void job_do_dismiss(Job *job);
|
||||
|
||||
#endif
|
||||
|
15
job.c
15
job.c
@ -568,7 +568,7 @@ void job_user_resume(Job *job, Error **errp)
|
||||
job_resume(job);
|
||||
}
|
||||
|
||||
void job_do_dismiss(Job *job)
|
||||
static void job_do_dismiss(Job *job)
|
||||
{
|
||||
assert(job);
|
||||
job->busy = false;
|
||||
@ -581,6 +581,19 @@ void job_do_dismiss(Job *job)
|
||||
job_unref(job);
|
||||
}
|
||||
|
||||
void job_dismiss(Job **jobptr, Error **errp)
|
||||
{
|
||||
Job *job = *jobptr;
|
||||
/* similarly to _complete, this is QMP-interface only. */
|
||||
assert(job->id);
|
||||
if (job_apply_verb(job, JOB_VERB_DISMISS, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
job_do_dismiss(job);
|
||||
*jobptr = NULL;
|
||||
}
|
||||
|
||||
void job_early_fail(Job *job)
|
||||
{
|
||||
assert(job->status == JOB_STATUS_CREATED);
|
||||
|
@ -233,8 +233,8 @@ static void cancel_common(CancelJob *s)
|
||||
|
||||
job_cancel_sync(&job->job);
|
||||
if (sts != JOB_STATUS_CREATED && sts != JOB_STATUS_CONCLUDED) {
|
||||
BlockJob *dummy = job;
|
||||
block_job_dismiss(&dummy, &error_abort);
|
||||
Job *dummy = &job->job;
|
||||
job_dismiss(&dummy, &error_abort);
|
||||
}
|
||||
assert(job->job.status == JOB_STATUS_NULL);
|
||||
job_unref(&job->job);
|
||||
|
Loading…
Reference in New Issue
Block a user