Cgroups with KVM and Libvirt

From SlackWiki
Revision as of 14:59, 11 May 2015 by Crudo (talk | contribs) (Created page with "=Using cgroups in Slackware with KVM/Libvirt= Hello friends, I’ve been using KVM a lot of months until now and every new host server that I create I need to change the way...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Using cgroups in Slackware with KVM/Libvirt

Hello friends, I’ve been using KVM a lot of months until now and every new host server that I create I need to change the way of how Slackware seems to create cgroups, libvirt doesn’t function very good if you don’t create specific directories in ‘/sys/fs/cgroup’ tree. So, to do that for me I made this script below

# cat /etc/rc.d/rc.cgroup

#!/bin/sh
#
# /etc/rc.d/rc.cgroup: cgroups init script
# Alexandre Mulatinho <alex@mulatinho.net>
# Unmount /sys/fs/cgroup
umount /sys/fs/cgroup

# Mount cgroup_root in /sys/fs/cgroup
mount -t tmpfs -o mode=755,rw cgroup_root /sys/fs/cgroup/

# Mount all the subsystems available in /sys/fs/cgroup as individual directory
for i in $(lssubsys -a);
do
        mkdir -pv /sys/fs/cgroup/$i
        mount -v -t cgroup -o $i $i /sys/fs/cgroup/$i
done

# chmod u+x /etc/rc.d/rc.cgroup

And now everytime my slackware system boot, my cgroups tree are build in right way that KVM and libvirt can use him to manipulate things like memory, cpu, io, disk, etc. Hope it helps someone else :-)