From: Fam Zheng <famz@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/2] blockdev: Error out on negative throttling option values
Date: Wed, 13 Jan 2016 08:29:48 +0800 [thread overview]
Message-ID: <20160113002948.GC25517@ad.usersys.redhat.com> (raw)
In-Reply-To: <w51twmider0.fsf@maestria.local.igalia.com>
On Tue, 01/12 16:00, Alberto Garcia wrote:
> On Mon 11 Jan 2016 06:42:38 AM CET, Fam Zheng <famz@redhat.com> wrote:
>
> > The implicit casting from unsigned int to double changes negative
> > values into large positive numbers, whereas explicitly casting to
> > signed integer first will let us catch the invalid value and report
> > error correctly:
> >
> > $ qemu-system-x86_64 -drive file=null-co://,iops=-1
> > qemu-system-x86_64: -drive file=null-co://,iops=-1: bps/iops/maxs
> > values must be 0 or greater
> >
>
> > throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =
> > - qemu_opt_get_number(opts, "throttling.bps-total", 0);
> > + (int64_t)qemu_opt_get_number(opts, "throttling.bps-total", 0);
>
> It seems to me that the problem is that qemu_opt_get_number() returns a
> value different from the one specified in the comand-line.
>
> How do we even tell the difference between a negative number and its
> bit-to-bit positive equivalent?
We can't. :(
>
> If we are going to reject very large numbers I would rather check that
> the throtting values are within a sane range and throw an error
> otherwise.
Yes, that is probably more accurate to the user.
Fam
next prev parent reply other threads:[~2016-01-13 0:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 5:42 [Qemu-devel] [PATCH 0/2] block: Reject negative values for throttling options Fam Zheng
2016-01-11 5:42 ` [Qemu-devel] [PATCH 1/2] blockdev: Error out on negative throttling option values Fam Zheng
2016-01-12 15:00 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2016-01-13 0:29 ` Fam Zheng [this message]
2016-01-11 5:42 ` [Qemu-devel] [PATCH 2/2] iotests: Test that negative throttle values are rejected Fam Zheng
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=20160113002948.GC25517@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.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).