[libvirt] VM cpuTime from libvirt

Zvi Dubitzky DUBI at il.ibm.com
Sun Mar 22 12:28:00 UTC 2009


Currently the  cat  /proc/pid/stat    where pid is the pid of the VM Qemu 
process gives the utime + stime of the  VM according to libvirt.

Unfortunately I notice  that this is actually the elapsed time of the host 
 . I find this by using libvirt  , sampling  the cputime of each VM 
process and compare it to the total elapsed time (of the Host Linux 
machine) . Roughly  assuming full VM vcpu utlization,  the cpu utilization 
of every VM is actually : ( # of VM  vcpus / total  # of Host cpus) .This 
implies that there is  no  idle time per VM (while actually there is) . We 
only know the idle time of the  Host via the  top command  at the Host .
Is the cputime of a VM (from cat /proc/pid/stat of the Qemu process as 
used by libvirt)  realy the cputime of the VM ?

I  tested with  a host having 2 sockets  X 4cpus =8  totally and assigned 
4 cpus to  VM1 and VM2 . libvirt gave equal cputime for each VM  which is 
equal to the total machine elapsed time. But even if  VM1 has 4 vcpus and 
VM2 have 8 vcpus the cputime of each VM 
(from cat  /proc/pid/stat)  is the elapsed time.

The truth is that I am running the libvirt application on the host machine 
and do the application wait there . Should that  matter much?

Each  guest idle time  is needed from the KVM for real cpu utilization 
calc   to be independent from the guest OS .
At least for Linux we can manually run 'top'  at  each guest  terminal 
window , but I do not know if it will show the real idle time or the total 
machine (host) idle time .At least linux has no idle process . Besides 
this is not a good programmatic way  to get the VM idle time.

Is there a cure or I am missing something ?

thanks

Zvi Dubitzky 
Virtualization and System Architecture   Email:dubi at il.ibm.com
IBM Haifa Research Laboratory    Phone: +972-4-8296182
Haifa, 31905, ISRAEL 





More information about the libvir-list mailing list