Skip to content

Commit

Permalink
cgfs: do not automount if cgroup namespaces are supported
Browse files Browse the repository at this point in the history
In that case containers will be able to mount cgroup filesystems
for themselves as they do on a host.

This fixes inability to start systemd based containers on cgns-enabled
kernels with cgmanager not running.

I've tested debian jessie, busybox, ubuntu trusty and xenial, all of
which booted ok.  However if there are some setups which require
premounted cgroupfs (i.e. they don't mount if they detect being in
a container), this may cause trouble.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
hallyn committed Feb 25, 2016
1 parent 55290b8 commit 4608594
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion doc/lxc.container.conf.sgml.in
Expand Up @@ -912,7 +912,7 @@ proc proc proc nodev,noexec,nosuid 0 0
the container's own cgroup into that directory.
The container will be able to write to its own
cgroup directory, but not the parents, since they
will be remounted read-only
will be remounted read-only.
</para>
</listitem>
<listitem>
Expand Down Expand Up @@ -986,6 +986,12 @@ proc proc proc nodev,noexec,nosuid 0 0
</para>
</listitem>
</itemizedlist>
<para>
If cgroup namespaces are enabled, then any <option>cgroup</option>
auto-mounting request will be ignored, since the container can
mount the filesystems itself, and automounting can confuse the
container init.
</para>
<para>
Note that if automatic mounting of the cgroup filesystem
is enabled, the tmpfs under
Expand Down
3 changes: 3 additions & 0 deletions src/lxc/cgfs.c
Expand Up @@ -1356,6 +1356,9 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
struct cgroup_process_info *info, *base_info;
int r, saved_errno = 0;

if (cgns_supported())
return true;

cgfs_d = hdata;
if (!cgfs_d)
return false;
Expand Down

0 comments on commit 4608594

Please sign in to comment.