Re: [libvirt] [PATCH]: fix ruby-libvirt bindings when virConnectNum* returns 0

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

 



On Tue, Jun 17, 2008 at 11:16:31AM +0200, Chris Lalancette wrote:
> Attached is a simple patch to fix a problem I ran into when using the
> ruby-libvirt bindings with libvirt 0.4.3.  Basically, if you call any of the
> virConnectList* functions with a "max" of 0, it returns "Invalid Arg".  To get
> around this, modify the ruby-libvirt bindings to return an empty list if we get
> num == 0 when calling the corresponding virConnectNumOf* function.  This should
> solve: https://bugzilla.redhat.com/show_bug.cgi?id=451666

  Hum, looking at the bugzilla it's for storage that the problem was raised.
It's a bit annoying, the main domain and network functions accept a max = 0
The documentation of virConnectListDefinedStoragePools doesn't prevent
maxnames = 0

  Actually the check done in the function is 
    if ((names == NULL) || (maxnames < 0))

i.e. it allows 0, and pass it to the underlying driver. One solution
would be to just return 0 there, as attached in this patch, the other
solution would be to check which underlying storage driver failed and
fix it,

Daniel
    

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard@xxxxxxxxxx  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/
Index: src/libvirt.c
===================================================================
RCS file: /data/cvs/libxen/src/libvirt.c,v
retrieving revision 1.146
diff -u -p -r1.146 libvirt.c
--- src/libvirt.c	10 Jun 2008 10:43:28 -0000	1.146
+++ src/libvirt.c	17 Jun 2008 09:59:00 -0000
@@ -4023,6 +4023,9 @@ virConnectListStoragePools	(virConnectPt
         return (-1);
     }
 
+    if (maxnames == 0)
+        return (0);
+
     if (conn->storageDriver && conn->storageDriver->listPools)
         return conn->storageDriver->listPools (conn, names, maxnames);
 
@@ -4087,6 +4090,9 @@ virConnectListDefinedStoragePools(virCon
         return (-1);
     }
 
+    if (maxnames == 0)
+        return(0);
+
     if (conn->storageDriver && conn->storageDriver->listDefinedPools)
         return conn->storageDriver->listDefinedPools (conn, names, maxnames);
 
--
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]