Re: [PATCH] Added missing memory reporting into python bindings

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

 



On 02/03/2012 07:53 AM, Martin Kletzander wrote:
> Two types of memory stats were not reported by python bindings. This
> patch fixes both of them.
> ---
>  python/libvirt-override.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/python/libvirt-override.c b/python/libvirt-override.c
> index 18849f8..289a9bb 100644
> --- a/python/libvirt-override.c
> +++ b/python/libvirt-override.c
> @@ -258,6 +258,12 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
>          else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_AVAILABLE)
>              PyDict_SetItem(info, libvirt_constcharPtrWrap("available"),
>                             PyLong_FromUnsignedLongLong(stats[i].val));
> +        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON)
> +            PyDict_SetItem(info, libvirt_constcharPtrWrap("actual"),
> +                           PyLong_FromUnsignedLongLong(stats[i].val));
> +        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_RSS)
> +            PyDict_SetItem(info, libvirt_constcharPtrWrap("rss"),
> +                           PyLong_FromUnsignedLongLong(stats[i].val));

ACK and pushed.

Note that you are perpetuating two already-existing bugs in this function:
- libvirt_constcharPtrWrap() can fail on OOM and return NULL, but
PyDict_SetItem() is not tolerant of NULL
- PyDict_SetItem() can fail and set a python exception (typically on
OOM), but we are silently ignoring that

but that's just part of my general complaint that we need to scrub this
entire file, and not worth holding up your patch while waiting for the
overall cleanups.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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