<div dir="ltr">Thanks Eric. I modified the fix accordingly.<div><a href="https://www.redhat.com/archives/libvir-list/2014-September/msg00363.html">https://www.redhat.com/archives/libvir-list/2014-September/msg00363.html</a><div><br></div><div>Best regards,</div></div><div>Hongbin</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 3, 2014 at 12:19 PM, Eric Blake <span dir="ltr"><<a href="mailto:eblake@redhat.com" target="_blank">eblake@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 09/03/2014 09:55 AM, Hongbin Lu wrote:<br>
<br>
>> The OpenVZ driver reported an error on parsing some OpenVZ config<br>
>> parameters (e.g. diskspace). This issue is due to the driver made<br>
>> two incorrect assumptions about the value of the parameters:<br>
>> 1. Assume paramaeter is just a number (e.g. 1024).<br>
>> 2. Assume the number is an integer.<br>
>> Actually, an OpenVZ config parameter may consists of a scalar and<br>
>> a unit, and the scalar is not necessary an integer (e.g. 2.2G).<br>
>> This patch is for fixing this issue.<br>
>> ---<br>
<br>
>><br>
</span><span class="">>> +static int<br>
>> +openvzParseParamUnit(char* str, openvzParamUnit *unit)<br>
>> +{<br>
>> +    int len = strlen(str);<br>
>> +    if (len == 0)<br>
>> +        return -1;<br>
>> +<br>
>> +    switch (str[len - 1]) {<br>
>> +    case 'G':<br>
>> +    case 'g':<br>
>> +        str[len - 1] = '\0';<br>
>> +        if (unit != NULL)<br>
>> +            *unit = OPENVZ_PARAM_UNIT_GIGABYTE;<br>
>> +        break;<br>
<br>
</span>This looks similar to the existing virScaleInteger (src/util/virutil.c)<br>
and its wrapper vshCommandOptScaledInt (tools/virsh.c); any chance you<br>
can reuse that code (maybe by making it more generic) instead of<br>
reimplementing it from scratch?<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Eric Blake   eblake redhat com    <a href="tel:%2B1-919-301-3266" value="+19193013266">+1-919-301-3266</a><br>
Libvirt virtualization library <a href="http://libvirt.org" target="_blank">http://libvirt.org</a><br>
<br>
</div></div></blockquote></div><br></div>