mirror of https://github.com/containers/podman.git
systemd, cgroupsv2: not bind mount /sys/fs/cgroup/systemd
when running on a cgroups v2 system, do not bind mount the named hierarchy /sys/fs/cgroup/systemd as it doesn't exist anymore. Instead bind mount the entire /sys/fs/cgroup. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
a622f8d345
commit
223fe64dc0
|
@ -466,30 +466,48 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
|
||||||
g.AddMount(tmpfsMnt)
|
g.AddMount(tmpfsMnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rootless containers have no write access to /sys/fs/cgroup, so don't
|
unified, err := cgroups.IsCgroup2UnifiedMode()
|
||||||
// add any mount into the container.
|
if err != nil {
|
||||||
if !rootless.IsRootless() {
|
return err
|
||||||
cgroupPath, err := c.CGroupPath()
|
}
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
sourcePath := filepath.Join("/sys/fs/cgroup/systemd", cgroupPath)
|
|
||||||
|
|
||||||
|
g.RemoveMount("/sys/fs/cgroup")
|
||||||
|
|
||||||
|
if unified {
|
||||||
|
sourcePath := filepath.Join("/sys/fs/cgroup")
|
||||||
systemdMnt := spec.Mount{
|
systemdMnt := spec.Mount{
|
||||||
Destination: "/sys/fs/cgroup/systemd",
|
Destination: "/sys/fs/cgroup",
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: sourcePath,
|
Source: sourcePath,
|
||||||
Options: []string{"bind", "private"},
|
Options: []string{"bind", "private", "rw"},
|
||||||
}
|
}
|
||||||
g.AddMount(systemdMnt)
|
g.AddMount(systemdMnt)
|
||||||
} else {
|
} else {
|
||||||
systemdMnt := spec.Mount{
|
// rootless containers have no write access to /sys/fs/cgroup, so don't
|
||||||
Destination: "/sys/fs/cgroup/systemd",
|
// add any mount into the container.
|
||||||
Type: "bind",
|
if !rootless.IsRootless() {
|
||||||
Source: "/sys/fs/cgroup/systemd",
|
cgroupPath, err := c.CGroupPath()
|
||||||
Options: []string{"bind", "nodev", "noexec", "nosuid"},
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sourcePath := filepath.Join("/sys/fs/cgroup", cgroupPath)
|
||||||
|
|
||||||
|
systemdMnt := spec.Mount{
|
||||||
|
Destination: "/sys/fs/cgroup",
|
||||||
|
Type: "bind",
|
||||||
|
Source: sourcePath,
|
||||||
|
Options: []string{"bind", "private"},
|
||||||
|
}
|
||||||
|
g.AddMount(systemdMnt)
|
||||||
|
} else {
|
||||||
|
systemdMnt := spec.Mount{
|
||||||
|
Destination: "/sys/fs/cgroup",
|
||||||
|
Type: "bind",
|
||||||
|
Source: "/sys/fs/cgroup",
|
||||||
|
Options: []string{"bind", "nodev", "noexec", "nosuid"},
|
||||||
|
}
|
||||||
|
g.AddMount(systemdMnt)
|
||||||
}
|
}
|
||||||
g.AddMount(systemdMnt)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue