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

43fe83
From 3d2c6bc59a4cfb28b94a46d11484ec7a4562716c Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <3d2c6bc59a4cfb28b94a46d11484ec7a4562716c.1377873642.git.jdenemar@redhat.com>
43fe83
From: Michal Privoznik <mprivozn@redhat.com>
43fe83
Date: Mon, 26 Aug 2013 17:41:49 +0200
43fe83
Subject: [PATCH] qemuBuildCommandLine: Fall back to mem balloon if there's no
43fe83
 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 the
43fe83
guest memory (prerequisite from qemu). Hence, we should compute the
43fe83
amount to be locked from max_balloon.
43fe83
(cherry picked from commit a7f94a40bb2554c56d0c6bea98a5843690dc3933)
43fe83
---
43fe83
 src/qemu/qemu_command.c | 15 +++++++++++++--
43fe83
 1 file changed, 13 insertions(+), 2 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
43fe83
index 7bbfd03..6dfd141 100644
43fe83
--- a/src/qemu/qemu_command.c
43fe83
+++ b/src/qemu/qemu_command.c
43fe83
@@ -9239,8 +9239,19 @@ qemuBuildCommandLine(virConnectPtr conn,
43fe83
         goto error;
43fe83
     }
43fe83
 
43fe83
-    if (mlock)
43fe83
-        virCommandSetMaxMemLock(cmd, def->mem.hard_limit * 1024);
43fe83
+    if (mlock) {
43fe83
+        unsigned long long memKB;
43fe83
+
43fe83
+        /* VFIO requires all of the guest's memory to be
43fe83
+         * locked resident, plus some amount for IO
43fe83
+         * space. Alex Williamson suggested adding 1GiB for IO
43fe83
+         * space just to be safe (some finer tuning might be
43fe83
+         * nice, though).
43fe83
+         */
43fe83
+        memKB = def->mem.hard_limit ?
43fe83
+            def->mem.hard_limit : def->mem.max_balloon + 1024 * 1024;
43fe83
+        virCommandSetMaxMemLock(cmd, memKB * 1024);
43fe83
+    }
43fe83
 
43fe83
     virObjectUnref(cfg);
43fe83
     return cmd;
43fe83
-- 
43fe83
1.8.3.2
43fe83