[libvirt] [PATCHv2 14/15] virsh: improve storage unit parsing

Eric Blake eblake at redhat.com
Thu Mar 8 01:09:05 UTC 2012


On 03/07/2012 05:45 AM, Peter Krempa wrote:
> On 03/06/2012 01:34 AM, Eric Blake wrote:
>> Now can now do:
>>
>> virsh vol-resize $vol 10M
>> virsh blockresize $dom $vol 10M
>>
>> to get both interfaces to resize to 10MiB.  The remaining wart
>> is that vol-resize defaults to bytes, but blockresize defaults
>> to KiB, but we can't break existing scripts; oh well, it's no
>> worse than the same wart of the underlying virDomainBlockResize.
>>

>> -        capacity = -capacity;
>> -    } else {
>> -        if (cmdVolSize(capacityStr,&capacity)<  0) {
>> -            vshError(ctl, _("Malformed size %s"), capacityStr);
>> -            goto cleanup;
>> -        }
>> +        capacityStr++;
> This shift in the string discards the minus sign in error/success
> messages, but their meaning remains correct.

The old code was wrong for negating things - the public API is
documented as always requiring a non-negative value (the combination of
delta and shrink implies a reduction, no negative needed).  So this is
actually a bug fix.

> This was probably added as a safety measure and I'd prefer if we would
> require the --shrink flag to mark that the user is sure of what he's
> doing, although it should be obvious enough from the minus sign. (I
> honestly would prefer a docs change but I'm afraid someone could get mad
> at us if he "accidentaly" corrupts his images.)

My latest version now requires both --delta and --shrink to be present
before ignoring a negative sign.

> 
> ACK, if you add the check for --shrink.
> 
> Peter
> 
> 

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list