Dear list, I am building a Arch server on my Arch box. My tools are QEMU/KVM and libvirt to manage the guest, systemd as system manager. I am looking at implementing the Linux Control Groups facilities for resource management. Even after long hours of reading, I am not quite sure about how to deal with the cgroups facilities. First, do I really need to care about all that, or libvirt and systemd will manage the resource in an efficient way right out of the box? If not, It's all about /etc/cgconfig.conf and cgrules.conf. I am honestly not sure : -what are the correct mount points for cpu, memory etc in the /sys/fs/cgroup directory . - which directories am I supposed to mk, if any ? Then, Archwiki[1] says: # cgcreate -a $USER -g memory,cpu:groupname - what is the groupename I shall create (qemu*, MyMachine) ? - which $USER shall I use (qemu*, my username) ? * qemu:qemu as user:group in /etc/libvirt/qemu.conf Thank you for some help as I admit if I understand the cgroups principle and advantages, I am far from understanding how to create such a group in case of a VM. [1]https://wiki.archlinux.org/index.php/Cgroups
On Mon, Feb 10, 2014 at 12:29 AM, arnaud gaboury <arnaud.gaboury@gmail.com> wrote:> Dear list, > > I am building a Arch server on my Arch box. > My tools are QEMU/KVM and libvirt to manage the guest, systemd as > system manager. > > I am looking at implementing the Linux Control Groups facilities for > resource management. Even after long hours of reading, I am not quite > sure about how to deal with the cgroups facilities. > > First, do I really need to care about all that, or libvirt and systemd > will manage the resource in an efficient way right out of the box? > > If not, It's all about /etc/cgconfig.conf and cgrules.conf. I am > honestly not sure : > -what are the correct mount points for cpu, memory etc in the > /sys/fs/cgroup directory . > - which directories am I supposed to mk, if any ? > > Then, Archwiki[1] says: > > # cgcreate -a $USER -g memory,cpu:groupname > > > - what is the groupename I shall create (qemu*, MyMachine) ? > - which $USER shall I use (qemu*, my username) ? > > * qemu:qemu as user:group in /etc/libvirt/qemu.conf > > Thank you for some help as I admit if I understand the cgroups > principle and advantages, I am far from understanding how to create > such a group in case of a VM. > > [1]https://wiki.archlinux.org/index.php/CgroupsAfter more reading, especially the Fedora Resource Management Guide[1], here is my /etc/cgconfig.conf: group dahlia { perm { # who can manage limits admin { uid = 1000; gid = 1004; } # who can add task task { uid = 1000; gid = 1004; } } # create this group in the controllers cpu { } cpuset { } memory { } devices { } freezer { } net_cls { } blkio { } } * NOTES : 1004 is qemu user ; dahlia is the name of the guest machine ; all dahlia controllers are created and mounted at boot in /sys/fs/cgroup/$CONTROLLER-NAME/dahlia $ systemctl status cgconfig.service returns no errors, so these settings sound OK. But now I am not sure how I can use these settings with libvirt. I have problems understanding well The libvirt Control Groups Resource Management page[2] It is the first time I do such a setup (using cgroups & systemd) for a VM, so thank you for help. [1]http://docs.fedoraproject.org/en-US/Fedora/17/html-single/Resource_Management_Guide/index.html#sec-How_Control_Groups_Are_Organized [2]http://libvirt.org/cgroups.html#legacyLayout
On Mon, Feb 10, 2014 at 12:29:10AM +0100, arnaud gaboury wrote:> Dear list, > > I am building a Arch server on my Arch box. > My tools are QEMU/KVM and libvirt to manage the guest, systemd as > system manager. > > I am looking at implementing the Linux Control Groups facilities for > resource management. Even after long hours of reading, I am not quite > sure about how to deal with the cgroups facilities. > > First, do I really need to care about all that, or libvirt and systemd > will manage the resource in an efficient way right out of the box?The precise answer depends on which version of systemd you have. In any systemd host though, systemd should ensure all the filesystems are mounted correctly. If you have libvirt >= 1.1.1 and systemd >= 205 then you can use its "slice" and "scope" concepts to setup grouping of VMs. If you have older systemd, then you have to setup groups manually. There's some guidance on setting up groups here http://libvirt.org/cgroups.html If you have systemd >= 205 then you can ignore cgconfig.conf entirely. For earlier version, you can use cgconfig.conf to setup the groups only. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
> The precise answer depends on which version of systemd you have. In > any systemd host though, systemd should ensure all the filesystems > are mounted correctly. If you have libvirt >= 1.1.1 and systemd >= 205 > then you can use its "slice" and "scope" concepts to setup grouping > of VMs. If you have older systemd, then you have to setup groups > manually. There's some guidance on setting up groups here > > http://libvirt.org/cgroups.html > > If you have systemd >= 205 then you can ignore cgconfig.conf entirely.systemd 208-10 and libvirt 1.2.1-1 So you are telling me I spent hours and hours of reading for nothing ? GGGrrhhh. I use the slice concept (or partition map) with this file : machine-dahlia.slice I have been reading and reading again your mentioned link, and I think it is the correct thing to do. But this part puzzles me: Systemd slice naming The systemd convention for slice naming is that a slice should include the name of all of its parents prepended on its own name. So for a libvirt partition /machine/engineering/testing, the slice name will be machine-engineering-testing.slice. Again the slice names map directly to the cgroup directory names. Systemd creates three top level slices by default, system.slice user.slice and machine.slice. All virtual machines or containers created by libvirt will be associated with machine.slice by default. Following above lines, I am thus not sure of the correct name of my .slice systemd file. When trying to avoid any issue, the guest is on the root of my filesystem in /dhalia. directory. This directory is owned by gabx:qemu (not sure it is useful, but when I created it, it came with these owners)