[libvirt] [PATCH 1/2] resize: add virStorageVolResize() API

Eric Blake eblake at redhat.com
Mon Jan 30 14:18:06 UTC 2012


On 01/30/2012 04:08 AM, Daniel P. Berrange wrote:
> On Fri, Jan 27, 2012 at 05:28:15PM -0700, Eric Blake wrote:
>> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
>>
>> Add a new function to allow changing of capacity of storage volumes.
>> Plan out several flags, even if not all of them will be implemented
>> up front.
>>

>> +typedef enum {
>> +  VIR_STORAGE_VOL_RESIZE_ALLOCATE = 1 << 0, /* force allocation of new size */
>> +  VIR_STORAGE_VOL_RESIZE_DELTA    = 1 << 1, /* size is relative to current */
>> +  VIR_STORAGE_VOL_RESIZE_SHRINK   = 1 << 2, /* allow decrease in capacity */
>> +} virStorageVolResizeFlags;
>> +
>> +int                     virStorageVolResize             (virStorageVolPtr vol,
>> +                                                         long long capacity,
>> +                                                         unsigned int flags);
> 
> 
> Why has this changed from 'unsigned long long' to just 'long long'.

Because of VIR_STORAGE_VOL_RESIZE_DELTA and
VIR_STORAGE_VOL_RESIZE_SHRINK.  That is,

virStorageVolResize(vol, -10 * 1024 * 1024, DELTA|SHRINK)

is a valid call to shave off 10 MiB of data.

> 
> In virStorageVolInfo we use 'unsigned long long', and you can't ever
> have a negative capacity, so I don't see why this should be signed.

Remember, off_t is signed, so you can never have a storage volume larger
than 2**63 bytes anyways.  Using signed capacity is no different than
using signed off_t (and if you can show me someone with a storage volume
with 2**64 bytes, I will be rather envious).

-- 
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/20120130/4297b7f9/attachment-0001.sig>


More information about the libvir-list mailing list