aboutsummaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-04-23 18:04:57 +0200
committerKevin Wolf <kwolf@redhat.com>2018-05-23 14:30:50 +0200
commit139a9f020d49e9f863e0d46fd3d0b440dfb3b9d7 (patch)
tree2d38eb4bfd2f2f8beb1b9fdc0ea6180b06e9a092 /job.c
parent5d4f376998bc6b01402b90634385b082b2eb5c5b (diff)
job: Add job_event_*()
Go through the Job layer in order to send QMP events. For the moment, these functions only call a notifier in the BlockJob layer that sends the existing commands. This uses notifiers rather than JobDriver callbacks because internal users of jobs won't receive QMP events, but might still be interested in getting notified for the events. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'job.c')
-rw-r--r--job.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/job.c b/job.c
index dd46170418..817c3b4426 100644
--- a/job.c
+++ b/job.c
@@ -215,6 +215,10 @@ void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
job->auto_finalize = !(flags & JOB_MANUAL_FINALIZE);
job->auto_dismiss = !(flags & JOB_MANUAL_DISMISS);
+ notifier_list_init(&job->on_finalize_cancelled);
+ notifier_list_init(&job->on_finalize_completed);
+ notifier_list_init(&job->on_pending);
+
job_state_transition(job, JOB_STATUS_CREATED);
aio_timer_init(qemu_get_aio_context(), &job->sleep_timer,
QEMU_CLOCK_REALTIME, SCALE_NS,
@@ -247,6 +251,21 @@ void job_unref(Job *job)
}
}
+void job_event_cancelled(Job *job)
+{
+ notifier_list_notify(&job->on_finalize_cancelled, job);
+}
+
+void job_event_completed(Job *job)
+{
+ notifier_list_notify(&job->on_finalize_completed, job);
+}
+
+void job_event_pending(Job *job)
+{
+ notifier_list_notify(&job->on_pending, job);
+}
+
void job_enter_cond(Job *job, bool(*fn)(Job *job))
{
if (!job_started(job)) {