Hi! I'm comparing the cpu usage of a VM from virDomainGetInfo and the usages returned per-vcpu from virDomainGetVcpus and the totals do not match up. I expect that the cpu usages reported per-vcpu, when summed, should equal the total cpu usage of the domain, but there is quite a large gap between them. Is there something I'm missing? See this example code using the python bindings:>>> import libvirt >>> c = libvirt.open('qemu:///system') >>> d = c.lookupByID(51) >>> d.info()[4]111390000000L>>> d.vcpus()[0][(0, 1, 12720000000L, 1), (1, 1, 2980000000L, 0), (2, 1, 3150000000L, 1), (3, 1, 2600000000L, 0)]>>> sum([vcpu[2] for vcpu in d.vcpus()[0]])21520000000L>>> d.info()[4] - sum([vcpu[2] for vcpu in d.vcpus()[0]])91760000000L Why is this additional 91 seconds not reflected in time spent by the vcpus? What exactly is the meaning of the cpuTime parameter of the virVcpuInfo struct? Thanks, --Igor -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20110913/3a52bd39/attachment.sig>
On 09/13/2011 03:46 PM, Igor Serebryany wrote:> Hi! > > I'm comparing the cpu usage of a VM from virDomainGetInfo and the > usages returned per-vcpu from virDomainGetVcpus and the totals do > not match up. > > I expect that the cpu usages reported per-vcpu, when summed, should > equal the total cpu usage of the domain, but there is quite a large > gap between them. Is there something I'm missing?Yes - emulation overhead. That is, there is some work done by the hypervisor process itself but not directly attributable to any of the work done by the vcpus visible in the guest. For example, in qemu, the time spent in opening qcow2 files counts against the overall domain time, but not towards any of the vcpu times.> Why is this additional 91 seconds not reflected in time spent by the > vcpus? What exactly is the meaning of the cpuTime parameter of the > virVcpuInfo struct?How much total time has been occupied by the overall hypervisor instance running the domain, which is probably larger than the amount of vcpu time racked up from the child's point of view. The smaller the overhead, the more efficient the virtualization. -- Eric Blake eblake at redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Maybe Matching Threads
- cpuTimes and qemu-kvm on F13
- Re: [PATCH Fedora libguestfs] Don't depend on libvirt-daemon-kvm monolith.
- [PATCH Fedora libguestfs] Don't depend on libvirt-daemon-kvm monolith.
- [API reference] confused by CPU time term
- python-libvirt for 0.9.3 leaking file descriptors