]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Allow virProcessSetNamespaces() to have sparse FD list
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 27 Aug 2015 00:09:54 +0000 (02:09 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 27 Aug 2015 13:05:51 +0000 (15:05 +0200)
So far, the virProcessSetNamespaces() takes an array of FDs that
it tries to set namespace on. However, in the very next commit
this array may be sparse, having some -1's in it. Teach the
function to cope with that.

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

index 77a038a9177648de8e5287f4e755b208402f8915..e6b78efbc3a06e0371ef9c3eada45fc747af3a6a 100644 (file)
@@ -705,6 +705,9 @@ int virProcessSetNamespaces(size_t nfdlist,
         return -1;
     }
     for (i = 0; i < nfdlist; i++) {
+        if (fdlist[i] < 0)
+            continue;
+
         /* We get EINVAL if new NS is same as the current
          * NS, or if the fd namespace doesn't match the
          * type passed to setns()'s second param. Since we