diff options
author | John Snow | 2015-11-03 00:28:20 +0100 |
---|---|---|
committer | Kevin Wolf | 2015-11-11 16:25:47 +0100 |
commit | 62547b8a1c04daf30f50e3db362ade53e22bf222 (patch) | |
tree | 459afde597d4e97dae7996bafcc77aad92b4e5d2 | |
parent | qcow2: avoid misaligned 64bit bswap (diff) | |
download | qemu-62547b8a1c04daf30f50e3db362ade53e22bf222.tar.gz qemu-62547b8a1c04daf30f50e3db362ade53e22bf222.tar.xz qemu-62547b8a1c04daf30f50e3db362ade53e22bf222.zip |
qemu-img: add check for zero-length job len
The mirror job doesn't update its total length until
it has already started running, so we should translate
a zero-length job-len as meaning 0%.
Otherwise, we may get divide-by-zero faults.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | qemu-img.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/qemu-img.c b/qemu-img.c index 3025776e14..9831db75ef 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -656,7 +656,8 @@ static void run_block_job(BlockJob *job, Error **errp) do { aio_poll(aio_context, true); - qemu_progress_print((float)job->offset / job->len * 100.f, 0); + qemu_progress_print(job->len ? + ((float)job->offset / job->len * 100.f) : 0.0f, 0); } while (!job->ready); block_job_complete_sync(job, errp); |