Skip to content

Commit

Permalink
cgroup namespaces: ignore the nsroot in cgroup namespaces
Browse files Browse the repository at this point in the history
If our cgroups were mounted in a cgroup namespace rooted at /a/b,
then a task in namespaced cgroup / will see / in /proc/self/mountinfo
and /sys/fs/cgroup/freezer/x will actually point to /a/b/x - but
the 'root' field (field 3) in mountinfo will show /a/b.  So as to
not confuse the cgroup calculation, check for nsroot=/a/b in the
last field, which will allow us to disambiguate between a mount
like above, and a bind mount of the /a/b cgroup directory.

Signed-off-by: Serge Hallyn <[email protected]>
  • Loading branch information
hallyn committed Mar 26, 2016
1 parent 519529f commit 9285fbd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libcontainer/cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ func getCgroupMountsHelper(ss map[string]bool, mi io.Reader) ([]Mount, error) {
if ss[opt] {
m.Subsystems = append(m.Subsystems, opt)
}
if strings.HasPrefix(opt, "nsroot=") {
nsroot := opt[7:]
if len(nsroot) > 1 && strings.HasPrefix(m.Root, nsroot) {
m.Root = m.Root[len(nsroot):]
}
}
}
res = append(res, m)
}
Expand Down

0 comments on commit 9285fbd

Please sign in to comment.