Break early when hard limit is set so that it's not intermixed by other logic for determining the limit. --- src/qemu/qemu_domain.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 416ab5b..12517a5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3633,14 +3633,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; } -- 2.6.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list