mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 01:04:59 +00:00
qemu: Set limits only when explicitly asked to do so
The current code is written under the assumption that, for all limits except the core size, asking for the limit to be set to zero is a no-op, and so the operation is performed unconditionally. While this is the behavior we want for the QEMU driver, the virCommand and virProcess facilities are generic, and should not implement this kind of policy: asking for a limit to be set to zero should result in that limit being set to zero every single time. Add some checks in the QEMU driver, effectively moving the policy where it belongs. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e098340cc4
commit
c2180c2fd6
@ -9259,9 +9259,10 @@ qemuDomainAdjustMaxMemLock(virDomainObjPtr vm,
|
||||
vm->original_memlock = 0;
|
||||
}
|
||||
|
||||
/* Trying to set the memory locking limit to zero is a no-op */
|
||||
if (virProcessSetMaxMemLock(vm->pid, bytes) < 0)
|
||||
if (bytes > 0 &&
|
||||
virProcessSetMaxMemLock(vm->pid, bytes) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2950,6 +2950,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
if (STREQ_NULLABLE(protocol, "rdma") &&
|
||||
vm->def->mem.hard_limit > 0 &&
|
||||
virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) {
|
||||
goto stopjob;
|
||||
}
|
||||
@ -4199,6 +4200,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
|
||||
switch (spec->destType) {
|
||||
case MIGRATION_DEST_HOST:
|
||||
if (STREQ(spec->dest.host.protocol, "rdma") &&
|
||||
vm->def->mem.hard_limit > 0 &&
|
||||
virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) {
|
||||
goto exit_monitor;
|
||||
}
|
||||
|
@ -7018,9 +7018,18 @@ qemuProcessLaunch(virConnectPtr conn,
|
||||
* 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);
|
||||
/* For all these settings, zero indicates that the limit should
|
||||
* not be set explicitly and the default/inherited limit should
|
||||
* be applied instead */
|
||||
if (maxMemLock > 0)
|
||||
virCommandSetMaxMemLock(cmd, maxMemLock);
|
||||
if (cfg->maxProcesses > 0)
|
||||
virCommandSetMaxProcesses(cmd, cfg->maxProcesses);
|
||||
if (cfg->maxFiles > 0)
|
||||
virCommandSetMaxFiles(cmd, cfg->maxFiles);
|
||||
|
||||
/* In this case, however, zero means that core dumps should be
|
||||
* disabled, and so we always need to set the limit explicitly */
|
||||
virCommandSetMaxCoreSize(cmd, cfg->maxCore);
|
||||
|
||||
VIR_DEBUG("Setting up security labelling");
|
||||
|
Loading…
Reference in New Issue
Block a user