Re: [PATCH v7 3/6] add interface virCgroupGetMemSwapUsage

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

 



On Tue, Nov 06, 2012 at 02:07:19PM +0800, Gao feng wrote:
> virCgroupGetMemSwapUsage is used to get container's swap usage,
> with this interface,we can get swap usage in fuse filesystem.
> 
> Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
> ---
>  src/libvirt_private.syms |    1 +
>  src/util/cgroup.c        |   20 ++++++++++++++++++++
>  src/util/cgroup.h        |    1 +
>  3 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index e94b478..2608072 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -98,6 +98,7 @@ virCgroupGetCpuacctUsage;
>  virCgroupGetCpusetCpus;
>  virCgroupGetCpusetMems;
>  virCgroupGetFreezerState;
> +virCgroupGetMemSwapUsage;
>  virCgroupGetMemSwapHardLimit;
>  virCgroupGetMemoryHardLimit;
>  virCgroupGetMemorySoftLimit;
> diff --git a/src/util/cgroup.c b/src/util/cgroup.c
> index 3f7b5f7..4aae70d 100644
> --- a/src/util/cgroup.c
> +++ b/src/util/cgroup.c
> @@ -1371,6 +1371,26 @@ int virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb)
>  }
>  
>  /**
> + * virCgroupGetMemSwapUsage:
> + *
> + * @group: The cgroup to get mem+swap usage for
> + * @kb: The mem+swap amount in kilobytes
> + *
> + * Returns: 0 on success
> + */
> +int virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
> +{
> +    long long unsigned int usage_in_bytes;
> +    int ret;
> +    ret = virCgroupGetValueU64(group,
> +                               VIR_CGROUP_CONTROLLER_MEMORY,
> +                               "memory.memsw.usage_in_bytes", &usage_in_bytes);
> +    if (ret == 0)
> +        *kb = usage_in_bytes >> 10;
> +    return ret;
> +}
> +
> +/**
>   * virCgroupSetCpusetMems:
>   *
>   * @group: The cgroup to set cpuset.mems for
> diff --git a/src/util/cgroup.h b/src/util/cgroup.h
> index 38fa4b7..0c11eb1 100644
> --- a/src/util/cgroup.h
> +++ b/src/util/cgroup.h
> @@ -92,6 +92,7 @@ int virCgroupSetMemorySoftLimit(virCgroupPtr group, unsigned long long kb);
>  int virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned long long *kb);
>  int virCgroupSetMemSwapHardLimit(virCgroupPtr group, unsigned long long kb);
>  int virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb);
> +int virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb);
>  
>  enum {
>      VIR_CGROUP_DEVICE_READ  = 1,
> -- 
> 1.7.7.6

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw

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