qemu: domain: Restructurate control flow in qemuDomainGetMlockLimitBytes

Break early when hard limit is set so that it's not intermixed by other
logic for determining the limit.
This commit is contained in:
Peter Krempa 2015-11-11 06:49:06 +01:00
parent 53ec39ea63
commit e7b91c510e

View File

@ -3639,14 +3639,18 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
{
unsigned long long memKB;
/* prefer the hard limit */
if (virMemoryLimitIsSet(def->mem.hard_limit)) {
memKB = def->mem.hard_limit;
goto done;
}
/* VFIO requires all of the guest's memory to be locked resident, plus some
* amount for IO space. Alex Williamson suggested adding 1GiB for IO space
* just to be safe (some finer tuning might be nice, though). */
if (virMemoryLimitIsSet(def->mem.hard_limit))
memKB = def->mem.hard_limit;
else
memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
done:
return memKB << 10;
}