]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Don't special-case setting a limit to zero
authorAndrea Bolognani <abologna@redhat.com>
Tue, 2 Mar 2021 17:44:00 +0000 (18:44 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 8 Mar 2021 21:41:40 +0000 (22:41 +0100)
This behavior reflects the needs of the QEMU driver and has no
place in a generic module such as virProcess.

Thanks to the changes made with the previous commit, it is now
safe to remove these checks and make all virProcessSetMax*()
functions finally behave the same way.

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

index d985bf637beaf1101c815ee25e5f9ac1e3cb8ffe..8428c91182e9bb80db91ae946625212392866f7c 100644 (file)
@@ -798,7 +798,7 @@ virProcessSetLimit(pid_t pid,
 /**
  * virProcessSetMaxMemLock:
  * @pid: process to be changed
- * @bytes: new limit (0 for no change)
+ * @bytes: new limit
  *
  * Sets a new limit on the amount of locked memory for a process.
  *
@@ -809,9 +809,6 @@ virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes)
 {
     struct rlimit rlim;
 
-    if (bytes == 0)
-        return 0;
-
     /* We use VIR_DOMAIN_MEMORY_PARAM_UNLIMITED internally to represent
      * unlimited memory amounts, but setrlimit() and prlimit() use
      * RLIM_INFINITY for the same purpose, so we need to translate between
@@ -896,7 +893,7 @@ virProcessGetMaxMemLock(pid_t pid G_GNUC_UNUSED,
 /**
  * virProcessSetMaxProcesses:
  * @pid: process to be changed
- * @procs: new limit (0 for no change)
+ * @procs: new limit
  *
  * Sets a new limit on the amount of processes for the user the
  * process is running as.
@@ -908,9 +905,6 @@ virProcessSetMaxProcesses(pid_t pid, unsigned int procs)
 {
     struct rlimit rlim;
 
-    if (procs == 0)
-        return 0;
-
     rlim.rlim_cur = rlim.rlim_max = procs;
 
     if (virProcessSetLimit(pid, RLIMIT_NPROC, &rlim) < 0) {
@@ -936,7 +930,7 @@ virProcessSetMaxProcesses(pid_t pid G_GNUC_UNUSED,
 /**
  * virProcessSetMaxFiles:
  * @pid: process to be changed
- * @files: new limit (0 for no change)
+ * @files: new limit
  *
  * Sets a new limit on the number of opened files for a process.
  *
@@ -947,9 +941,6 @@ virProcessSetMaxFiles(pid_t pid, unsigned int files)
 {
     struct rlimit rlim;
 
-    if (files == 0)
-        return 0;
-
    /* Max number of opened files is one greater than actual limit. See
     * man setrlimit.
     *