qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-img: add check for zero-length job len
Date: Mon, 2 Nov 2015 16:24:53 -0800	[thread overview]
Message-ID: <20151103002453.GA15533@localhost.localdomain> (raw)
In-Reply-To: <1446506900-27733-1-git-send-email-jsnow@redhat.com>

On Mon, Nov 02, 2015 at 06:28:20PM -0500, John Snow wrote:
> 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>
> ---
>  qemu-img.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 3025776..38b4888 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.00, 0);
>      } while (!job->ready);
>  
>      block_job_complete_sync(job, errp);
> -- 
> 2.4.3
>

Reviewed-by: Jeff Cody <jcody@redhat.com>

      parent reply	other threads:[~2015-11-03  0:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 23:28 [Qemu-devel] [PATCH] qemu-img: add check for zero-length job len John Snow
2015-11-02 23:43 ` Eric Blake
2015-11-02 23:45   ` John Snow
2015-11-04 11:12     ` Kevin Wolf
2015-11-03  0:24 ` Jeff Cody [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151103002453.GA15533@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).