[libvirt] [PATCH] conf: fix virDomainLeaseIndex cannot work when both parameter have lockspaces present
Luyao Huang
lhuang at redhat.com
Mon Dec 15 13:32:19 UTC 2014
On 12/15/2014 09:27 PM, Michal Privoznik wrote:
> On 15.12.2014 07:46, Luyao Huang wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1174096
>>
>> When both parameter have lockspaces present, virDomainLeaseIndex
>> will always -1 even there is a lease the same with the one we check.
>> I think we shouldn't do 'continue' when the two lockspaces are the same.
>>
>> Signed-off-by: Luyao Huang <lhuang at redhat.com>
>> ---
>> src/conf/domain_conf.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 5cf0b1a..f36affc 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -11667,13 +11667,14 @@ int virDomainLeaseIndex(virDomainDefPtr def,
>>
>> for (i = 0; i < def->nleases; i++) {
>> vlease = def->leases[i];
>> - /* Either both must have lockspaces present which match.. */
>> - if (vlease->lockspace && lease->lockspace &&
>> - STRNEQ(vlease->lockspace, lease->lockspace))
>> - continue;
>> + /* Either both must have lockspaces present which match.. */
>> + if (vlease->lockspace && lease->lockspace) {
>> + if (STRNEQ(vlease->lockspace, lease->lockspace))
>> + continue;
>> /* ...or neither must have a lockspace present */
>> - if (vlease->lockspace || lease->lockspace)
>> + } else if (vlease->lockspace || lease->lockspace)
>> continue;
>
> When an 'if' statement has body enclosed in brackets, so must have the
> 'else' branch.
>
Ohhh, i see. Thanks a lot for your pointing out :)
>> +
>> if (STREQ(vlease->key, lease->key))
>> return i;
>> }
>>
>
> ACked, fixed and pushed.
>
Thanks
> Michal
Luyao
More information about the libvir-list
mailing list