aboutsummaryrefslogtreecommitdiff
path: root/blockjob.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-04-25 14:56:09 +0200
committerKevin Wolf <kwolf@redhat.com>2018-05-23 14:30:51 +0200
commit2e1795b58131427719c7cd11f8b9b6984b3f24f8 (patch)
treed9e0c9842af8c71f9aa40c56599c880a88ca7535 /blockjob.c
parentdf956ae2014340bf7de0190edb1d09be55d9eadf (diff)
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>
Diffstat (limited to 'blockjob.c')
-rw-r--r--blockjob.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/blockjob.c b/blockjob.c
index 38f18e9ba3..da11b3b763 100644
--- a/blockjob.c
+++ b/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)
{