[libvirt] [PATCH 1/6] domMemStats: Add domainMemoryStats method to struct _virDriver

Daniel Veillard veillard at redhat.com
Wed Dec 16 21:42:51 UTC 2009


On Fri, Dec 11, 2009 at 03:26:12PM -0500, Adam Litke wrote:
> Set up the types for the domainMemoryStats function and insert it into the
> virDriver structure definition.  Because of static initializers, update every
> driver and set the new field to NULL.
> 
> Note: The changes in python/* are to fix compiler errors.  The actual python
> binding is implemented in a later patch.
> 
> Signed-off-by: Adam Litke <agl at us.ibm.com>
> To: libvirt list <libvir-list at redhat.com>
> ---
>  include/libvirt/libvirt.h.in |   52 ++++++++++++++++++++++++++++++++++++++++++
>  python/generator.py          |    4 ++-
>  src/driver.h                 |    7 +++++
>  src/esx/esx_driver.c         |    1 +
>  src/lxc/lxc_driver.c         |    1 +
>  src/opennebula/one_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/xen/xen_driver.c         |    1 +
>  14 files changed, 73 insertions(+), 1 deletions(-)
> 
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index f51a565..3416ed4 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -333,6 +333,55 @@ struct _virDomainInterfaceStats {
>   */
>  typedef virDomainInterfaceStatsStruct *virDomainInterfaceStatsPtr;
>  
> +/**
> + * Memory Statistics Tags:
> + */
> +typedef enum {
> +    /* The total amount of data read from swap space (in bytes). */
> +    VIR_MEMSTAT_SWAP_IN         = 0,
> +    /* The total amount of memory written out to swap space (in bytes). */
> +    VIR_MEMSTAT_SWAP_OUT        = 1,
> +
> +    /*
> +     * Page faults occur when a process makes a valid access to virtual memory
> +     * that is not available.  When servicing the page fault, if disk IO is
> +     * required, it is considered a major fault.  If not, it is a minor fault.
> +     * These are expressed as the number of faults that have occurred.
> +     */
> +    VIR_MEMSTAT_MAJOR_FAULT     = 2,
> +    VIR_MEMSTAT_MINOR_FAULT     = 3,
> +
> +    /*
> +     * The amount of memory left completely unused by the system.  Memory that
> +     * is available but used for reclaimable caches should NOT be reported as
> +     * free.  This value is expressed in bytes.
> +     */
> +    VIR_MEMSTAT_MEM_FREE        = 4,
> +
> +    /*
> +     * The total amount of usable memory as seen by the domain.  This value
> +     * may be less than the amount of memory assigned to the domain if a
> +     * balloon driver is in use or if the guest OS does not initialize all
> +     * assigned pages.  This value is expressed in bytes.
> +     */
> +    VIR_MEMSTAT_MEM_TOTAL       = 5,
> +
> +    /*
> +     * The number of statistics supported by this version of the interface.
> +     * To add new statistics, add them to the enum and increase this value.
> +     */
> +    VIR_MEMSTAT_NR_TAGS         = 6,
> +} virDomainMemoryStatTags;


  Okay, I have gone though your series of patches quickly, this looks
basically sane, I just need a bit more thorough review. My only concern
right now is that most libvirt APIs about memory expose values in
Kilobytes (well nearly all) and it would be better to keep things
consistent. I assume this affects only the documentation here and
the qemu driver implementation which need a divide on values.
  I think the mapping as a dictionary for Python is a good idea too.

  If you could just repost those two patches I will try to finish
the review and hopefully push this ASAP, assuming there is no
disagreements by others.
  It would be nice to see if we can get an implementation in another
driver maybe as simple as a monotonic increment of values for the
test driver or something similar,

  thanks !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list