Blame SOURCES/libvirt-qemuDomainAttachHostPciDevice-Fall-back-to-mem-balloon-if-there-s-no-hard_limit.patch

43fe83
From 487610941b91468f80e6fd91ad9379cef4a77c60 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <487610941b91468f80e6fd91ad9379cef4a77c60.1377873642.git.jdenemar@redhat.com>
43fe83
From: Michal Privoznik <mprivozn@redhat.com>
43fe83
Date: Mon, 26 Aug 2013 17:41:50 +0200
43fe83
Subject: [PATCH] qemuDomainAttachHostPciDevice: Fall back to mem balloon if
43fe83
 there's no hard_limit
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1001143
43fe83
43fe83
If there's no hard_limit set and domain uses VFIO we still must lock
43fe83
the guest memory (prerequisite from qemu). Hence, we should compute
43fe83
the amount to be locked from max_balloon.
43fe83
(cherry picked from commit a45ec678e9bbe8a6157cb440f334b5d21e40f0b4)
43fe83
---
43fe83
 src/qemu/qemu_hotplug.c | 7 +++++--
43fe83
 1 file changed, 5 insertions(+), 2 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
43fe83
index 89df4ad..98b8ad1 100644
43fe83
--- a/src/qemu/qemu_hotplug.c
43fe83
+++ b/src/qemu/qemu_hotplug.c
43fe83
@@ -1022,6 +1022,8 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
43fe83
 
43fe83
     if (hostdev->source.subsys.u.pci.backend
43fe83
         == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
43fe83
+        unsigned long long memKB;
43fe83
+
43fe83
         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
43fe83
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
43fe83
                            _("VFIO PCI device assignment is not "
43fe83
@@ -1034,8 +1036,9 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
43fe83
          * doesn't hurt to "change" the limit to the same value.
43fe83
          */
43fe83
         vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
43fe83
-        virProcessSetMaxMemLock(vm->pid,
43fe83
-                                vm->def->mem.hard_limit * 1024);
43fe83
+        memKB = vm->def->mem.hard_limit ?
43fe83
+            vm->def->mem.hard_limit : vm->def->mem.max_balloon + 1024 * 1024;
43fe83
+        virProcessSetMaxMemLock(vm->pid, memKB);
43fe83
         vm->def->hostdevs[vm->def->nhostdevs--] = NULL;
43fe83
     }
43fe83
 
43fe83
-- 
43fe83
1.8.3.2
43fe83