[libvirt] cgroup limits only affect kvm guest under certain conditions

KAMEZAWA Hiroyuki kamezawa.hiroyu at jp.fujitsu.com
Fri Jan 7 06:07:06 UTC 2011


On Thu, 06 Jan 2011 14:15:37 +0100
Dominik Klein <dk at in-telegence.net> wrote:

> Hi
> 
> I am playing with cgroups and try to limit block io for guests.
> 
> The proof of concept is:
> 
> # mkdir /dev/cgroup/blkio
> # mount -t cgroup -o blkio blkio /dev/cgroup/blkio/
> # cd blkio/
> # mkdir test
> # cd test/
> # ls -l /dev/vdisks/kirk
> lrwxrwxrwx 1 root root 7 2011-01-06 13:46 /dev/vdisks/kirk -> ../dm-5
> # ls -l /dev/dm-5
> brw-rw---- 1 root disk 253, 5 2011-01-06 13:36 /dev/dm-5
> # echo "253:5  1048576" > blkio.throttle.write_bps_device
> # echo $$ > tasks
> # dd if=/dev/zero of=/dev/dm-5 bs=1M count=20
> 20+0 records in
> 20+0 records out
> 20971520 bytes (21 MB) copied, 20.0223 s, 1.0 MB/s
> 
> So limit applies to the dd child of my shell.
> 
> Now I assign /dev/dm-5 (/dev/vdisks/kirk) to a vm and echo the qemu-kvm
> pid into tasks. Limits are not applied, the guest can happily use max io
> bandwidth.
> 

qemu consists of several threads. Cgroup works per thread now.
Could you double check "all threads for qemu" are in a cgroup ?
I think you have to write all thread-ID to "tasks" file when you
move qemu after starting it.

Thanks,
-Kame





More information about the libvir-list mailing list