qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 1/2] blockdev: Error out on negative throttling


From: Alberto Garcia
Subject: Re: [Qemu-block] [PATCH 1/2] blockdev: Error out on negative throttling option values
Date: Tue, 12 Jan 2016 16:00:35 +0100
User-agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu)

On Mon 11 Jan 2016 06:42:38 AM CET, Fam Zheng <address@hidden> 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?

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.

Berto



reply via email to

[Prev in Thread] Current Thread [Next in Thread]