]> Git Repo - qemu.git/commitdiff
qemu-img: add check for zero-length job len
authorJohn Snow <[email protected]>
Mon, 2 Nov 2015 23:28:20 +0000 (18:28 -0500)
committerKevin Wolf <[email protected]>
Wed, 11 Nov 2015 15:25:47 +0000 (16:25 +0100)
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 <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
qemu-img.c

index 3025776e14c9b40cd59370954b2050dbd4b93b73..9831db75ef1b5ea3d8a7f554c60cb2c879f898f4 100644 (file)
@@ -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);
This page took 0.029363 seconds and 4 git commands to generate.