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

Re: [libvirt] [PATCH 2/2] python: Expose binding for virNodeGetMemoryStats()



On 11/28/2011 10:19 AM, Peter Krempa wrote:
> This patch adds binding for virNodeGetMemoryStats method of libvirtd.
> Return value is represended as a python dictionary mapping fileld

s/represended/represented/  s/fileld/field/

(copy-and-paste from the last patch :)

> +++ b/python/libvirt-override-api.xml
> @@ -84,6 +84,13 @@
>        <arg name='cpuNum' type='int' info='number of node cpu. (VIR_NODE_CPU_STATS_ALL_CPUS means total cpu statistics)'/>
>        <arg name='flags' type='unsigned int' info='aditional flags'/>
>      </function>
> +    <function name='virNodeGetMemoryStats' file='python'>
> +      <info>Extract node's memory statistics.</info>
> +      <return type='virNodeMemoryStats' info='dictionary mapping field names to values or None in case of error'/>
> +      <arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
> +      <arg name='cellNum' type='int' info='number of node cell. (VIR_NODE_MEMORY_STATS_ALL_CELLS means total cell statistics)'/>
> +      <arg name='flags' type='unsigned int' info='aditional flags'/>

s/aditional/additional/

> +    if (!(ret = PyDict_New())) {
> +        free(stats);
> +        return VIR_PY_NONE;
> +    }
> +    for (i = 0; i < nparams; i++) {
> +        PyDict_SetItem(ret,
> +                       libvirt_constcharPtrWrap(stats[i].field),
> +                       libvirt_ulonglongWrap(stats[i].value));
> +    }

Copy and paste, so not a problem with this patch any more so than the
other functions that used the same code pattern, but can PyDict_SetItem
fail?  If so, should be be reclaiming the entries added so far before
returning overall failure, instead of silently truncating the return
dictionary by omitting the entries that weren't inserted properly?

ACK with spelling nits fixed.

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

Attachment: signature.asc
Description: OpenPGP digital signature


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