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;
}
}
if (STREQ_NULLABLE(protocol, "rdma") &&
+ vm->def->mem.hard_limit > 0 &&
virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) {
goto stopjob;
}
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;
}
* 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");