[libvirt] [PATCH] openvz: fixed an config file parsing error

Hongbin Lu hongbin034 at gmail.com
Sun Sep 7 03:36:05 UTC 2014


Thanks Eric. I modified the fix accordingly.
https://www.redhat.com/archives/libvir-list/2014-September/msg00363.html

Best regards,
Hongbin


On Wed, Sep 3, 2014 at 12:19 PM, Eric Blake <eblake at redhat.com> wrote:

> On 09/03/2014 09:55 AM, Hongbin Lu wrote:
>
> >> The OpenVZ driver reported an error on parsing some OpenVZ config
> >> parameters (e.g. diskspace). This issue is due to the driver made
> >> two incorrect assumptions about the value of the parameters:
> >> 1. Assume paramaeter is just a number (e.g. 1024).
> >> 2. Assume the number is an integer.
> >> Actually, an OpenVZ config parameter may consists of a scalar and
> >> a unit, and the scalar is not necessary an integer (e.g. 2.2G).
> >> This patch is for fixing this issue.
> >> ---
>
> >>
> >> +static int
> >> +openvzParseParamUnit(char* str, openvzParamUnit *unit)
> >> +{
> >> +    int len = strlen(str);
> >> +    if (len == 0)
> >> +        return -1;
> >> +
> >> +    switch (str[len - 1]) {
> >> +    case 'G':
> >> +    case 'g':
> >> +        str[len - 1] = '\0';
> >> +        if (unit != NULL)
> >> +            *unit = OPENVZ_PARAM_UNIT_GIGABYTE;
> >> +        break;
>
> This looks similar to the existing virScaleInteger (src/util/virutil.c)
> and its wrapper vshCommandOptScaledInt (tools/virsh.c); any chance you
> can reuse that code (maybe by making it more generic) instead of
> reimplementing it from scratch?
>
> --
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140906/57b256f2/attachment-0001.htm>


More information about the libvir-list mailing list