From: Luyao Huang Date: Mon, 15 Dec 2014 06:46:28 +0000 (+0800) Subject: conf: fix virDomainLeaseIndex logic X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=046d82d72fa7a2daf2bcb39af3d1a5c3d22e23bd;p=libvirt.git conf: fix virDomainLeaseIndex logic https://bugzilla.redhat.com/show_bug.cgi?id=1174096 When both parameter have lockspaces present, virDomainLeaseIndex always returns -1 even there is a lease the same with the one we check. This is due to broken logic in 'if-else' statement. Signed-off-by: Luyao Huang Signed-off-by: Michal Privoznik --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 82ab2aaaac..15bf8583c4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11673,13 +11673,15 @@ 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; + } + if (STREQ(vlease->key, lease->key)) return i; }