.`virsh blkiotune --weight` command fails to set the correct cgroup I/O controller value
Currently, using the `virsh blkiotune --weight` command to set the VM weight does not work as expected. The command fails to set the correct `io.bfq.weight` value in the cgroup I/O controller interface file. There is no workaround at this time.
Description:
[cgroup] 'blkiotune --weight' will set a wrong value to io.bfq.weight
Versions:
libvirt-7.4.0-1.el9.x86_64
systemd-248-5.el9.x86_64
How reproducible:
100%
Steps:
1. have a running vm = 'vm1'
2. Set its weight to 119
[root@libvirt-rhel-9 ~]# virsh blkiotune vm1 --weight 119
ERROR HAPPENS HERE: we got a 12 but not a 119 in xml/blkiotune/cgroup
[root@libvirt-rhel-9 ~]# virsh dumpxml vm1 | grep weight
<weight>12</weight>
[root@libvirt-rhel-9 ~]# cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d1\\x2dvm1.scope/io.bfq.weight
default 12
[root@libvirt-rhel-9 ~]# virsh blkiotune vm1
weight : 12
3. try some other values, all incorrect
[root@libvirt-rhel-9 ~]# virsh blkiotune vm1 --weight 131
[root@libvirt-rhel-9 ~]# cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d1\\x2dvm1.scope/io.bfq.weight
default 14
[root@libvirt-rhel-9 ~]# virsh blkiotune vm1 --weight 9
[root@libvirt-rhel-9 ~]# cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d1\\x2dvm1.scope/io.bfq.weight
default 1
Expected result:
cgroup io.bfq.weight should be set as the blkiotune cmd
Actual result:
It's quite like follow a logic:
cgroup_io_bfq_weight = math.ceil(blkiotune_cmd_weight/10)
Unfortunately there is nothing we can do in libvirt to fix this.
In order to set the IO weight for VMs in RHEL properly we have to use systemd DBus APIs. Libvirt properly calls the API with the value requested by user. After that it's up to systemd to write the value to the io.bfq.weight file.
Until systemd 248 it was doing exactly that, however there was an issue with that approach. In kernel io.weight has range [1, 10000] but that interface file is not currently present, instead we have io.bfq.weight which has different range [1, 1000] but both are controlled using the same IOWeight systemd property because the io.bfq.weight should be eventually removed and io.weight will be used. Because of all this there is no simple solution to the messed up situation. If user would requested IO weight larger then 1000 it would fail so systemd starting with version 248 coverts the value to fit withing the smaller range.
This will be most likely fixed once we will get rid of the io.bfq.weight and we will have only io.weight, but I don't know when that happens.
From libvirt POV we can only document this unfortunate behavior.
Comment 4yalzhang@redhat.com
2022-11-14 01:34:39 UTC
According to comment 2, move this bug to documentation.
Description: [cgroup] 'blkiotune --weight' will set a wrong value to io.bfq.weight Versions: libvirt-7.4.0-1.el9.x86_64 systemd-248-5.el9.x86_64 How reproducible: 100% Steps: 1. have a running vm = 'vm1' 2. Set its weight to 119 [root@libvirt-rhel-9 ~]# virsh blkiotune vm1 --weight 119 ERROR HAPPENS HERE: we got a 12 but not a 119 in xml/blkiotune/cgroup [root@libvirt-rhel-9 ~]# virsh dumpxml vm1 | grep weight <weight>12</weight> [root@libvirt-rhel-9 ~]# cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d1\\x2dvm1.scope/io.bfq.weight default 12 [root@libvirt-rhel-9 ~]# virsh blkiotune vm1 weight : 12 3. try some other values, all incorrect [root@libvirt-rhel-9 ~]# virsh blkiotune vm1 --weight 131 [root@libvirt-rhel-9 ~]# cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d1\\x2dvm1.scope/io.bfq.weight default 14 [root@libvirt-rhel-9 ~]# virsh blkiotune vm1 --weight 9 [root@libvirt-rhel-9 ~]# cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d1\\x2dvm1.scope/io.bfq.weight default 1 Expected result: cgroup io.bfq.weight should be set as the blkiotune cmd Actual result: It's quite like follow a logic: cgroup_io_bfq_weight = math.ceil(blkiotune_cmd_weight/10)