[libvirt] [PATCH] Added missing memory reporting into python bindings

Eric Blake eblake at redhat.com
Fri Feb 3 17:52:05 UTC 2012


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 at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120203/e1f7ad28/attachment-0001.sig>


More information about the libvir-list mailing list