mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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:
parent
53ec39ea63
commit
e7b91c510e
@ -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;
|
||||
|
||||
done:
|
||||
return memKB << 10;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user