[libvirt] [PATCH v7 2/7] qemu: expand domain memory statistics with 'usable'

Pavel Hrdina phrdina at redhat.com
Wed Jul 27 08:03:48 UTC 2016


On Wed, Jul 13, 2016 at 01:42:13PM +0300, Derbyshev Dmitriy wrote:
> From: Derbyshev Dmitry <dderbyshev at virtuozzo.com>
> 
> Currently 'memtotal' in virtio drivers and qemu corresponds
> to 'available' in libvirt. Because of that we introduce libvirt 'usable'
> parameter, which maps to 'stat-available-memory' balloon statistics.
> As balloon statistics isn't reported in hmp, so no modification is made
> in qemu_monitor_text.c.
> 
> Signed-off-by: Derbyshev Dmitry <dderbyshev at virtuozzo.com>
> ---
>  include/libvirt/libvirt-domain.h | 8 +++++++-
>  src/libvirt-domain.c             | 3 +++
>  src/qemu/qemu_monitor_json.c     | 4 ++++
>  tools/virsh-domain-monitor.c     | 2 ++
>  tools/virsh.pod                  | 2 ++
>  5 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
> index 7ea93aa..3fb482b 100644
> --- a/include/libvirt/libvirt-domain.h
> +++ b/include/libvirt/libvirt-domain.h
> @@ -604,10 +604,16 @@ typedef enum {
>      VIR_DOMAIN_MEMORY_STAT_RSS             = 7,
>  
>      /*
> +     * How big the balloon can be inflated without pushing the guest system

s/big/much/

> +     * to swap, corresponds to 'Available' in /proc/meminfo
> +     */
> +    VIR_DOMAIN_MEMORY_STAT_USABLE          = 8,
> +
> +    /*
>       * 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_DOMAIN_MEMORY_STAT_NR              = 8,
> +    VIR_DOMAIN_MEMORY_STAT_NR              = 9,
>  
>  # ifdef VIR_ENUM_SENTINELS
>      VIR_DOMAIN_MEMORY_STAT_LAST = VIR_DOMAIN_MEMORY_STAT_NR
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 4e71a94..1467030 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -5986,6 +5986,9 @@ virDomainGetInterfaceParameters(virDomainPtr domain,
>   *     The amount of memory which is not being used for any purpose (in kb).
>   * VIR_DOMAIN_MEMORY_STAT_AVAILABLE:
>   *     The total amount of memory available to the domain's OS (in kb).
> + * VIR_DOMAIN_MEMORY_STAT_USABLE:
> + *     How big the balloon can be inflated without pushing the guest system

s/big/much/

> + *     to swap, corresponds to 'Available' in /proc/meminfo
>   * VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON:
>   *     Current balloon value (in kb).
>   *
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index bb426dc..c83e0cc 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -1719,7 +1719,11 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
>                        VIR_DOMAIN_MEMORY_STAT_UNUSED, 1024);
>      GET_BALLOON_STATS("stat-total-memory",
>                        VIR_DOMAIN_MEMORY_STAT_AVAILABLE, 1024);
> +    GET_BALLOON_STATS("stat-available-memory",
> +                      VIR_DOMAIN_MEMORY_STAT_USABLE, 1024);
> +
>      ret = got;
> +
>   cleanup:
>      virJSONValueFree(cmd);
>      virJSONValueFree(reply);
> diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
> index c712fa5..7f30da2 100644
> --- a/tools/virsh-domain-monitor.c
> +++ b/tools/virsh-domain-monitor.c
> @@ -369,6 +369,8 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
>              vshPrint(ctl, "unused %llu\n", stats[i].val);
>          if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_AVAILABLE)
>              vshPrint(ctl, "available %llu\n", stats[i].val);
> +        if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_USABLE)
> +            vshPrint(ctl, "usable %llu\n", stats[i].val);
>          if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON)
>              vshPrint(ctl, "actual %llu\n", stats[i].val);
>          if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_RSS)
> diff --git a/tools/virsh.pod b/tools/virsh.pod
> index 4ebf7ad..5444f91 100644
> --- a/tools/virsh.pod
> +++ b/tools/virsh.pod
> @@ -819,6 +819,8 @@ B<Explanation of fields>:
>    available         - The amount of usable memory as seen by the domain (in kB)
>    actual            - Current balloon value (in KB)
>    rss               - Resident Set Size of the running domain's process (in kB)
> +  usable            - The amount of memory which can be reclaimed by balloon 

trailing white space

> +without causing host swapping (in KB)
>  
>  For QEMU/KVM with a memory balloon, setting the optional I<--period> to a
>  value larger than 0 in seconds will allow the balloon driver to return

ACK




More information about the libvir-list mailing list