qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: Zhengui li <lizhengui@huawei.com>,
	pbonzini@redhat.com, stefanha@redhat.com, mreitz@redhat.com,
	kwolf@redhat.com
Cc: xieyingtai@huawei.com, lizhengui@huawei.com,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH] qemu-img: add support for rate limit in qemu-img commit
Date: Mon, 19 Oct 2020 13:13:50 +0200	[thread overview]
Message-ID: <w51imb6lb81.fsf@maestria.local.igalia.com> (raw)
In-Reply-To: <1603002839-1532-1-git-send-email-lizhengui@huawei.com>

On Sun 18 Oct 2020 08:33:59 AM CEST, Zhengui li wrote:

Hello,

> diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
> index b89c019..ed55b76 100644
> --- a/qemu-img-cmds.hx
> +++ b/qemu-img-cmds.hx
> @@ -34,9 +34,9 @@ SRST
>  ERST
>  
>  DEF("commit", img_commit,
> -    "commit [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-b base] [-d] [-p] filename")
> +    "commit [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-b base] [-s speed] [-d] [-p] filename")
>  SRST
> -.. option:: commit [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [-t CACHE] [-b BASE] [-d] [-p] FILENAME
> +.. option:: commit [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [-t CACHE] [-b BASE] [-s SPEED] [-d] [-p] FILENAME
>  ERST

You should also update docs/tools/qemu-img.rst and explain what the new
parameter does.

> +        case 's': {
> +            unsigned long long sval;
> +            if (qemu_strtou64(optarg, NULL, 10, &sval)) {
> +                error_report("rate limit parse failed");
> +                return 1;
> +            }

You are using 'unsigned long long' here but qemu_strtou64() takes a
uint64_t.

> +            rate_limit = (int64_t)sval * 1024 * 1024;
> +        }   break;

And then you multiply that value by 1024*1024, which can overflow.

So I understand that the value received by 'qemu-img' is in megabytes?
Is there a reason for using that and not bytes?

qemu-img.c provides cvtnum() and cvtnum_full() which allow the user to
specify the units.

Berto


      reply	other threads:[~2020-10-19 11:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-18  6:33 [PATCH] qemu-img: add support for rate limit in qemu-img commit Zhengui li
2020-10-19 11:13 ` Alberto Garcia [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=w51imb6lb81.fsf@maestria.local.igalia.com \
    --to=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=lizhengui@huawei.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=xieyingtai@huawei.com \
    /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).