Skip to content
Snippets Groups Projects
Commit 96f9aae6 authored by Guido Günther's avatar Guido Günther
Browse files

Make mounted cgroups configurable

via /etc/default/libvirt-bin and check for memory
cgroup on kernel command line.

Closes: #732666
parent 949fae6f
No related branches found
No related tags found
No related merge requests found
...@@ -13,3 +13,5 @@ start_libvirtd="yes" ...@@ -13,3 +13,5 @@ start_libvirtd="yes"
# Whether to mount a systemd like cgroup layout (only # Whether to mount a systemd like cgroup layout (only
# useful when not running systemd) # useful when not running systemd)
#mount_cgroups=yes #mount_cgroups=yes
# Which cgroups to mount
#cgroups="memory devices"
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
### END INIT INFO ### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH
DAEMON=/usr/sbin/libvirtd DAEMON=/usr/sbin/libvirtd
NAME=libvirtd NAME=libvirtd
DESC="libvirt management daemon" DESC="libvirt management daemon"
MOUNTS="cpuset cpu cpuacct memory devices freezer net_cls blkio perf_event" cgroups="cpuset cpu cpuacct memory devices freezer net_cls blkio perf_event"
export PATH ! grep -qs cgroup_enable=memory /proc/cmdline || cgroups="$cgroups memory"
test -x $DAEMON || exit 0 test -x $DAEMON || exit 0
. /lib/lsb/init-functions . /lib/lsb/init-functions
...@@ -81,7 +82,7 @@ mount_cgroups() ...@@ -81,7 +82,7 @@ mount_cgroups()
if ! systemd_running if ! systemd_running
then then
mount -t tmpfs cgroup_root /sys/fs/cgroup || return 1 mount -t tmpfs cgroup_root /sys/fs/cgroup || return 1
for M in $MOUNTS; do for M in $cgroups; do
mkdir /sys/fs/cgroup/$M || return 1 mkdir /sys/fs/cgroup/$M || return 1
mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,$M "cgroup_${M}" "/sys/fs/cgroup/${M}" || return 1 mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,$M "cgroup_${M}" "/sys/fs/cgroup/${M}" || return 1
done done
...@@ -95,7 +96,7 @@ umount_cgroups() ...@@ -95,7 +96,7 @@ umount_cgroups()
{ {
if ! systemd_running if ! systemd_running
then then
for M in $MOUNTS; do for M in $cgroups; do
umount "cgroup_${M}" umount "cgroup_${M}"
rmdir /sys/fs/cgroup/$M rmdir /sys/fs/cgroup/$M
done done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment