]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: simplify qemuDomainGetMemLockLimitBytes()
authorLaine Stump <laine@redhat.com>
Tue, 23 Mar 2021 17:13:33 +0000 (13:13 -0400)
committerLaine Stump <laine@redhat.com>
Wed, 24 Mar 2021 19:06:08 +0000 (15:06 -0400)
This function goes through a loop checking if each hostdev is a VFIO
or mdev device, and then later it calls virDomainDefHasNVMEDisk(). The
function qemuDomainNeedsVFIO() does exactly the same thing, so let's
just call that instead.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_domain.c

index 5f0c7f05318ac425c0115e4b3028f5a87f272953..5238a5209570d5debccf136fc2e937503c85bd3e 100644 (file)
@@ -9258,8 +9258,6 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def,
                                bool forceVFIO)
 {
     unsigned long long memKB = 0;
-    bool usesVFIO = false;
-    size_t i;
 
     /* prefer the hard limit */
     if (virMemoryLimitIsSet(def->mem.hard_limit)) {
@@ -9296,20 +9294,7 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def,
      *
      * Note that this may not be valid for all platforms.
      */
-    if (!forceVFIO) {
-        for (i = 0; i < def->nhostdevs; i++) {
-            if (virHostdevIsVFIODevice(def->hostdevs[i]) ||
-                virHostdevIsMdevDevice(def->hostdevs[i])) {
-                usesVFIO = true;
-                break;
-            }
-        }
-
-        if (virDomainDefHasNVMeDisk(def))
-            usesVFIO = true;
-    }
-
-    if (usesVFIO || forceVFIO)
+    if (forceVFIO || qemuDomainNeedsVFIO(def))
         memKB = virDomainDefGetMemoryTotal(def) + 1024 * 1024;
 
     return memKB << 10;