[libvirt-users] virNodeInfo returns MBytes instead of bytes

Michal Privoznik mprivozn at redhat.com
Mon Sep 30 09:06:36 UTC 2013


On 30.09.2013 06:34, Sam Giraffe wrote:
> Hi,
> 
> http://www.libvirt.org/html/libvirt-libvirt.html#virNodeInfo says that
> memory size is in kilobytes, however when I use this call I get an
> answer in Megabytes, see below. The hypervisor has 16 GB of RAM.
> 
> $ python
> Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45)
> [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
>>>> import libvirt
> 
>>>> conn=libvirt.open("qemu+ssh://xx@xx.xxx.com/system
> <http://xx@xx.xxx.com/system>")
> Enter passphrase for key '/home/xx/.ssh/id_rsa':
> 
>>>> hv_info=conn.getInfo()
> 
>>>> hv_info
> ['x86_64', 15919, 8, 3292, 1, 1, 4, 2]

This is the python bindings bug. From the code:

http://libvirt.org/git/?p=libvirt.git;a=blob;f=python/libvirt-override.c;h=e659bae30ad01b315041e29913fb442c348ed0f6;hb=HEAD#l2846

We are shifting the mem amount left 10 times (effectively divide it by
1024). Hence you'll get MB instead of KB. Although I am not quite sure
how to fix this. I see two options:

1) fix the code (possibly breaking other applications already relying on
the bug)

2) document it as known bug (not consistent with C struct)

Michal




More information about the libvirt-users mailing list