diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 0225e9ae273b117933313a9075c37eb261ce5e31..fc225cfbb60585736500f5b4b9cfbd1e4f10ea76 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2015,6 +2015,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags) const char *vmPathName = NULL; char *datastoreName = NULL; char *vmxPath = NULL; + virBuffer buffer = VIR_BUFFER_INITIALIZER; char *url = NULL; char *vmx = NULL; virDomainDefPtr def = NULL; @@ -2052,21 +2053,28 @@ esxDomainDumpXML(virDomainPtr domain, int flags) } /* expected format: "[] " */ - if (sscanf(vmPathName, "[%a[^]%]] %as", &datastoreName, &vmxPath) != 2) { + if (sscanf(vmPathName, "[%a[^]%]] %a[^\n]", &datastoreName, &vmxPath) != 2) { ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID, "'config.files.vmPathName' property '%s' doesn't have " "expected format '[] '", vmPathName); goto failure; } - if (virAsprintf(&url, "%s://%s:%d/folder/%s?dcPath=%s&dsName=%s", - priv->transport, domain->conn->uri->server, - domain->conn->uri->port, vmxPath, - priv->host->datacenter->value, datastoreName) < 0) { + virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->transport, + domain->conn->uri->server, domain->conn->uri->port); + virBufferURIEncodeString(&buffer, vmxPath); + virBufferAddLit(&buffer, "?dcPath="); + virBufferURIEncodeString(&buffer, priv->host->datacenter->value); + virBufferAddLit(&buffer, "&dsName="); + virBufferURIEncodeString(&buffer, datastoreName); + + if (virBufferError(&buffer)) { virReportOOMError(domain->conn); goto failure; } + url = virBufferContentAndReset(&buffer); + if (esxVI_Context_Download(domain->conn, priv->host, url, &vmx) < 0) { goto failure; } diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 10dd7fda6f8b2ad485bba6743dd8c85ee2f12252..dfcb35217a1216e0e40e001916db674528047dfe 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -442,7 +442,8 @@ esxVI_Context_Download(virConnectPtr conn, esxVI_Context *ctx, const char *url, if (responseCode != 200) { ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, - "HTTP response code %d", (int)responseCode); + "HTTP response code %d while trying to download '%s'", + (int)responseCode, url); goto failure; }