]> xenbits.xensource.com Git - libvirt.git/commitdiff
xenapi: Improve error reporting in xenapiOpen once again
authorMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 21 Jul 2011 13:16:11 +0000 (15:16 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 29 Oct 2011 16:42:02 +0000 (18:42 +0200)
privP->session->error_description is a list and in order to get the
complete error message all parts of the list should be concatenated.
xenapiSessionErrorHandler does this when its third parameter is NULL.
The current code discards all but the first part of the error message
resulting in a potentially incomplete error message.

This partly reverts 006be75ee214f9b4, that tried to avoid reporting
a (null) in the error message. The actual problem is more general in
returnErrorFromSession that might return NULL if there is no error.

Make sure that returnErrorFromSession return non-NULL always. Also
don't skip the last error message part.

src/xenapi/xenapi_driver.c
src/xenapi/xenapi_utils.c

index 39464554e73b471688537d7b8656ed7352bab2ca..975fd4713533d512a654b75eafe5294010fefc7f 100644 (file)
@@ -194,10 +194,7 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth,
         return VIR_DRV_OPEN_SUCCESS;
     }
 
-    xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
-                              *privP->session->error_description != NULL ?
-                              *privP->session->error_description :
-                              _("unknown error"));
+    xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, NULL);
 
   error:
     VIR_FREE(username);
index 342ae5bdb8f9c0e0adc7c1437574302891767a30..79fd9461ec61e3d6710cff54e170d045c29c7bdf 100644 (file)
@@ -272,12 +272,14 @@ returnErrorFromSession(xen_session *session)
 {
     int i;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    for (i = 0; i < session->error_description_count - 1; i++) {
+    for (i = 0; i < session->error_description_count; i++) {
         if (!i)
             virBufferEscapeString(&buf, "%s", session->error_description[i]);
         else
             virBufferEscapeString(&buf, " : %s", session->error_description[i]);
     }
+    if (virBufferUse(&buf) < 1)
+        virBufferAdd(&buf, _("unknown error"), -1);
     return virBufferContentAndReset(&buf);
 }