[libvirt] [PATCH 1/2] python: Report nodeinfo's memory in KiB

Daniel P. Berrange berrange at redhat.com
Mon Sep 30 09:37:18 UTC 2013


On Mon, Sep 30, 2013 at 11:30:11AM +0200, Michal Privoznik wrote:
> The python binding to virNodeGetInfo API has this awful bug. The
> amount of RAM the node has is reported in MiB instead of KiB as
> we have documented in the struct virNodeInfo description. The
> problem is, after we obtain the nodeinfo the amount is shifted
> left ten times (divided by 1024).
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  python/libvirt-override.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/python/libvirt-override.c b/python/libvirt-override.c
> index e659bae..3069013 100644
> --- a/python/libvirt-override.c
> +++ b/python/libvirt-override.c
> @@ -2843,7 +2843,7 @@ libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
>          return VIR_PY_NONE;
>      py_retval = PyList_New(8);
>      PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&info.model[0]));
> -    PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.memory >> 10));
> +    PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.memory));
>      PyList_SetItem(py_retval, 2, libvirt_intWrap((int) info.cpus));
>      PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.mhz));
>      PyList_SetItem(py_retval, 4, libvirt_intWrap((int) info.nodes));

NACK, this is a clear backwards compat problem that will break *every*
application using this API

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