mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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:
parent
df956ae201
commit
2e1795b581
8 changed files with 45 additions and 34 deletions
33
blockjob.c
33
blockjob.c
|
@ -338,6 +338,22 @@ static void block_job_event_pending(Notifier *n, void *opaque)
|
|||
&error_abort);
|
||||
}
|
||||
|
||||
static void block_job_event_ready(Notifier *n, void *opaque)
|
||||
{
|
||||
BlockJob *job = opaque;
|
||||
|
||||
if (block_job_is_internal(job)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qapi_event_send_block_job_ready(job_type(&job->job),
|
||||
job->job.id,
|
||||
job->len,
|
||||
job->offset,
|
||||
job->speed, &error_abort);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* API for block job drivers and the block layer. These functions are
|
||||
* declared in blockjob_int.h.
|
||||
|
@ -386,12 +402,14 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|||
job->finalize_cancelled_notifier.notify = block_job_event_cancelled;
|
||||
job->finalize_completed_notifier.notify = block_job_event_completed;
|
||||
job->pending_notifier.notify = block_job_event_pending;
|
||||
job->ready_notifier.notify = block_job_event_ready;
|
||||
|
||||
notifier_list_add(&job->job.on_finalize_cancelled,
|
||||
&job->finalize_cancelled_notifier);
|
||||
notifier_list_add(&job->job.on_finalize_completed,
|
||||
&job->finalize_completed_notifier);
|
||||
notifier_list_add(&job->job.on_pending, &job->pending_notifier);
|
||||
notifier_list_add(&job->job.on_ready, &job->ready_notifier);
|
||||
|
||||
error_setg(&job->blocker, "block device is in use by block job: %s",
|
||||
job_type_str(&job->job));
|
||||
|
@ -433,21 +451,6 @@ void block_job_user_resume(Job *job)
|
|||
block_job_iostatus_reset(bjob);
|
||||
}
|
||||
|
||||
void block_job_event_ready(BlockJob *job)
|
||||
{
|
||||
job_state_transition(&job->job, JOB_STATUS_READY);
|
||||
|
||||
if (block_job_is_internal(job)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qapi_event_send_block_job_ready(job_type(&job->job),
|
||||
job->job.id,
|
||||
job->len,
|
||||
job->offset,
|
||||
job->speed, &error_abort);
|
||||
}
|
||||
|
||||
BlockErrorAction block_job_error_action(BlockJob *job, BlockdevOnError on_err,
|
||||
int is_read, int error)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue