]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Drop @forceVFIO argument of qemuDomainGetMemLockLimitBytes()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 9 May 2023 14:16:09 +0000 (16:16 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 16 May 2023 12:43:43 +0000 (14:43 +0200)
After previous cleanup, there's not a single caller that would
call qemuDomainGetMemLockLimitBytes() with @forceVFIO set. All
callers pass false.

Drop the unneeded argument from the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_process.c
tests/qemumemlocktest.c

index 7933fecba8b1c26790738e5051a5859bc8f03726..35d03515c7ec13c639110b076075381e44f9d5f4 100644 (file)
@@ -9403,14 +9403,12 @@ ppc64VFIODeviceIsNV2Bridge(const char *device)
 /**
  * getPPC64MemLockLimitBytes:
  * @def: domain definition
- * @forceVFIO: force VFIO usage
  *
  * A PPC64 helper that calculates the memory locking limit in order for
  * the guest to operate properly.
  */
 static unsigned long long
-getPPC64MemLockLimitBytes(virDomainDef *def,
-                          bool forceVFIO)
+getPPC64MemLockLimitBytes(virDomainDef *def)
 {
     unsigned long long memKB = 0;
     unsigned long long baseLimit = 0;
@@ -9472,10 +9470,10 @@ getPPC64MemLockLimitBytes(virDomainDef *def,
                 8192;
 
     /* NVLink2 support in QEMU is a special case of the passthrough
-     * mechanics explained in the forceVFIO case below. The GPU RAM
-     * is placed with a gap after maxMemory. The current QEMU
-     * implementation puts the NVIDIA RAM above the PCI MMIO, which
-     * starts at 32TiB and is the MMIO reserved for the guest main RAM.
+     * mechanics explained below. The GPU RAM is placed with a gap after
+     * maxMemory. The current QEMU implementation puts the NVIDIA RAM
+     * above the PCI MMIO, which starts at 32TiB and is the MMIO
+     * reserved for the guest main RAM.
      *
      * This window ends at 64TiB, and this is where the GPUs are being
      * placed. The next available window size is at 128TiB, and
@@ -9496,7 +9494,7 @@ getPPC64MemLockLimitBytes(virDomainDef *def,
         passthroughLimit = maxMemory +
                            128 * (1ULL<<30) / 512 * nPCIHostBridges +
                            8192;
-    } else if (forceVFIO || qemuDomainNeedsVFIO(def) || virDomainDefHasVDPANet(def)) {
+    } else if (qemuDomainNeedsVFIO(def) || virDomainDefHasVDPANet(def)) {
         /* For regular (non-NVLink2 present) VFIO passthrough, the value
          * of passthroughLimit is:
          *
@@ -9580,20 +9578,16 @@ qemuDomainGetNumVDPANetDevices(const virDomainDef *def)
 /**
  * qemuDomainGetMemLockLimitBytes:
  * @def: domain definition
- * @forceVFIO: force VFIO calculation
  *
  * Calculate the memory locking limit that needs to be set in order for
  * the guest to operate properly. The limit depends on a number of factors,
  * including certain configuration options and less immediately apparent ones
  * such as the guest architecture or the use of certain devices.
- * The @forceVFIO argument can be used to tell this function will use VFIO even
- * though @def doesn't indicates so right now.
  *
  * Returns: the memory locking limit, or 0 if setting the limit is not needed
  */
 unsigned long long
-qemuDomainGetMemLockLimitBytes(virDomainDef *def,
-                               bool forceVFIO)
+qemuDomainGetMemLockLimitBytes(virDomainDef *def)
 {
     unsigned long long memKB = 0;
     int nvfio;
@@ -9615,7 +9609,7 @@ qemuDomainGetMemLockLimitBytes(virDomainDef *def,
         return VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
     if (ARCH_IS_PPC64(def->os.arch) && def->virtType == VIR_DOMAIN_VIRT_KVM)
-        return getPPC64MemLockLimitBytes(def, forceVFIO);
+        return getPPC64MemLockLimitBytes(def);
 
     nvfio = qemuDomainGetNumVFIOHostdevs(def);
     nnvme = qemuDomainGetNumNVMeDisks(def);
@@ -9638,7 +9632,7 @@ qemuDomainGetMemLockLimitBytes(virDomainDef *def,
      *
      * Note that this may not be valid for all platforms.
      */
-    if (forceVFIO || nvfio || nnvme || nvdpa) {
+    if (nvfio || nnvme || nvdpa) {
         /* At present, the full memory needs to be locked for each VFIO / VDPA
          * NVMe device. For VFIO devices, this only applies when there is a
          * vIOMMU present. Yes, this may result in a memory limit that is
@@ -9650,8 +9644,8 @@ qemuDomainGetMemLockLimitBytes(virDomainDef *def,
          */
         int factor = nvdpa + nnvme;
 
-        if (nvfio || forceVFIO) {
-            if (nvfio && def->iommu)
+        if (nvfio) {
+            if (def->iommu)
                 factor += nvfio;
             else
                 factor += 1;
@@ -9741,7 +9735,7 @@ int
 qemuDomainAdjustMaxMemLock(virDomainObj *vm)
 {
     return qemuDomainSetMaxMemLock(vm,
-                                   qemuDomainGetMemLockLimitBytes(vm->def, false),
+                                   qemuDomainGetMemLockLimitBytes(vm->def),
                                    &QEMU_DOMAIN_PRIVATE(vm)->originalMemlock);
 }
 
index 9d15a78e1ca998b387da9ffb841d42c424a71c95..ec9ae75bce0a54fda53ab4d529ed2ca4e9dc9f2f 100644 (file)
@@ -854,8 +854,7 @@ bool qemuDomainSupportsPCI(virDomainDef *def,
 
 void qemuDomainUpdateCurrentMemorySize(virDomainObj *vm);
 
-unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDef *def,
-                                                  bool forceVFIO);
+unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDef *def);
 int qemuDomainAdjustMaxMemLock(virDomainObj *vm);
 int qemuDomainAdjustMaxMemLockHostdev(virDomainObj *vm,
                                       virDomainHostdevDef *hostdev);
index bb4cf352269d21e2f78f7ad8bbfa6ac5fef63ada..ce5ed6389abac5e45421150c36e1aa888cd5d9a7 100644 (file)
@@ -7665,7 +7665,7 @@ qemuProcessLaunch(virConnectPtr conn,
 
     /* In some situations, eg. VFIO passthrough, QEMU might need to lock a
      * significant amount of memory, so we need to set the limit accordingly */
-    maxMemLock = qemuDomainGetMemLockLimitBytes(vm->def, false);
+    maxMemLock = qemuDomainGetMemLockLimitBytes(vm->def);
 
     /* For all these settings, zero indicates that the limit should
      * not be set explicitly and the default/inherited limit should
index c53905a7dd666117ac46a09a9a8126688a93ab49..7d219fcc40f842431436ba83f14cc93f273153dc 100644 (file)
@@ -39,7 +39,7 @@ testCompareMemLock(const void *data)
         return -1;
     }
 
-    return virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(def, false));
+    return virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(def));
 }
 
 static int