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

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



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

  That doesn't sound proper to me. I re-checked, all virConnectList* functions
in libvirt.c raise with an error only if the connection is invalid, if 
the pointer to the storage is NULL or if the max value is < 0. the max value
being 0 should be accepted, that's the semantic of the check done on top
of the driver. So what driver did fail with an argument error ? this need
to be fixed.
  This looks okay in the QEmu driver from what I saw
  xenHypervisorListDomains seems to need fixing.
  xenDaemonListDomains need to be fixed too.
  xenDaemonListDefinedDomains need to be fixed too.
  The OpenVZ driver looks okay
  The LXC driver looks okay
  The remote driver seems okay but it's harder for me to assert it works 
  through the full chain.

Patch for the Xen parts attached.
Could you try to investigate and find more precisely under what conditions
you got the 'max = 0' returning an invalid arg error, we need to find this
fix it not work around it at the binding level IMHO,

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/
Index: src/xen_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/xen_internal.c,v
retrieving revision 1.121
diff -u -p -r1.121 xen_internal.c
--- src/xen_internal.c	6 Jun 2008 11:09:57 -0000	1.121
+++ src/xen_internal.c	17 Jun 2008 09:48:17 -0000
@@ -2554,9 +2554,12 @@ xenHypervisorListDomains(virConnectPtr c
 
     priv = (xenUnifiedPrivatePtr) conn->privateData;
     if (priv->handle < 0 ||
-        (ids == NULL) || (maxids < 1))
+        (ids == NULL) || (maxids < 0))
         return (-1);
 
+    if (maxids == 0)
+        return(0);
+
     if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
         virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info",
                     maxids);
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/xend_internal.c,v
retrieving revision 1.198
diff -u -p -r1.198 xend_internal.c
--- src/xend_internal.c	9 Jun 2008 12:16:03 -0000	1.198
+++ src/xend_internal.c	17 Jun 2008 09:48:17 -0000
@@ -3330,7 +3330,10 @@ xenDaemonListDomains(virConnectPtr conn,
     struct sexpr *_for_i, *node;
     long id;
 
-    if ((ids == NULL) || (maxids <= 0))
+    if (maxids == 0)
+        return(0);
+
+    if ((ids == NULL) || (maxids < 0))
         goto error;
     root = sexpr_get(conn, "/xend/domain");
     if (root == NULL)
@@ -4219,8 +4222,11 @@ int xenDaemonListDefinedDomains(virConne
     if (priv->xendConfigVersion < 3)
         return(-1);
 
-    if ((names == NULL) || (maxnames <= 0))
+    if ((names == NULL) || (maxnames < 0))
         goto error;
+    if (maxnames == 0)
+        return(0);
+
     root = sexpr_get(conn, "/xend/domain?state=halted");
     if (root == NULL)
         goto error;

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