When running 'virt-top -1' , "show percpu statistics mode", 
virt-top shows a fake value.

When running 'while true; do echo hello;done' on a 4vcpu guest,
==
   0    0.0
   1    0.0
   2    0.0
   3    0.0
   4   25.0 25.0=
   5   25.0 25.0=#
   6   25.0 25.0=
   7   25.0 25.0=

==

All cpus just used equally ;)

This is because there is no interface to get per-cpu usage of domain.
This patch adds an interface virDomainPcpuStats() to get per-cpu
statistics, cpuTime in nanoseconds.

Here is a test result with a python script using new interface.
==
[root@bluextal python]# ./virt-cpuacct.py
({'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, 
{'cpuTime': 4679204346L}, {'cpuTime': 2103820380L}, {'cpuTime': 8904513019L}, 
{'cpuTime': 7424701195L})
[root@bluextal python]# ./virt-cpuacct.py
({'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, 
{'cpuTime': 57010689139L}, {'cpuTime': 26152907202L}, {'cpuTime': 
53759693931L}, {'cpuTime': 43074348218L})
==

Although I added a new interface, I still wonder what interface is better...
any comments are welcome.

Thanks,
-Kame

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to