1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemu: Use qemuDomainRequiresMlock() in qemuBuildCommandLine()

This removes a duplication of the logic used to decide whether
the memory locking limit should be set.
This commit is contained in:
Andrea Bolognani 2015-11-12 16:32:53 +01:00
parent a6a5ac9650
commit cf9bd25655

View File

@ -9134,7 +9134,6 @@ qemuBuildCommandLine(virConnectPtr conn,
int usbcontroller = 0; int usbcontroller = 0;
int actualSerials = 0; int actualSerials = 0;
bool usblegacy = false; bool usblegacy = false;
bool mlock = false;
int contOrder[] = { int contOrder[] = {
/* /*
* List of controller types that we add commandline args for, * List of controller types that we add commandline args for,
@ -9302,7 +9301,6 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArgFormat(cmd, "mlock=%s", virCommandAddArgFormat(cmd, "mlock=%s",
def->mem.locked ? "on" : "off"); def->mem.locked ? "on" : "off");
} }
mlock = def->mem.locked;
virCommandAddArg(cmd, "-smp"); virCommandAddArg(cmd, "-smp");
if (!(smp = qemuBuildSmpArgStr(def, qemuCaps))) if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
@ -10867,9 +10865,6 @@ qemuBuildCommandLine(virConnectPtr conn,
"supported by this version of qemu")); "supported by this version of qemu"));
goto error; goto error;
} }
/* VFIO requires all of the guest's memory to be locked
* resident */
mlock = true;
} }
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
@ -11096,7 +11091,9 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error; 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)); virCommandSetMaxMemLock(cmd, qemuDomainGetMlockLimitBytes(def));
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) && if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) &&