From ea0486873ef586ba3a4a8d302123d829b1bcf36b Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 27 Aug 2015 02:09:54 +0200 Subject: [PATCH] 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 --- src/util/virprocess.c | 3 +++ 1 file changed, 3 insertions(+) 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 -- GitLab