From e289cf734bf020ef632665969929445540bb4a2f Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Wed, 15 Jul 2015 12:10:15 -0700 Subject: [PATCH] Fix handling name= cgroups Before name=systemd cgroup was mounted inside container to /sys/fs/cgroup/name=systemd, which is wrong, it should be /sys/fs/cgroup/systemd Signed-off-by: Alexander Morozov --- libcontainer/cgroups/utils.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index 8ab80a7f2c3..c7c460ac063 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -17,6 +17,8 @@ import ( "github.com/docker/docker/pkg/units" ) +const cgroupNamePrefix = "name=" + // https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt func FindCgroupMountpoint(subsystem string) (string, error) { f, err := os.Open("/proc/self/mountinfo") @@ -90,8 +92,8 @@ func GetCgroupMounts() ([]Mount, error) { m := Mount{Mountpoint: mount.Mountpoint} for _, opt := range strings.Split(mount.VfsOpts, ",") { - if strings.HasPrefix(opt, "name=") { - m.Subsystems = append(m.Subsystems, opt) + if strings.HasPrefix(opt, cgroupNamePrefix) { + m.Subsystems = append(m.Subsystems, opt[len(cgroupNamePrefix):]) } if allMap[opt] { m.Subsystems = append(m.Subsystems, opt) @@ -186,7 +188,7 @@ func ParseCgroupFile(subsystem string, r io.Reader) (string, error) { parts := strings.Split(text, ":") for _, subs := range strings.Split(parts[1], ",") { - if subs == subsystem { + if subs == subsystem || subs == cgroupNamePrefix+subsystem { return parts[2], nil } }