mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
Add support for shared CGroup namespaces
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #220 Approved by: rhatdan
This commit is contained in:
@ -81,6 +81,8 @@ const (
|
|||||||
UserNS LinuxNS = iota
|
UserNS LinuxNS = iota
|
||||||
// UTSNS is the UTS namespace
|
// UTSNS is the UTS namespace
|
||||||
UTSNS LinuxNS = iota
|
UTSNS LinuxNS = iota
|
||||||
|
// CgroupNS is the CGroup namespace
|
||||||
|
CgroupNS LinuxNS = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns a string representation of a Linux namespace
|
// String returns a string representation of a Linux namespace
|
||||||
@ -101,6 +103,8 @@ func (ns LinuxNS) String() string {
|
|||||||
return "user"
|
return "user"
|
||||||
case UTSNS:
|
case UTSNS:
|
||||||
return "uts"
|
return "uts"
|
||||||
|
case CgroupNS:
|
||||||
|
return "cgroup"
|
||||||
default:
|
default:
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
@ -920,6 +924,21 @@ func (c *Container) Init() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if c.config.CgroupNsCtr != "" {
|
||||||
|
cgroupCtr, err := c.runtime.state.Container(c.config.CgroupNsCtr)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nsPath, err := cgroupCtr.NamespacePath(CgroupNS)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := g.AddOrReplaceLinuxNamespace(spec.CgroupNamespace, nsPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.runningSpec = g.Spec()
|
c.runningSpec = g.Spec()
|
||||||
c.runningSpec.Root.Path = c.state.Mountpoint
|
c.runningSpec.Root.Path = c.state.Mountpoint
|
||||||
|
Reference in New Issue
Block a user