[libvirt] [PATCHv4 02/10] Implement domainMemoryStats API slot for LXC driver.

Daniel P. Berrange berrange at redhat.com
Thu Feb 20 15:28:29 UTC 2014


On Fri, Feb 14, 2014 at 06:49:00PM +0100, Thorsten Behrens wrote:
> ---
> Notes to v4:
>  - check errors before filling param array
>  - UL->ULL change punted to separate patch
>  
>  src/lxc/lxc_driver.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index f735631..827d989 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -5197,6 +5197,61 @@ 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;
> +    unsigned long long swap_usage;
> +    unsigned long mem_usage;
> +
> +    virCheckFlags(0, -1);
> +
> +    if (!(vm = lxcDomObjFromDomain(dom)))
> +        goto cleanup;
> +
> +    priv = vm->privateData;
> +
> +    if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
> +        goto cleanup;
> +
> +    if (!virCgroupGetMemSwapUsage(priv->cgroup, &swap_usage))
> +        goto cleanup;
> +
> +    if (!virCgroupGetMemoryUsage(priv->cgroup, &mem_usage))
> +        goto cleanup;
> +
> +    ret = 0;
> +    if (!virDomainObjIsActive(vm))
> +        goto cleanup;

This has to be higher up and raise VIR_ERR_OPERATION_INVALID
to prevent us accessing a NULL priv->cgroup.


ACK, I'll make that fix before pushing


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list