[PATCH] qemuDomainAttachHostPciDevice: Fall back to mem balloon if there's no hard_limit

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

 



If there's no hard_limit set and domain uses VFIO we still must lock
the guest memory (prerequisite from qemu). Hence, we should compute
the amount to be locked from max_balloon.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 9727410..f028df6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1020,6 +1020,8 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
 
     if (hostdev->source.subsys.u.pci.backend
         == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
+        unsigned long long memKB;
+
         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("VFIO PCI device assignment is not "
@@ -1032,8 +1034,9 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
          * doesn't hurt to "change" the limit to the same value.
          */
         vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
-        virProcessSetMaxMemLock(vm->pid,
-                                vm->def->mem.hard_limit * 1024);
+        memKB = def->mem.hard_limit ?
+            def->mem.hard_limit : def->mem.max_balloon + 1024 * 1024;
+        virProcessSetMaxMemLock(vm->pid, memKB);
         vm->def->hostdevs[vm->def->nhostdevs--] = NULL;
     }
 
-- 
1.8.1.5

--
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]