Currently this only happens for the core size, but we want the
behavior to be consistent for other limits as well.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/util/vircommand.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 3eef0767bb..044c5e0500 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -132,8 +132,11 @@ struct _virCommand {
bool reap;
bool rawStatus;
+ bool setMaxMemLock;
unsigned long long maxMemLock;
+ bool setMaxProcesses;
unsigned int maxProcesses;
+ bool setMaxFiles;
unsigned int maxFiles;
bool setMaxCore;
unsigned long long maxCore;
@@ -806,11 +809,14 @@ virExec(virCommandPtr cmd)
/* pidfilefd is intentionally leaked. */
}
- if (virProcessSetMaxMemLock(pid, cmd->maxMemLock) < 0)
+ if (cmd->setMaxMemLock &&
+ virProcessSetMaxMemLock(pid, cmd->maxMemLock) < 0)
goto fork_error;
- if (virProcessSetMaxProcesses(pid, cmd->maxProcesses) < 0)
+ if (cmd->setMaxProcesses &&
+ virProcessSetMaxProcesses(pid, cmd->maxProcesses) < 0)
goto fork_error;
- if (virProcessSetMaxFiles(pid, cmd->maxFiles) < 0)
+ if (cmd->setMaxFiles &&
+ virProcessSetMaxFiles(pid, cmd->maxFiles) < 0)
goto fork_error;
if (cmd->setMaxCore &&
virProcessSetMaxCoreSize(pid, cmd->maxCore) < 0)
@@ -1149,6 +1155,7 @@ virCommandSetMaxMemLock(virCommandPtr cmd, unsigned long long
bytes)
return;
cmd->maxMemLock = bytes;
+ cmd->setMaxMemLock = true;
}
void
@@ -1158,6 +1165,7 @@ virCommandSetMaxProcesses(virCommandPtr cmd, unsigned int procs)
return;
cmd->maxProcesses = procs;
+ cmd->setMaxProcesses = true;
}
void
@@ -1167,6 +1175,7 @@ virCommandSetMaxFiles(virCommandPtr cmd, unsigned int files)
return;
cmd->maxFiles = files;
+ cmd->setMaxFiles = true;
}
void virCommandSetMaxCoreSize(virCommandPtr cmd, unsigned long long bytes)
--
2.26.2