diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-05-04 12:17:20 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-05-23 14:30:51 +0200 |
commit | 30a5c887bf4a7e00d0e0ecbb08509e8ba2902620 (patch) | |
tree | 1dac007a566de2715e9f73d62a74b98cc45f019e /include/qemu | |
parent | 2e1795b58131427719c7cd11f8b9b6984b3f24f8 (diff) | |
download | qemu-30a5c887bf4a7e00d0e0ecbb08509e8ba2902620.zip qemu-30a5c887bf4a7e00d0e0ecbb08509e8ba2902620.tar.gz qemu-30a5c887bf4a7e00d0e0ecbb08509e8ba2902620.tar.bz2 |
job: Move progress fields to Job
BlockJob has fields .offset and .len, which are actually misnomers today
because they are no longer tied to block device sizes, but just progress
counters. As such they make a lot of sense in generic Jobs.
This patch moves the fields to Job and renames them to .progress_current
and .progress_total to describe their function better.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r-- | include/qemu/job.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/qemu/job.h b/include/qemu/job.h index bfc2bc5..92d1d24 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -114,6 +114,16 @@ typedef struct Job { /** True if this job should automatically dismiss itself */ bool auto_dismiss; + /** + * Current progress. The unit is arbitrary as long as the ratio between + * progress_current and progress_total represents the estimated percentage + * of work already done. + */ + int64_t progress_current; + + /** Estimated progress_current value at the completion of the job */ + int64_t progress_total; + /** ret code passed to job_completed. */ int ret; @@ -304,6 +314,24 @@ void job_ref(Job *job); */ void job_unref(Job *job); +/** + * @job: The job that has made progress + * @done: How much progress the job made since the last call + * + * Updates the progress counter of the job. + */ +void job_progress_update(Job *job, uint64_t done); + +/** + * @job: The job whose expected progress end value is set + * @remaining: Missing progress (on top of the current progress counter value) + * until the new expected end value is reached + * + * Sets the expected end value of the progress counter of a job so that a + * completion percentage can be calculated when the progress is updated. + */ +void job_progress_set_remaining(Job *job, uint64_t remaining); + /** To be called when a cancelled job is finalised. */ void job_event_cancelled(Job *job); |