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 | 5 +----
src/xenapi/xenapi_utils.c | 4 +++-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 97da1d1..77bf82d 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -193,10 +193,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);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 342ae5b..79fd946 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -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);
}
--
1.7.4.1