[libvirt] [PATCH] virsh: Error prompt if one passes negative value for scheduler setting

Eric Blake eblake at redhat.com
Fri Jan 28 15:33:20 UTC 2011


On 01/28/2011 05:11 AM, Osier Yang wrote:
> 于 2011年01月28日 20:02, Daniel P. Berrange 写道:
>> On Fri, Jan 28, 2011 at 07:53:44PM +0800, Osier Yang wrote:
>>> As cgroup doesn't allow one writes negative into files like cpu.shares,
>>> (e.g. echo -1>  /cgroup/cpu/libvirt/qemu/rhel6/cpu.shares), user will be
>>> confused if libvirt accepts negative value and converts it into unsigned
>>> int (or long int, etc) silently.

But strtoul() is explicitly documented as accepting -1 as shorthand for
ULONG_MAX, and as a command-line convenience, I much prefer that
shorthand over 18446744073709551615.  I don't see this as confusing.

>>
>> Surely this check should be done inside  virStrToLong_{ui,ul,ull}

If we want to be sticklers about reject '-' and module 2^32 (2^64)
wraparound, then yes, virStrToLong_u* would be the place to do it.  But
I'm not convinced that this is a good change.

> Is there some codes that expects virStrToLong_{ui,ul,ull} to convert
> the negative to {ui, ul, ull}?

Probably, given the above arguments about -1 being useful shorthand for
the maximum value.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110128/17246b64/attachment-0001.sig>


More information about the libvir-list mailing list