job: Add job_transition_to_ready()

The transition to the READY state was still performed in the BlockJob
layer, in the same function that sent the BLOCK_JOB_READY QMP event.

This patch brings the state transition to the Job layer and implements
the QMP event using a notifier called from the Job layer, like we
already do for other events related to state transitions.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Kevin Wolf 2018-04-25 14:56:09 +02:00
parent df956ae201
commit 2e1795b581
8 changed files with 45 additions and 34 deletions

View file

@ -132,6 +132,9 @@ typedef struct Job {
/** Notifiers called when the job transitions to PENDING */
NotifierList on_pending;
/** Notifiers called when the job transitions to READY */
NotifierList on_ready;
/** Element of the list of jobs */
QLIST_ENTRY(Job) job_list;
@ -426,6 +429,9 @@ int job_apply_verb(Job *job, JobVerb verb, Error **errp);
/** The @job could not be started, free it. */
void job_early_fail(Job *job);
/** Moves the @job from RUNNING to READY */
void job_transition_to_ready(Job *job);
/**
* @job: The job being completed.
* @ret: The status code.
@ -522,7 +528,4 @@ void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque);
*/
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);
#endif