]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Set all limits at the same time
authorAndrea Bolognani <abologna@redhat.com>
Tue, 2 Mar 2021 17:57:51 +0000 (18:57 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 8 Mar 2021 21:41:40 +0000 (22:41 +0100)
qemuProcessLaunch() is the correct place to set process limits,
and in fact is where we were dealing with almost all of them,
but the memory locking limit was handled in
qemuBuildCommandLine() instead for some reason.

The code is rewritten so that the desired limit is calculated
and applied in separated steps, which will help with further
changes, but this doesn't alter the behavior.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_process.c

index 5cdb05e795b1bb8b9032618226dbf513fc3312c0..4461c2762fed5ab1e5809b5141e6718b53f65bcc 100644 (file)
@@ -10127,10 +10127,6 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
         qemuBuildVsockCommandLine(cmd, def, def->vsock, qemuCaps) < 0)
         return NULL;
 
-    /* In some situations, eg. VFIO passthrough, QEMU might need to lock a
-     * significant amount of memory, so we need to set the limit accordingly */
-    virCommandSetMaxMemLock(cmd, qemuDomainGetMemLockLimitBytes(def, false));
-
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) &&
         cfg->logTimestamp)
         virCommandAddArgList(cmd, "-msg", "timestamp=on", NULL);
index cee2de2df136315d7336458223e31ec18518a395..6684065534d5085bac63f055ba766be97fd6a2a7 100644 (file)
@@ -6916,6 +6916,7 @@ qemuProcessLaunch(virConnectPtr conn,
     g_autoptr(virQEMUDriverConfig) cfg = NULL;
     size_t nnicindexes = 0;
     g_autofree int *nicindexes = NULL;
+    unsigned long long maxMemLock = 0;
 
     VIR_DEBUG("conn=%p driver=%p vm=%p name=%s if=%d asyncJob=%d "
               "incoming.launchURI=%s incoming.deferredURI=%s "
@@ -7013,6 +7014,11 @@ qemuProcessLaunch(virConnectPtr conn,
 
     VIR_DEBUG("Setting up process limits");
 
+    /* In some situations, eg. VFIO passthrough, QEMU might need to lock a
+     * significant amount of memory, so we need to set the limit accordingly */
+    maxMemLock = qemuDomainGetMemLockLimitBytes(vm->def, false);
+
+    virCommandSetMaxMemLock(cmd, maxMemLock);
     virCommandSetMaxProcesses(cmd, cfg->maxProcesses);
     virCommandSetMaxFiles(cmd, cfg->maxFiles);
     virCommandSetMaxCoreSize(cmd, cfg->maxCore);