]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBuildCommandLine: Fall back to mem balloon if there's no hard_limit
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Aug 2013 12:53:22 +0000 (14:53 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Aug 2013 13:16:07 +0000 (15:16 +0200)
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.

src/qemu/qemu_command.c

index c8f7df227cd21bdbc6a6ca72cf54f90af55b1b47..71c220f19d48c6237ee8cd3412658b41014ae1f6 100644 (file)
@@ -9219,8 +9219,19 @@ qemuBuildCommandLine(virConnectPtr conn,
         goto error;
     }
 
-    if (mlock)
-        virCommandSetMaxMemLock(cmd, def->mem.hard_limit * 1024);
+    if (mlock) {
+        unsigned long long memKB;
+
+        /* VFIO requires all of the guest's memory to be
+         * locked resident, plus some amount for IO
+         * space. Alex Williamson suggested adding 1GiB for IO
+         * space just to be safe (some finer tuning might be
+         * nice, though).
+         */
+        memKB = def->mem.hard_limit ?
+            def->mem.hard_limit : def->mem.max_balloon + 1024 * 1024;
+        virCommandSetMaxMemLock(cmd, memKB * 1024);
+    }
 
     virObjectUnref(cfg);
     return cmd;