[libvirt] [PATCH]: fix ruby-libvirt bindings when virConnectNum* returns 0
Daniel Veillard
veillard at redhat.com
Tue Jun 17 10:00:09 UTC 2008
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 at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
-------------- next part --------------
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);
More information about the libvir-list
mailing list