[PATCH v2 27/39] qemu: Take NVMe disks into account when calculating memlock limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have this beautiful function that does crystal ball
divination. The function is named
qemuDomainGetMemLockLimitBytes() and it calculates the upper
limit of how much locked memory is given guest going to need. The
function bases its guess on devices defined for a domain. For
instance, if there is a VFIO hostdev defined then it adds 1GiB to
the guessed maximum. Since NVMe disks are pretty much VFIO
hostdevs (but not quite), we have to do the same sorcery.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
ACKed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f8fe430a7f..33929ce3a8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11888,6 +11888,9 @@ getPPC64MemLockLimitBytes(virDomainDefPtr def)
         }
     }
 
+    if (virDomainDefHasNVMeDisk(def))
+        usesVFIO = true;
+
     memory = virDomainDefGetMemoryTotal(def);
 
     if (def->mem.max_memory)
@@ -11986,6 +11989,7 @@ unsigned long long
 qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
 {
     unsigned long long memKB = 0;
+    bool usesVFIO = false;
     size_t i;
 
     /* prefer the hard limit */
@@ -12026,11 +12030,17 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
     for (i = 0; i < def->nhostdevs; i++) {
         if (virHostdevIsVFIODevice(def->hostdevs[i]) ||
             virHostdevIsMdevDevice(def->hostdevs[i])) {
-            memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
-            goto done;
+            usesVFIO = true;
+            break;
         }
     }
 
+    if (virDomainDefHasNVMeDisk(def))
+        usesVFIO = true;
+
+    if (usesVFIO)
+        memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
+
  done:
     return memKB << 10;
 }
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux