cgroups: add support for systemd cgroup hierarchy

The systemd cgroup hierarchy support is being added so we can run
logind outside of systemd. This is needed because software that was
using consolekit is now migrating to logind.
We do not create this hierarchy, we just add services to it if it
exists.
This commit is contained in:
William Hubbs 2013-06-25 10:50:13 -05:00
parent 02a7d3573d
commit 2391ddff77
2 changed files with 10 additions and 4 deletions

View File

@ -70,15 +70,17 @@ cgroup_set_values()
return 0 return 0
} }
cgroup_set_limits() cgroup_add_service()
{ {
openrc_cgroup=/sys/fs/cgroup/openrc if [ -d "$1" ]; then
if [ -d "$openrc_cgroup" ]; then cgroup="$1/$RC_SVCNAME"
cgroup="$openrc_cgroup/$RC_SVCNAME"
mkdir -p "$cgroup" mkdir -p "$cgroup"
[ -f "$cgroup/tasks" ] && echo 0 > "$cgroup/tasks" [ -f "$cgroup/tasks" ] && echo 0 > "$cgroup/tasks"
fi fi
}
cgroup_set_limits()
{
local blkio="${rc_cgroup_blkio:-$RC_CGROUP_BLKIO}" local blkio="${rc_cgroup_blkio:-$RC_CGROUP_BLKIO}"
[ -n "$blkio" ] && cgroup_set_values blkio "$blkio" [ -n "$blkio" ] && cgroup_set_values blkio "$blkio"

View File

@ -209,6 +209,10 @@ sourcex -e "@SYSCONFDIR@/rc.conf"
[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT} [ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT}
# Apply cgroups settings if defined # Apply cgroups settings if defined
if [ "$(command -v cgroup_add_service)" = "cgroup_add_service" ]; then
cgroup_add_service /sys/fs/cgroup/openrc
cgroup_add_service /sys/fs/cgroup/systemd/system
fi
[ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] && \ [ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] && \
cgroup_set_limits cgroup_set_limits