From e451df796aaa605413a0b84ddd1bf39ec4a751a0 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Fri, 26 Dec 2014 14:14:59 +0300 Subject: [PATCH] namespace: don't create needless namespaces A non-zero Path field for a namespace says that a process should attach to an existing namespace, so the process can be forked without the flag for this namespace. Signed-off-by: Andrey Vagin --- namespaces/utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/namespaces/utils.go b/namespaces/utils.go index de71a379f..20db08788 100644 --- a/namespaces/utils.go +++ b/namespaces/utils.go @@ -36,9 +36,12 @@ func newInitPipe() (parent *os.File, child *os.File, err error) { } // GetNamespaceFlags parses the container's Namespaces options to set the correct -// flags on clone, unshare, and setns +// flags on clone, unshare. This functions returns flags only for new namespaces. func GetNamespaceFlags(namespaces libcontainer.Namespaces) (flag int) { for _, v := range namespaces { + if v.Path != "" { + continue + } flag |= namespaceInfo[v.Type] } return flag