From 484460ec4678a264c5e7355495c2f0da72cb42bd Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Thu, 21 Jul 2011 15:16:11 +0200 Subject: [PATCH] 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. --- 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 39464554e7..975fd47135 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -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); diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index 342ae5bdb8..79fd9461ec 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); } -- 2.47.2