diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-04-18 17:10:26 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-05-23 14:30:50 +0200 |
commit | b15de82867975e0b4acf644b5ee36d84904b6612 (patch) | |
tree | 7d2052b01d9021df82c698827b795149bbd2f0a4 /include/qemu | |
parent | 5d43e86e11f488fda7956b13160e0c0105a84845 (diff) | |
download | qemu-b15de82867975e0b4acf644b5ee36d84904b6612.zip qemu-b15de82867975e0b4acf644b5ee36d84904b6612.tar.gz qemu-b15de82867975e0b4acf644b5ee36d84904b6612.tar.bz2 |
job: Move pause/resume functions to Job
While we already moved the state related to job pausing to Job, the
functions to do were still BlockJob only. This commit moves them over to
Job.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r-- | include/qemu/job.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/qemu/job.h b/include/qemu/job.h index 509408f..bc63985 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -83,6 +83,12 @@ typedef struct Job { bool paused; /** + * Set to true if the job is paused by user. Can be unpaused with the + * block-job-resume QMP command. + */ + bool user_paused; + + /** * Set to true if the job should cancel itself. The flag must * always be tested just before toggling the busy flag from false * to true. After a job has been cancelled, it should only yield @@ -124,6 +130,12 @@ struct JobDriver { */ void coroutine_fn (*resume)(Job *job); + /** + * Called when the job is resumed by the user (i.e. user_paused becomes + * false). .user_resume is called before .resume. + */ + void (*user_resume)(Job *job); + /** Called when the job is freed */ void (*free)(Job *job); }; @@ -203,6 +215,31 @@ const char *job_type_str(const Job *job); bool job_is_cancelled(Job *job); /** + * Request @job to pause at the next pause point. Must be paired with + * job_resume(). If the job is supposed to be resumed by user action, call + * job_user_pause() instead. + */ +void job_pause(Job *job); + +/** Resumes a @job paused with job_pause. */ +void job_resume(Job *job); + +/** + * Asynchronously pause the specified @job. + * Do not allow a resume until a matching call to job_user_resume. + */ +void job_user_pause(Job *job, Error **errp); + +/** Returns true if the job is user-paused. */ +bool job_user_paused(Job *job); + +/** + * Resume the specified @job. + * Must be paired with a preceding job_user_pause. + */ +void job_user_resume(Job *job, Error **errp); + +/** * Get the next element from the list of block jobs after @job, or the * first one if @job is %NULL. * |