How to modify cgroup trees of LXCs and VMs?

Unfazed4088

New Member
Jan 12, 2025
4
1
3
Code:
root@node-1:~# systemd-cgls --no-pager
CGroup /:
-.slice
├─qemu.slice
│ └─200.scope
│   └─3089943 /usr/bin/kvm -id 200 -name vm-01,debug-threads=on -no-shutdown -chardev socket,id=qmp,path=/v…
├─init.scope
│ └─1 /sbin/init
├─system.slice
│ └─<truncated system stuff>
├─lxc
│ ├─100
│ │ └─ns
│ │   ├─.lxc
│ │   │ └─2959216 /bin/bash
│ │   ├─init.scope
│ │   │ └─7902 /sbin/init
│ │   └─system.slice
│ │     └─ <container stuff truncated>
│ ├─101
      └─ns
          <continues for all CTIDs>


I want to have VMs and LXCs be under a single cgroup tree so I can have them all share an IOPS limit. They all share the same storage pool, the consumer SATA SSDs are very limited by IOPS and get really bad latency once they hit their limit. I was hoping I could just apply the limit on on the system.slice, but neither the qemu.slice or the lxc tree are children of it. So, I need to create a new slice and move qemu.slice and the lxc tree to them so I can apply the iops limit and have them both share it.
 
Last edited:
Hi!

There is no simple way to move VMs and CTs under a single root cgroup as for VMs the code already depends on the VM's cgroups to be under the /qemu.slice cgroup and the /lxc cgroup is given by LXC itself, which has many intricacies that make this a requirement. So it can only be limited for both individually but not as an aggregate.

Unfortunately blk-throttle seems to be only configurable by cgroups themselves, but there might be tweaks to throttle the IOPS through some device mapper or other kernel parameters, but I haven't looked into this too deeply.