]> git.proxmox.com Git - mirror_lxc.git/commit - src/lxc/cgroup.c
cgroup: Major rewrite of cgroup logic
authorChristian Seiler <christian@iwakd.de>
Sun, 8 Sep 2013 18:50:03 +0000 (20:50 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 10 Sep 2013 22:19:21 +0000 (18:19 -0400)
commit33ad9f1ab13de51d28aecbcbdac086ea009a1740
treea5f3ec893b19698fd5d47f1a0cb6a17dbe1a5c93
parentbfa3f007370adf755c7960d1c854e6064c40cf6a
cgroup: Major rewrite of cgroup logic

This patch rewrites most of the cgroup logic. It creates a set of data
structures to store the kernel state of the cgroup hierarchies and
their mountpoints.

Mainly, everything is now grouped with respect to the hierarchies of
the system. Multiple controllers may be mounted together or separately
to different hierarchies, the data structures reflect this.

Each hierarchy may have multiple mount points (that were created
previously using the bind mount method) and each of these mount points
may point to a different prefix inside the cgroup tree. The current
code does not make any assumptions regarding the mount points, it just
parses /proc/self/mountinfo to acquire the relevant information.

The only requirement is that the current cgroup of either init (if
cgroup.pattern starts with '/' and the tools are executed as root) or
the current process (otherwise) are accessible. The root cgroup need
not be accessible.

The configuration option cgroup.pattern is introduced. For
root-executed containers, it specifies which format the cgroups should
be in. Example values may include '/lxc/%n', 'lxc/%n', '%n' or
'/machine/%n.lxc'. Any occurrence of '%n' is replaced with the name of
the container (and if clashes occur in any hierarchy, -1, -2, etc. are
appended globally). If the pattern starts with /, new containers'
cgroups will be located relative to init's cgroup; if it doesn't, they
will be located relative to the current process's cgroup.

Some changes to the cgroup.h API have been done to make it more
consistent, both with respect to naming and with respect to the
parameters. This causes some changes in other parts of the code that
are included in the patch.

There has been some testing of this functionality, but there are
probably still quite a few bugs in there, especially for people with
different configurations.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
13 files changed:
src/lxc/attach.c
src/lxc/cgroup.c
src/lxc/cgroup.h
src/lxc/commands.c
src/lxc/freezer.c
src/lxc/lxc.h
src/lxc/lxccontainer.c
src/lxc/lxcutmp.c
src/lxc/start.c
src/lxc/start.h
src/lxc/state.c
src/lxc/utils.c
src/tests/cgpath.c