[libvirt] [PATCH] Add support for shared sanlock leases

Eric Blake eblake at redhat.com
Fri Jun 22 04:19:34 UTC 2012


On 06/21/2012 11:00 AM, Federico Simoncelli wrote:
> On Thu, Jun 21, 2012 at 03:37:10PM +0100, Daniel P. Berrange wrote:
>> From: "Daniel P. Berrange" <berrange at redhat.com>
>>
>> A sanlock lease can be marked as shared (rather
>> than exclusive)  using SANLK_RES_SHARED flag. This
>> adds support for that flag and ensures that in auto
>> disk mode, any shared disks use shared leases. This
>> also makes any read-only disks be completely
>> ignored.
>>

>>      case VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK:
>>          if (driver->autoDiskLease) {
>> -            if (virLockManagerSanlockAddDisk(lock, name, nparams, params) < 0)
>> +            if (virLockManagerSanlockAddDisk(lock, name, nparams, params,
>> +                                             !!(flags & VIR_LOCK_MANAGER_RESOURCE_SHARED)) < 0)
> 
> Just out of curiosity, you are using "!!" (both here and below) because
> the compiler is complaining about the type?

Rather, it is a way of forcing a value to be 0 or 1 with the fewest
characters possible (since the line is already long); shorter than
constructs such as:

(bool)(flags & VIR_LOCK_MANAGER_RESOURCE_SHARED)
(flags & VIR_LOCK_MANAGER_RESOURCE_SHARED) != 0

But since virLockManagerSanlockAddDisk() declared its argument as bool,
and we already require a C99 compiler, the !! trick is strictly
unnecessary; C99 compilers already guarantee to implicitly convert any
non-zero value to true when doing argument conversion.

-- 
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/20120621/c1c788f1/attachment-0001.sig>


More information about the libvir-list mailing list