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 <avagin@openvz.org>
This commit is contained in:
Andrey Vagin
2014-12-26 14:14:59 +03:00
parent e30793aed7
commit e451df796a
+4 -1
View File
@@ -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