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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
>  
> +/**
> + * 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;

I'm a little wary of this last element 'VIR_MEMSTAT_NR_TAGS', since 
it is something that will obviously change as we add more stats. I
see your intent is that the caller simply statically declare an array
that is VIR_MEMSTAT_NR_TAGS  in size. The only other alternative I see
is to have an API for querying the number of supported statistics, but
then that has the downside of requiring an extra API call (network
round trip) for something we expect to be called quite frequently.

> +
> +typedef struct _virDomainMemoryStat virDomainMemoryStatStruct;
> +
> +struct _virDomainMemoryStat {
> +    virDomainMemoryStatTags tag;

This should be an 'int', since enums have an ill-defined size for ABI

> +    unsigned long long val;
> +};
> +
> +typedef virDomainMemoryStatStruct *virDomainMemoryStatPtr;
> +
>  
>  /* Domain migration flags. */
>  typedef enum {
> @@ -633,6 +682,9 @@ int                     virDomainInterfaceStats (virDomainPtr dom,
>                                                   const char *path,
>                                                   virDomainInterfaceStatsPtr stats,
>                                                   size_t size);
> +int                     virDomainMemoryStats (virDomainPtr dom,
> +                                              virDomainMemoryStatPtr stats,
> +                                              unsigned int nr_stats);
>  int                     virDomainBlockPeek (virDomainPtr dom,
>                                              const char *path,
>                                              unsigned long long offset,

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 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]