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 /blockjob.c | |
parent | 2e1795b58131427719c7cd11f8b9b6984b3f24f8 (diff) |
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 'blockjob.c')
-rw-r--r-- | blockjob.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/blockjob.c b/blockjob.c index da11b3b763..5c8ff6f846 100644 --- a/blockjob.c +++ b/blockjob.c @@ -242,16 +242,6 @@ int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n) return ratelimit_calculate_delay(&job->limit, n); } -void block_job_progress_update(BlockJob *job, uint64_t done) -{ - job->offset += done; -} - -void block_job_progress_set_remaining(BlockJob *job, uint64_t remaining) -{ - job->len = job->offset + remaining; -} - BlockJobInfo *block_job_query(BlockJob *job, Error **errp) { BlockJobInfo *info; @@ -263,10 +253,10 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp) info = g_new0(BlockJobInfo, 1); info->type = g_strdup(job_type_str(&job->job)); info->device = g_strdup(job->job.id); - info->len = job->len; info->busy = atomic_read(&job->job.busy); info->paused = job->job.pause_count > 0; - info->offset = job->offset; + info->offset = job->job.progress_current; + info->len = job->job.progress_total; info->speed = job->speed; info->io_status = job->iostatus; info->ready = job_is_ready(&job->job), @@ -296,8 +286,8 @@ static void block_job_event_cancelled(Notifier *n, void *opaque) qapi_event_send_block_job_cancelled(job_type(&job->job), job->job.id, - job->len, - job->offset, + job->job.progress_total, + job->job.progress_current, job->speed, &error_abort); } @@ -317,8 +307,8 @@ static void block_job_event_completed(Notifier *n, void *opaque) qapi_event_send_block_job_completed(job_type(&job->job), job->job.id, - job->len, - job->offset, + job->job.progress_total, + job->job.progress_current, job->speed, !!msg, msg, @@ -348,8 +338,8 @@ static void block_job_event_ready(Notifier *n, void *opaque) qapi_event_send_block_job_ready(job_type(&job->job), job->job.id, - job->len, - job->offset, + job->job.progress_total, + job->job.progress_current, job->speed, &error_abort); } |