[libvirt] [RFC][PATCHv1 2/5] libvirt - new API for getting percpu statistics of VM

Matthias Bolte matthias.bolte at googlemail.com
Fri Apr 15 07:43:15 UTC 2011


2011/4/15 KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com>:
> Per (host) cpu activity of VMs are very insterested numbers
> when running VMs on large SMPs. virt-top -1 mode tries to
> provide the information. (But it's not implemented.)
>
> This patch adds a libvirt interface to get per cpu statistics
> of each nodes. This patch just adds an interface and driver
> entry points. So,
>  - doesn't include patches for python.
>  - doesn't include any driver.
>
> Following patches will add some drivers and codes for python.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com>
> ---
>  include/libvirt/libvirt.h.in |   13 ++++++++++
>  src/driver.h                 |    6 ++++
>  src/esx/esx_driver.c         |    1 +
>  src/libvirt.c                |   55 ++++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms      |    4 +++
>  src/libxl/libxl_driver.c     |    1 +
>  src/lxc/lxc_driver.c         |    1 +
>  src/openvz/openvz_driver.c   |    1 +
>  src/phyp/phyp_driver.c       |    1 +
>  src/qemu/qemu_driver.c       |    1 +
>  src/remote/remote_driver.c   |    1 +
>  src/test/test_driver.c       |    1 +
>  src/uml/uml_driver.c         |    1 +
>  src/vbox/vbox_tmpl.c         |    1 +
>  src/vmware/vmware_driver.c   |    1 +
>  src/xen/xen_driver.c         |    1 +
>  src/xenapi/xenapi_driver.c   |    1 +
>  17 files changed, 91 insertions(+), 0 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 5783303..6b9292c 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -400,6 +400,13 @@ struct _virDomainMemoryStat {
>
>  typedef virDomainMemoryStatStruct *virDomainMemoryStatPtr;
>
> +typedef struct _virDomainPcpuStat virDomainPcpuStatStruct;
> +
> +struct _virDomainPcpuStat {
> +    unsigned long long cpuTime;
> +};
> +

NACK to adding another public struct to the API. It's not expendable.
As a stylistic nit pleas don't use the term PCPU as this looks like
"Physical CPU". Just call it virDomainPerVcpuStat at least.

Also do you really need the absolute CPU time? As noted elsewhere,
this is in fact not implementable for ESX. But ESX can provide the
virtual CPU utilization in MHz and percent.

See the virNodeGetCpuTime series [1] for a better approach.

[1] https://www.redhat.com/archives/libvir-list/2011-April/msg00702.html

Matthias




More information about the libvir-list mailing list