From: Michal Privoznik Date: Thu, 27 Aug 2015 00:09:54 +0000 (+0200) Subject: util: Allow virProcessSetNamespaces() to have sparse FD list X-Git-Tag: v1.2.19-rc2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea0486873ef586ba3a4a8d302123d829b1bcf36b;p=thirdparty%2Flibvirt.git util: Allow virProcessSetNamespaces() to have sparse FD list 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 --- diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 77a038a917..e6b78efbc3 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -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