This removes a duplication of the logic used to decide whether the memory locking limit should be set. --- src/qemu/qemu_command.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8fdf90c..3e9eb8c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9135,7 +9135,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, @@ -9304,7 +9303,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))) @@ -10869,9 +10867,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)) { @@ -11124,7 +11119,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) && -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list