[libvirt] [PATCH 2/6] domMemoryStats: Add public symbol to libvirt API

Daniel P. Berrange berrange at redhat.com
Thu Dec 17 10:37:12 UTC 2009


On Fri, Dec 11, 2009 at 03:26:13PM -0500, Adam Litke wrote:
> Add a new function 'virDomainMemoryStats' to the libvirt API.  Export it via
> libvirt_public.syms
> 
> Signed-off-by: Adam Litke <agl at us.ibm.com>
> To: libvirt list <libvir-list at redhat.com>
> ---
>  src/libvirt.c           |   64 +++++++++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms |    2 +
>  2 files changed, 66 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index b14942d..0af1ee3 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -4045,6 +4045,70 @@ error:
>  }
>  
>  /**
> + * virDomainMemStats:
> + * @dom: pointer to the domain object
> + * @stats: nr_stats-sized array of stat structures (returned)
> + * @nr_stats: number of memory statistics requested
> + * 
> + * This function provides memory statistics for the domain.
> + *
> + * Up to 'nr_stats' elements of 'stats' will be populated with memory statistics
> + * from the domain.  Only statistics supported by the domain, the driver, and
> + * this version of libvirt will be returned.

What is the intended return value if a driver does not support a 
particular field. Should it be initialized to '0' or -1.

Also, I'm wondering does the calling application need to initialize
the '@stats' paramter at all, eg filling in the 'tag' with the 
VIR_MEMSTAT_XXX constants for which they want data. Or must the
application always supply the 'stats' array large enough to hold
all types of stats ?

> + * 
> + * Memory Statistics:
> + *
> + * VIR_MEMSTAT_SWAP_IN:
> + *     The total amount of data read from swap space (in bytes).
> + * VIR_MEMSTAT_SWAP_OUT:
> + *     The total amount of memory written out to swap space (in bytes).
> + * VIR_MEMSTAT_MAJOR_FAULT:
> + *     The number of page faults that required disk IO to service.
> + * VIR_MEMSTAT_MINOR_FAULT:
> + *     The number of page faults serviced without disk IO.
> + * VIR_MEMSTAT_MEM_FREE:
> + *     The amount of memory which is not being used for any purpose (in bytes).
> + * VIR_MEMSTAT_MEM_TOTAL:
> + *     The total amount of memory recognized by the domain's OS (in bytes).
> + *
> + * Returns: The number of stats provided or -1 in case of failure.
> + */
> +int virDomainMemoryStats (virDomainPtr dom, virDomainMemoryStatPtr stats,
> +                          unsigned int nr_stats)
> +{

> diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
> index 8921c1a..5761a7e 100644
> --- a/src/libvirt_public.syms
> +++ b/src/libvirt_public.syms
> @@ -327,6 +327,8 @@ LIBVIRT_0.7.2 {
>  	virStreamAbort;
>  	virStreamFree;
>  	virDomainMigrateToURI;
> +        # XXX: For testing only -- Move to 0.7.3 section
> +        virDomainMemoryStats;
>  } LIBVIRT_0.7.1;

You should create the new section in your patch if it doesn't exist yet,
using the next logical version number. Otherwise this is the kind of
thing that can get missed if we pull your patchset straight into GIT

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list