xenapi: Improve error reporting in xenapiOpen once again

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.
This commit is contained in:
Matthias Bolte 2011-07-21 15:16:11 +02:00
parent 228a9ec312
commit 484460ec46
2 changed files with 4 additions and 5 deletions

View 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);

View 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);
}