]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Fix memory locking limit calculation
authorAndrea Bolognani <abologna@redhat.com>
Wed, 22 Mar 2017 12:44:13 +0000 (13:44 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 28 Mar 2017 08:54:49 +0000 (10:54 +0200)
For guests that use <memoryBacking><locked>, our only option
is to remove the memory locking limit altogether.

Partially-resolves: https://bugzilla.redhat.com/1431793

src/qemu/qemu_domain.c

index ed7f199143dbe4436068d34064695f7319de36ba..458bb5f9a431db2567666f73148a82954ef2c525 100644 (file)
@@ -6223,10 +6223,13 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
         goto done;
     }
 
-    if (def->mem.locked) {
-        memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
-        goto done;
-    }
+    /* If the guest wants its memory to be locked, we need to raise the memory
+     * locking limit so that the OS will not refuse allocation requests;
+     * however, there is no reliable way for us to figure out how much memory
+     * the QEMU process will allocate for its own use, so our only way out is
+     * to remove the limit altogether. Use with extreme care */
+    if (def->mem.locked)
+        return VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
     if (ARCH_IS_PPC64(def->os.arch) && def->virtType == VIR_DOMAIN_VIRT_KVM) {
         unsigned long long maxMemory;