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 /qemu-img.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 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/qemu-img.c b/qemu-img.c index 700e4e187b..976b437da0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -863,9 +863,13 @@ static void run_block_job(BlockJob *job, Error **errp) aio_context_acquire(aio_context); job_ref(&job->job); do { + float progress = 0.0f; aio_poll(aio_context, true); - qemu_progress_print(job->len ? - ((float)job->offset / job->len * 100.f) : 0.0f, 0); + if (job->job.progress_total) { + progress = (float)job->job.progress_current / + job->job.progress_total * 100.f; + } + qemu_progress_print(progress, 0); } while (!job_is_ready(&job->job) && !job_is_completed(&job->job)); if (!job_is_completed(&job->job)) { |