Re: [PATCHv3] virNodeGetCPUMap: Add python binding

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

 



On 10/25/2012 08:59 AM, Viktor Mihajlovski wrote:
> Added a method getCPUMap to virConnect.
> It can be used as follows:
> 
> import libvirt
> import sys
> import os
> 
> conn = libvirt.openReadOnly(None)
> if conn == None:
>     print 'Failed to open connection to the hypervisor'
>     sys.exit(1)
> 
> try:
>     (cpus, cpumap, online) = conn.getCPUMap(0)

> +    <function name='virNodeGetCPUMap' file='python'>
> +      <info>Get node CPU information</info>
> +      <return type='str *' info='(cpunum, online, cpumap) on success, None on error'/>

Oops, docs disagree with commit message on tuple ordering.

> +    /* 0: number of CPUs */
> +    if ((pycpunum = PyLong_FromLong(i_retval)) == NULL ||
> +        PyTuple_SetItem(ret, 0, pycpunum) < 0)
> +        goto error;
> +
> +    /* 1: CPU map */

But code matched the commit message, so I'll fix the docs.


> +    /* 2: number of online CPUs */
> +    if((pyonline = PyLong_FromLong(online)) == NULL ||

Style - space after 'if'.

> +       PyTuple_SetItem(ret, 2, pyonline) < 0)
> +        goto error;

Indentation (but that's caused by the earlier spacing after 'if').

> +

ACK and pushed with this squashed in:

diff --git i/python/libvirt-override-api.xml
w/python/libvirt-override-api.xml
index e54701c..a0e0496 100644
--- i/python/libvirt-override-api.xml
+++ w/python/libvirt-override-api.xml
@@ -544,7 +544,7 @@
     </function>
     <function name='virNodeGetCPUMap' file='python'>
       <info>Get node CPU information</info>
-      <return type='str *' info='(cpunum, online, cpumap) on success,
None on error'/>
+      <return type='str *' info='(cpunum, cpumap, online) on success,
None on error'/>
       <arg name='conn' type='virConnectPtr' info='pointer to the
hypervisor connection'/>
       <arg name='flags' type='int' info='unused, pass 0'/>
     </function>
diff --git i/python/libvirt-override.c w/python/libvirt-override.c
index 0609803..320f26a 100644
--- i/python/libvirt-override.c
+++ w/python/libvirt-override.c
@@ -6449,8 +6449,8 @@ libvirt_virNodeGetCPUMap(PyObject *self
ATTRIBUTE_UNUSED,
         goto error;

     /* 2: number of online CPUs */
-    if((pyonline = PyLong_FromLong(online)) == NULL ||
-       PyTuple_SetItem(ret, 2, pyonline) < 0)
+    if ((pyonline = PyLong_FromLong(online)) == NULL ||
+        PyTuple_SetItem(ret, 2, pyonline) < 0)
         goto error;

 cleanup:


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