diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-04-23 18:04:57 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-05-23 14:30:50 +0200 |
commit | 139a9f020d49e9f863e0d46fd3d0b440dfb3b9d7 (patch) | |
tree | 2d38eb4bfd2f2f8beb1b9fdc0ea6180b06e9a092 /include | |
parent | 5d4f376998bc6b01402b90634385b082b2eb5c5b (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 'include')
-rw-r--r-- | include/block/blockjob.h | 9 | ||||
-rw-r--r-- | include/qemu/job.h | 18 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/block/blockjob.h b/include/block/blockjob.h index f9aaaaa835..aef06295f6 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -82,6 +82,15 @@ typedef struct BlockJob { /** Block other operations when block job is running */ Error *blocker; + /** Called when a cancelled job is finalised. */ + Notifier finalize_cancelled_notifier; + + /** Called when a successfully completed job is finalised. */ + Notifier finalize_completed_notifier; + + /** Called when the job transitions to PENDING */ + Notifier pending_notifier; + /** BlockDriverStates that are involved in this block job */ GSList *nodes; diff --git a/include/qemu/job.h b/include/qemu/job.h index 9783e4049b..14d93778f3 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -105,6 +105,15 @@ typedef struct Job { /** True if this job should automatically dismiss itself */ bool auto_dismiss; + /** Notifiers called when a cancelled job is finalised */ + NotifierList on_finalize_cancelled; + + /** Notifiers called when a successfully completed job is finalised */ + NotifierList on_finalize_completed; + + /** Notifiers called when the job transitions to PENDING */ + NotifierList on_pending; + /** Element of the list of jobs */ QLIST_ENTRY(Job) job_list; } Job; @@ -182,6 +191,15 @@ void job_ref(Job *job); */ void job_unref(Job *job); +/** To be called when a cancelled job is finalised. */ +void job_event_cancelled(Job *job); + +/** To be called when a successfully completed job is finalised. */ +void job_event_completed(Job *job); + +/** To be called when the job transitions to PENDING */ +void job_event_pending(Job *job); + /** * Conditionally enter the job coroutine if the job is ready to run, not * already busy and fn() returns true. fn() is called while under the job_lock |