I can reproduce this bug on RHEL9
Version:
Kernel-5.14.0-7.el9.x86_64
libvirt-7.8.0-1.el9.x86_64
qemu-kvm-6.1.0-5.el9.x86_64
1. Prepare a running vm.
# virsh domstate $vm
running
2. Provide cpu statistics information of a domain.
# virsh cpu-stats $vm
Actual results:
error: Failed to retrieve CPU statistics for domain 'rhel9.0-2'
error: Operation not supported: operation 'getCpuacctPercpuUsage' not supported for backend 'cgroup V2'
Additional info:
Before running #virsh cpu-stats $vm the libvirtd’s status is running
After the error happened, I ran #systemctl status libvirtd and it shows libvirtd’s status is dead.
+++ This bug was initially created as a clone of Bug #1796543 +++
Description of problem: 'virsh cpu-stats ...' does not work with cgroup v2. The command fails with the error 'operation 'getCpuacctPercpuUsage' not supported'. On further analysis I see that a function 'getCpuacctPercpuUsage' is not registered in the backend 'virCgroupV2Backend'.
Version-Release number of selected component (if applicable):5.6.0
How reproducible:
Steps to Reproduce:
1. Bring up VMs through QEMU
2. Issue a 'virsh cpu-stats <domain-name>'
Actual results: operation 'getCpuacctPercpuUsage' not supported'
Expected results: Display the CPU-stats per cpu.
Additional info:
--- Additional comment from Pavel Hrdina on 2020-01-30 17:35:37 UTC ---
Unfortunately there is nothing we can do to provide the per-CPU stats.
With cgroups v1 there was cpuacct.usage_percpu file where we could get the data from but with cgroups v2 there is no such interface.
The latest kernel documentation for CPU controller <https://www.kernel.org/doc/html/v5.5/admin-guide/cgroup-v2.html#cpu>.
The only think we can do is to not call that function and return CPU usage stats for all CPUs which we can get from cgroups v2
--- Additional comment from Ramkumar on 2020-01-30 17:45:17 UTC ---
I understand and agree that it would be good to prevent calling the PercpuUsage function and just call the usage stats for all the CPUs. Could this be taken up in a future release?
--- Additional comment from Daniel Berrangé on 2020-02-03 11:34:21 UTC ---
(In reply to Pavel Hrdina from comment #1)
> Unfortunately there is nothing we can do to provide the per-CPU stats.
>
> With cgroups v1 there was cpuacct.usage_percpu file where we could get the
> data from but with cgroups v2 there is no such interface.
> The latest kernel documentation for CPU controller
> <https://www.kernel.org/doc/html/v5.5/admin-guide/cgroup-v2.html#cpu>.
>
> The only think we can do is to not call that function and return CPU usage
> stats for all CPUs which we can get from cgroups v2
I wonder what the kernel maintainers recommend as a replacement for this lost functionality, if any ? eg is there perhaps a non-cgroups based way of getting what we want, or have they decided this info can never be provided to apps ?
--- Additional comment from Satheesh Rajendran on 2020-02-14 12:22:08 UTC ---
Am hitting the same issue too, just adding the env details.
Host kernel: 5.5.0-g7e7c42aa3
Libvirt: libvirt-6.1.0-1.fc31.ppc64le(compiled against, c246cfc4869096b773b697f5af899dbfd776fde7)
Regards,
-Satheesh
Comment 1Jaroslav Suchanek
2021-10-21 13:20:48 UTC
Pavel would be please check it? If there is really nothing what can be done about, lets close it. Thanks.