Re: [PATCHv2 2/6] Implement domainMemoryStats API slot for LXC driver.

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

 



On 01/20/2014 07:12 PM, Thorsten Behrens wrote:
> ---
> 
> Notes on v2:
>  - check if domain is running, fixed ret val calculation
>  - api slot comment is now referencing 1.2.2
> 
>  src/lxc/lxc_driver.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 5ae4b65..8cf8e48 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -4556,6 +4556,55 @@ lxcNodeGetInfo(virConnectPtr conn,
>  
>  
>  static int
> +lxcDomainMemoryStats(virDomainPtr dom,
> +                     struct _virDomainMemoryStat *stats,
> +                     unsigned int nr_stats,
> +                     unsigned int flags)
> +{
> +    virDomainObjPtr vm;
> +    int ret = -1;
> +    virLXCDomainObjPrivatePtr priv;
> +
> +    virCheckFlags(0, -1);
> +
> +    if (!(vm = lxcDomObjFromDomain(dom)))
> +        goto cleanup;
> +
> +    priv = vm->privateData;
> +
> +    if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
> +        goto cleanup;
> +
> +    ret = 0;
> +    if (!virDomainObjIsActive(vm))
> +        goto cleanup;
> +
> +    if (ret < nr_stats) {
> +        stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON;
> +        stats[ret].val = vm->def->mem.cur_balloon;
> +        ret++;
> +    }
> +    if (ret < nr_stats) {
> +        stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_SWAP_IN;
> +        virCgroupGetMemSwapUsage(priv->cgroup, &stats[ret].val);
> +        ret++;
> +    }
> +    if (ret < nr_stats) {
> +        unsigned long kb;
> +        stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_RSS;
> +        virCgroupGetMemoryUsage(priv->cgroup, &kb);
> +        stats[ret].val = kb;
> +        ret++;
> +    }
> +
> +cleanup:
> +    if (vm)
> +        virObjectUnlock(vm);
> +    return ret;
> +}
> +
> +
> +static int
>  lxcNodeGetCPUStats(virConnectPtr conn,
>                     int cpuNum,
>                     virNodeCPUStatsPtr params,
> @@ -4783,6 +4832,7 @@ static virDriver lxcDriver = {
>      .domainSetSchedulerParameters = lxcDomainSetSchedulerParameters, /* 0.5.0 */
>      .domainSetSchedulerParametersFlags = lxcDomainSetSchedulerParametersFlags, /* 0.9.2 */
>      .domainInterfaceStats = lxcDomainInterfaceStats, /* 0.7.3 */
> +    .domainMemoryStats = lxcDomainMemoryStats, /* 1.2.2 */
>      .nodeGetCPUStats = lxcNodeGetCPUStats, /* 0.9.3 */
>      .nodeGetMemoryStats = lxcNodeGetMemoryStats, /* 0.9.3 */
>      .nodeGetCellsFreeMemory = lxcNodeGetCellsFreeMemory, /* 0.6.5 */
> 
looks good to me
ACK

thanks!

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