From ef088ed962cc39e6ca301cade1c5416257aed984 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Tue, 26 Jan 2010 02:05:45 +0100 Subject: [PATCH] esx: Output error details from libcurl --- src/esx/esx_vi.c | 14 ++++++++------ src/esx/esx_vi.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 0fe953593c..bc94326529 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -251,8 +251,8 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) if (errorCode != CURLE_OK) { ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, - "curl_easy_perform() returned an error: %s (%d)", - curl_easy_strerror(errorCode), errorCode); + "curl_easy_perform() returned an error: %s (%d) : %s", + curl_easy_strerror(errorCode), errorCode, ctx->curl_error); return -1; } @@ -262,8 +262,8 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) if (errorCode != CURLE_OK) { ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "curl_easy_getinfo(CURLINFO_RESPONSE_CODE) returned an " - "error: %s (%d)", curl_easy_strerror(errorCode), - errorCode); + "error: %s (%d) : %s", curl_easy_strerror(errorCode), + errorCode, ctx->curl_error); return -1; } @@ -282,8 +282,8 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) if (errorCode != CURLE_OK) { ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "curl_easy_getinfo(CURLINFO_REDIRECT_URL) returned " - "an error: %s (%d)", curl_easy_strerror(errorCode), - errorCode); + "an error: %s (%d) : %s", curl_easy_strerror(errorCode), + errorCode, ctx->curl_error); } else { ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "The server redirects from '%s' to '%s'", url, @@ -360,6 +360,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url, esxVI_CURL_ReadString); curl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEFUNCTION, esxVI_CURL_WriteBuffer); + curl_easy_setopt(ctx->curl_handle, CURLOPT_ERRORBUFFER, + ctx->curl_error); #if ESX_VI__CURL__ENABLE_DEBUG_OUTPUT curl_easy_setopt(ctx->curl_handle, CURLOPT_DEBUGFUNCTION, esxVI_CURL_Debug); curl_easy_setopt(ctx->curl_handle, CURLOPT_VERBOSE, 1); diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h index 608dcbda81..4e8b675138 100644 --- a/src/esx/esx_vi.h +++ b/src/esx/esx_vi.h @@ -77,6 +77,7 @@ struct _esxVI_Context { char *ipAddress; CURL *curl_handle; struct curl_slist *curl_headers; + char curl_error[CURL_ERROR_SIZE]; virMutex curl_lock; char *username; char *password;