[libvirt] [PATCH] libxl: add discard support to libxl_device_disk

Eric Blake eblake at redhat.com
Fri May 30 21:17:08 UTC 2014


On 05/30/2014 03:07 PM, Jim Fehlig wrote:
> Olaf Hering wrote:
>> Translate libvirt discard settings into libxl-4.5 discard settings.
>>
>> Signed-off-by: Olaf Hering <olaf at aepfle.de>
>> ---
>>

>> +static void
>> +libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
>> +{
>> +    if (!x_disk->readwrite)
>> +        return;
>> +#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE)
>> +    switch (discard) {

This line needs a cast to the enum type, if you want the compiler to
enforce that you covered all enum values.

>> +    case VIR_DOMAIN_DISK_DISCARD_DEFAULT:
>>   
> case VIR_DOMAIN_DISK_DISCARD_LAST:
>> +        break;
>> +    case VIR_DOMAIN_DISK_DISCARD_UNMAP:
>> +        libxl_defbool_set(&x_disk->discard_enable, true);
>> +        break;
>> +    default:
>>   
> 
> Then you can remove 'default'.

Removing 'default' is also essential for the compiler-enforced full enum
coverage trick in a switch statement.

-- 
Eric Blake   eblake 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: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140530/65c82e4d/attachment-0001.sig>


More information about the libvir-list mailing list