2011/4/10 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>: > --- > Âsrc/esx/esx_driver.c |  Â4 +- > Âsrc/esx/esx_vi.c   | Â348 ++++++++++++++++++++++++++------------------------ > Âsrc/esx/esx_vi.h   |  29 +++- > Â3 files changed, 205 insertions(+), 176 deletions(-) > > diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c > index deda372..ef76350 100644 > --- a/src/esx/esx_driver.c > +++ b/src/esx/esx_driver.c > @@ -2642,7 +2642,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags) > >   url = virBufferContentAndReset(&buffer); > > -  Âif (esxVI_Context_DownloadFile(priv->primary, url, &vmx) < 0) { > +  Âif (esxVI_CURL_Download(priv->primary->curl, url, &vmx) < 0) { >     goto cleanup; >   } > > @@ -3111,7 +3111,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) >   /* Upload VMX file */ >   VIR_DEBUG("Uploading .vmx config, url='%s' vmx='%s'", url, vmx); > > -  Âif (esxVI_Context_UploadFile(priv->primary, url, vmx) < 0) { > +  Âif (esxVI_CURL_Upload(priv->primary->curl, url, vmx) < 0) { >     goto cleanup; >   } > > diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c > index fbab347..2fd09cd 100644 > --- a/src/esx/esx_vi.c > +++ b/src/esx/esx_vi.c > @@ -76,42 +76,25 @@ > > > Â/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > - * Context > + * CURL > Â*/ > > -/* esxVI_Context_Alloc */ > -ESX_VI__TEMPLATE__ALLOC(Context); > +/* esxVI_CURL_Alloc */ > +ESX_VI__TEMPLATE__ALLOC(CURL) > > -/* esxVI_Context_Free */ > -ESX_VI__TEMPLATE__FREE(Context, > +/* esxVI_CURL_Free */ > +ESX_VI__TEMPLATE__FREE(CURL, > Â{ > -  ÂVIR_FREE(item->url); > -  ÂVIR_FREE(item->ipAddress); > - > -  Âif (item->curl_handle != NULL) { > -    Âcurl_easy_cleanup(item->curl_handle); > +  Âif (item->handle != NULL) { > +    Âcurl_easy_cleanup(item->handle); >   } > > -  Âif (item->curl_headers != NULL) { > -    Âcurl_slist_free_all(item->curl_headers); > +  Âif (item->headers != NULL) { > +    Âcurl_slist_free_all(item->headers); >   } > > -  ÂvirMutexDestroy(&item->curl_lock); > - > -  ÂVIR_FREE(item->username); > -  ÂVIR_FREE(item->password); > -  ÂesxVI_ServiceContent_Free(&item->service); > -  ÂesxVI_UserSession_Free(&item->session); > -  ÂesxVI_Datacenter_Free(&item->datacenter); > -  ÂesxVI_ComputeResource_Free(&item->computeResource); > -  ÂesxVI_HostSystem_Free(&item->hostSystem); > -  ÂesxVI_SelectionSpec_Free(&item->selectSet_folderToChildEntity); > -  ÂesxVI_SelectionSpec_Free(&item->selectSet_hostSystemToParent); > -  ÂesxVI_SelectionSpec_Free(&item->selectSet_hostSystemToVm); > -  ÂesxVI_SelectionSpec_Free(&item->selectSet_hostSystemToDatastore); > -  ÂesxVI_SelectionSpec_Free(&item->selectSet_computeResourceToHost); > -  ÂesxVI_SelectionSpec_Free(&item->selectSet_computeResourceToParentToParent); > -}); > +  ÂvirMutexDestroy(&item->lock); > +}) > > Âstatic size_t > ÂesxVI_CURL_ReadString(char *data, size_t size, size_t nmemb, void *ptrptr) > @@ -218,7 +201,7 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type, > Â#endif > > Âstatic int > -esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) > +esxVI_CURL_Perform(esxVI_CURL *curl, const char *url) > Â{ >   CURLcode errorCode; >   long responseCode = 0; > @@ -226,23 +209,23 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) >   const char *redirectUrl = NULL; > Â#endif > > -  ÂerrorCode = curl_easy_perform(ctx->curl_handle); > +  ÂerrorCode = curl_easy_perform(curl->handle); > >   if (errorCode != CURLE_OK) { >     ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, >           Â_("curl_easy_perform() returned an error: %s (%d) : %s"), > -           curl_easy_strerror(errorCode), errorCode, ctx->curl_error); > +           curl_easy_strerror(errorCode), errorCode, curl->error); >     return -1; >   } > > -  ÂerrorCode = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE, > +  ÂerrorCode = curl_easy_getinfo(curl->handle, CURLINFO_RESPONSE_CODE, >                  &responseCode); > >   if (errorCode != CURLE_OK) { >     ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, >           Â_("curl_easy_getinfo(CURLINFO_RESPONSE_CODE) returned an " >            Â"error: %s (%d) : %s"), curl_easy_strerror(errorCode), > -           errorCode, ctx->curl_error); > +           errorCode, curl->error); >     return -1; >   } > > @@ -255,7 +238,7 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) > >   if (responseCode == 301) { > Â#if LIBCURL_VERSION_NUM >= 0x071202 /* 7.18.2 */ > -    ÂerrorCode = curl_easy_getinfo(ctx->curl_handle, CURLINFO_REDIRECT_URL, > +    ÂerrorCode = curl_easy_getinfo(curl->handle, CURLINFO_REDIRECT_URL, >                    &redirectUrl); > >     if (errorCode != CURLE_OK) { > @@ -263,7 +246,7 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) >             Â_("curl_easy_getinfo(CURLINFO_REDIRECT_URL) returned " >              Â"an error: %s (%d) : %s"), >             Âcurl_easy_strerror(errorCode), > -             errorCode, ctx->curl_error); > +             errorCode, curl->error); >     } else { >       ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, >             Â_("The server redirects from '%s' to '%s'"), url, > @@ -281,32 +264,23 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url) > Â} > > Âint > -esxVI_Context_Connect(esxVI_Context *ctx, const char *url, > -           Âconst char *ipAddress, const char *username, > -           Âconst char *password, esxUtil_ParsedUri *parsedUri) > +esxVI_CURL_Connect(esxVI_CURL *curl, esxUtil_ParsedUri *parsedUri) > Â{ > -  Âif (ctx == NULL || url == NULL || ipAddress == NULL || username == NULL || > -    Âpassword == NULL || ctx->url != NULL || ctx->service != NULL || > -    Âctx->curl_handle != NULL || ctx->curl_headers != NULL) { > -    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); > -    Âreturn -1; > -  Â} > - > -  Âif (esxVI_String_DeepCopyValue(&ctx->url, url) < 0 || > -    ÂesxVI_String_DeepCopyValue(&ctx->ipAddress, ipAddress) < 0) { > +  Âif (curl->handle != NULL) { > +    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call")); >     return -1; >   } > > -  Âctx->curl_handle = curl_easy_init(); > +  Âcurl->handle = curl_easy_init(); > > -  Âif (ctx->curl_handle == NULL) { > +  Âif (curl->handle == NULL) { >     ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", >           Â_("Could not initialize CURL")); >     return -1; >   } > > -  Âctx->curl_headers = curl_slist_append(ctx->curl_headers, "Content-Type: " > -                     Â"text/xml; charset=UTF-8"); > +  Âcurl->headers = curl_slist_append(curl->headers, > +                   Â"Content-Type: text/xml; charset=UTF-8"); > >   /* >   Â* Add a dummy expect header to stop CURL from waiting for a response code > @@ -316,56 +290,179 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url, >   Â* 100 (Continue) response and the wait times out resulting in wasting >   Â* approx. 2 sec per POST operation. >   Â*/ > -  Âctx->curl_headers = curl_slist_append(ctx->curl_headers, > -                     Â"Expect: nothing"); > +  Âcurl->headers = curl_slist_append(curl->headers, "Expect: nothing"); > > -  Âif (ctx->curl_headers == NULL) { > +  Âif (curl->headers == NULL) { >     ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", >           Â_("Could not build CURL header list")); >     return -1; >   } > > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_URL, ctx->url); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_USERAGENT, "libvirt-esx"); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_HEADER, 0); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_FOLLOWLOCATION, 0); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_SSL_VERIFYPEER, > +  Âcurl_easy_setopt(curl->handle, CURLOPT_USERAGENT, "libvirt-esx"); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_HEADER, 0); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_FOLLOWLOCATION, 0); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_SSL_VERIFYPEER, >           ÂparsedUri->noVerify ? 0 : 1); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_SSL_VERIFYHOST, > +  Âcurl_easy_setopt(curl->handle, CURLOPT_SSL_VERIFYHOST, >           ÂparsedUri->noVerify ? 0 : 2); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_COOKIEFILE, ""); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_HTTPHEADER, ctx->curl_headers); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_READFUNCTION, > +  Âcurl_easy_setopt(curl->handle, CURLOPT_COOKIEFILE, ""); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_HTTPHEADER, curl->headers); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_READFUNCTION, >           ÂesxVI_CURL_ReadString); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEFUNCTION, > +  Âcurl_easy_setopt(curl->handle, CURLOPT_WRITEFUNCTION, >           ÂesxVI_CURL_WriteBuffer); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_ERRORBUFFER, > -           ctx->curl_error); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_ERRORBUFFER, 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); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_DEBUGFUNCTION, esxVI_CURL_Debug); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_VERBOSE, 1); > Â#endif > >   if (parsedUri->proxy) { > -    Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_PROXY, > +    Âcurl_easy_setopt(curl->handle, CURLOPT_PROXY, >             ÂparsedUri->proxy_hostname); > -    Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_PROXYTYPE, > +    Âcurl_easy_setopt(curl->handle, CURLOPT_PROXYTYPE, >             ÂparsedUri->proxy_type); > -    Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_PROXYPORT, > +    Âcurl_easy_setopt(curl->handle, CURLOPT_PROXYPORT, >             ÂparsedUri->proxy_port); >   } > > -  Âif (virMutexInit(&ctx->curl_lock) < 0) { > +  Âif (virMutexInit(&curl->lock) < 0) { >     ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", >           Â_("Could not initialize CURL mutex")); >     return -1; >   } > > -  Âctx->username = strdup(username); > -  Âctx->password = strdup(password); > +  Âreturn 0; > +} > + > +int > +esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content) > +{ > +  ÂvirBuffer buffer = VIR_BUFFER_INITIALIZER; > +  Âint responseCode = 0; > > -  Âif (ctx->username == NULL || ctx->password == NULL) { > +  Âif (content == NULL || *content != NULL) { > +    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); > +    Âreturn -1; > +  Â} > + > +  ÂvirMutexLock(&curl->lock); > + > +  Âcurl_easy_setopt(curl->handle, CURLOPT_URL, url); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_WRITEDATA, &buffer); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 0); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_HTTPGET, 1); > + > +  ÂresponseCode = esxVI_CURL_Perform(curl, url); > + > +  ÂvirMutexUnlock(&curl->lock); > + > +  Âif (responseCode < 0) { > +    Âgoto cleanup; > +  Â} else if (responseCode != 200) { > +    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, > +           _("HTTP response code %d for download from '%s'"), > +           responseCode, url); > +    Âgoto cleanup; > +  Â} > + > +  Âif (virBufferError(&buffer)) { >     virReportOOMError(); > +    Âgoto cleanup; > +  Â} > + > +  Â*content = virBufferContentAndReset(&buffer); > + > + Âcleanup: > +  Âif (*content == NULL) { > +    ÂvirBufferFreeAndReset(&buffer); > +    Âreturn -1; > +  Â} > + > +  Âreturn 0; > +} > + > +int > +esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char *content) > +{ > +  Âint responseCode = 0; > + > +  Âif (content == NULL) { > +    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); > +    Âreturn -1; > +  Â} > + > +  ÂvirMutexLock(&curl->lock); > + > +  Âcurl_easy_setopt(curl->handle, CURLOPT_URL, url); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_READDATA, &content); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1); > +  Âcurl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, strlen(content)); > + > +  ÂresponseCode = esxVI_CURL_Perform(curl, url); > + > +  ÂvirMutexUnlock(&curl->lock); > + > +  Âif (responseCode < 0) { > +    Âreturn -1; > +  Â} else if (responseCode != 200 && responseCode != 201) { > +    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, > +           _("HTTP response code %d for upload to '%s'"), > +           responseCode, url); > +    Âreturn -1; > +  Â} > + > +  Âreturn 0; > +} > + > + > + > +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > + * Context > + */ > + > +/* esxVI_Context_Alloc */ > +ESX_VI__TEMPLATE__ALLOC(Context) > + > +/* esxVI_Context_Free */ > +ESX_VI__TEMPLATE__FREE(Context, > +{ > +  ÂesxVI_CURL_Free(&item->curl); > +  ÂVIR_FREE(item->url); > +  ÂVIR_FREE(item->ipAddress); > +  ÂVIR_FREE(item->username); > +  ÂVIR_FREE(item->password); > +  ÂesxVI_ServiceContent_Free(&item->service); > +  ÂesxVI_UserSession_Free(&item->session); > +  ÂesxVI_Datacenter_Free(&item->datacenter); > +  ÂesxVI_ComputeResource_Free(&item->computeResource); > +  ÂesxVI_HostSystem_Free(&item->hostSystem); > +  ÂesxVI_SelectionSpec_Free(&item->selectSet_folderToChildEntity); > +  ÂesxVI_SelectionSpec_Free(&item->selectSet_hostSystemToParent); > +  ÂesxVI_SelectionSpec_Free(&item->selectSet_hostSystemToVm); > +  ÂesxVI_SelectionSpec_Free(&item->selectSet_hostSystemToDatastore); > +  ÂesxVI_SelectionSpec_Free(&item->selectSet_computeResourceToHost); > +  ÂesxVI_SelectionSpec_Free(&item->selectSet_computeResourceToParentToParent); > +}) > + > +int > +esxVI_Context_Connect(esxVI_Context *ctx, const char *url, > +           Âconst char *ipAddress, const char *username, > +           Âconst char *password, esxUtil_ParsedUri *parsedUri) > +{ > +  Âif (ctx == NULL || url == NULL || ipAddress == NULL || username == NULL || > +    Âpassword == NULL || ctx->url != NULL || ctx->service != NULL || > +    Âctx->curl != NULL) { > +    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); > +    Âreturn -1; > +  Â} > + > +  Âif (esxVI_CURL_Alloc(&ctx->curl) < 0 || > +    ÂesxVI_CURL_Connect(ctx->curl, parsedUri) < 0 || > +    ÂesxVI_String_DeepCopyValue(&ctx->url, url) < 0 || > +    ÂesxVI_String_DeepCopyValue(&ctx->ipAddress, ipAddress) < 0 || > +    ÂesxVI_String_DeepCopyValue(&ctx->username, username) < 0 || > +    ÂesxVI_String_DeepCopyValue(&ctx->password, password) < 0) { >     return -1; >   } > > @@ -577,87 +674,6 @@ esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx, > Â} > > Âint > -esxVI_Context_DownloadFile(esxVI_Context *ctx, const char *url, char **content) > -{ > -  ÂvirBuffer buffer = VIR_BUFFER_INITIALIZER; > -  Âint responseCode = 0; > - > -  Âif (content == NULL || *content != NULL) { > -    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); > -    Âreturn -1; > -  Â} > - > -  ÂvirMutexLock(&ctx->curl_lock); > - > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_URL, url); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEDATA, &buffer); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_UPLOAD, 0); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_HTTPGET, 1); > - > -  ÂresponseCode = esxVI_CURL_Perform(ctx, url); > - > -  ÂvirMutexUnlock(&ctx->curl_lock); > - > -  Âif (responseCode < 0) { > -    Âgoto cleanup; > -  Â} else if (responseCode != 200) { > -    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, > -           _("HTTP response code %d for download from '%s'"), > -           responseCode, url); > -    Âgoto cleanup; > -  Â} > - > -  Âif (virBufferError(&buffer)) { > -    ÂvirReportOOMError(); > -    Âgoto cleanup; > -  Â} > - > -  Â*content = virBufferContentAndReset(&buffer); > - > - Âcleanup: > -  Âif (*content == NULL) { > -    ÂvirBufferFreeAndReset(&buffer); > -    Âreturn -1; > -  Â} > - > -  Âreturn 0; > -} > - > -int > -esxVI_Context_UploadFile(esxVI_Context *ctx, const char *url, > -             const char *content) > -{ > -  Âint responseCode = 0; > - > -  Âif (content == NULL) { > -    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); > -    Âreturn -1; > -  Â} > - > -  ÂvirMutexLock(&ctx->curl_lock); > - > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_URL, url); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_READDATA, &content); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_UPLOAD, 1); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_INFILESIZE, strlen(content)); > - > -  ÂresponseCode = esxVI_CURL_Perform(ctx, url); > - > -  ÂvirMutexUnlock(&ctx->curl_lock); > - > -  Âif (responseCode < 0) { > -    Âreturn -1; > -  Â} else if (responseCode != 200 && responseCode != 201) { > -    ÂESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, > -           _("HTTP response code %d for upload to '%s'"), > -           responseCode, url); > -    Âreturn -1; > -  Â} > - > -  Âreturn 0; > -} > - > -int > ÂesxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, >            const char *request, esxVI_Response **response, >            esxVI_Occurrence occurrence) > @@ -678,17 +694,17 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, >     return -1; >   } > > -  ÂvirMutexLock(&ctx->curl_lock); > +  ÂvirMutexLock(&ctx->curl->lock); > > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_URL, ctx->url); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEDATA, &buffer); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_UPLOAD, 0); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDS, request); > -  Âcurl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDSIZE, strlen(request)); > +  Âcurl_easy_setopt(ctx->curl->handle, CURLOPT_URL, ctx->url); > +  Âcurl_easy_setopt(ctx->curl->handle, CURLOPT_WRITEDATA, &buffer); > +  Âcurl_easy_setopt(ctx->curl->handle, CURLOPT_UPLOAD, 0); > +  Âcurl_easy_setopt(ctx->curl->handle, CURLOPT_POSTFIELDS, request); > +  Âcurl_easy_setopt(ctx->curl->handle, CURLOPT_POSTFIELDSIZE, strlen(request)); > > -  Â(*response)->responseCode = esxVI_CURL_Perform(ctx, ctx->url); > +  Â(*response)->responseCode = esxVI_CURL_Perform(ctx->curl, ctx->url); > > -  ÂvirMutexUnlock(&ctx->curl_lock); > +  ÂvirMutexUnlock(&ctx->curl->lock); > >   if ((*response)->responseCode < 0) { >     goto cleanup; > @@ -869,7 +885,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, > Â*/ > > Â/* esxVI_Response_Alloc */ > -ESX_VI__TEMPLATE__ALLOC(Response); > +ESX_VI__TEMPLATE__ALLOC(Response) > > Â/* esxVI_Response_Free */ > ÂESX_VI__TEMPLATE__FREE(Response, > @@ -879,7 +895,7 @@ ESX_VI__TEMPLATE__FREE(Response, >   if (item->document != NULL) { >     xmlFreeDoc(item->document); >   } > -}); > +}) > > > > diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h > index d046bf9..57788ac 100644 > --- a/src/esx/esx_vi.h > +++ b/src/esx/esx_vi.h > @@ -82,6 +82,7 @@ typedef enum _esxVI_APIVersion esxVI_APIVersion; > Âtypedef enum _esxVI_ProductVersion esxVI_ProductVersion; > Âtypedef enum _esxVI_Occurrence esxVI_Occurrence; > Âtypedef struct _esxVI_ParsedHostCpuIdInfo esxVI_ParsedHostCpuIdInfo; > +typedef struct _esxVI_CURL esxVI_CURL; > Âtypedef struct _esxVI_Context esxVI_Context; > Âtypedef struct _esxVI_Response esxVI_Response; > Âtypedef struct _esxVI_Enumeration esxVI_Enumeration; > @@ -142,16 +143,32 @@ struct _esxVI_ParsedHostCpuIdInfo { > > > Â/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > + * CURL > + */ > + > +struct _esxVI_CURL { > +  ÂCURL *handle; > +  ÂvirMutex lock; > +  Âstruct curl_slist *headers; > +  Âchar error[CURL_ERROR_SIZE]; > +}; > + > +int esxVI_CURL_Alloc(esxVI_CURL **curl); > +void esxVI_CURL_Free(esxVI_CURL **curl); > +int esxVI_CURL_Connect(esxVI_CURL *curl, esxUtil_ParsedUri *parsedUri); > +int esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content); > +int esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char *content); > + > + > + > +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > Â* Context > Â*/ > > Âstruct _esxVI_Context { > +  ÂesxVI_CURL *curl; >   char *url; >   char *ipAddress; > -  ÂCURL *curl_handle; > -  Âstruct curl_slist *curl_headers; > -  Âchar curl_error[CURL_ERROR_SIZE]; > -  ÂvirMutex curl_lock; >   char *username; >   char *password; >   esxVI_ServiceContent *service; > @@ -180,10 +197,6 @@ int esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx, >                    esxUtil_ParsedUri *parsedUri); > Âint esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx, >                        const char *hostSystemIpAddress); > -int esxVI_Context_DownloadFile(esxVI_Context *ctx, const char *url, > -                char **content); > -int esxVI_Context_UploadFile(esxVI_Context *ctx, const char *url, > -               const char *content); > Âint esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, >              const char *request, esxVI_Response **response, >              esxVI_Occurrence occurrence); > -- > 1.7.0.4 > Ping :) Matthias -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list