]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Use qemuDomainRequiresMlock() in qemuBuildCommandLine()
authorAndrea Bolognani <abologna@redhat.com>
Thu, 12 Nov 2015 15:32:53 +0000 (16:32 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 20 Nov 2015 09:25:14 +0000 (10:25 +0100)
This removes a duplication of the logic used to decide whether
the memory locking limit should be set.

src/qemu/qemu_command.c

index 91c55cb0a2c68d5e5e81e943bd6282e5f4e332a6..ef5ef932e1e64a346872b528d99b97337345dffc 100644 (file)
@@ -9134,7 +9134,6 @@ qemuBuildCommandLine(virConnectPtr conn,
     int usbcontroller = 0;
     int actualSerials = 0;
     bool usblegacy = false;
-    bool mlock = false;
     int contOrder[] = {
         /*
          * List of controller types that we add commandline args for,
@@ -9302,7 +9301,6 @@ qemuBuildCommandLine(virConnectPtr conn,
         virCommandAddArgFormat(cmd, "mlock=%s",
                                def->mem.locked ? "on" : "off");
     }
-    mlock = def->mem.locked;
 
     virCommandAddArg(cmd, "-smp");
     if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
@@ -10867,9 +10865,6 @@ qemuBuildCommandLine(virConnectPtr conn,
                                      "supported by this version of qemu"));
                     goto error;
                 }
-                /* VFIO requires all of the guest's memory to be locked
-                 * resident */
-                mlock = true;
             }
 
             if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
@@ -11096,7 +11091,9 @@ qemuBuildCommandLine(virConnectPtr conn,
             goto error;
     }
 
-    if (mlock)
+    /* In some situations, eg. VFIO passthrough, QEMU might need to lock a
+     * significant amount of memory, so we need to set the limit accordingly */
+    if (qemuDomainRequiresMlock(def))
         virCommandSetMaxMemLock(cmd, qemuDomainGetMlockLimitBytes(def));
 
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) &&