On Tue, 01/12 16:00, Alberto Garcia wrote: > On Mon 11 Jan 2016 06:42:38 AM CET, Fam Zheng <f...@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