提交 484460ec 编写于 作者: M Matthias Bolte

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 006be75e, 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.
上级 228a9ec3
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册