if (strchr(fileName, '/') == NULL && strchr(fileName, '\\') == NULL) {
/* Plain file name, use same directory as for the .vmx file */
if (virAsprintf(&result, "%s/%s",
- data->datastorePathWithoutFileName, fileName) < 0) {
- virReportOOMError();
+ data->datastorePathWithoutFileName, fileName) < 0)
goto cleanup;
- }
} else {
if (esxVI_String_AppendValueToList(&propertyNameList,
"summary.name") < 0 ||
}
if (virAsprintf(&result, "[%s] %s", datastoreName,
- strippedFileName) < 0) {
- virReportOOMError();
+ strippedFileName) < 0)
goto cleanup;
- }
break;
}
}
if (virAsprintf(&result, "[%s] %s", datastoreName,
- directoryAndFileName) < 0) {
- virReportOOMError();
+ directoryAndFileName) < 0)
goto cleanup;
- }
}
/* If it's an absolute path outside of a datastore just use it as is */
caps = virCapabilitiesNew(VIR_ARCH_I686, 1, 1);
}
- if (caps == NULL) {
- virReportOOMError();
+ if (caps == NULL)
return NULL;
- }
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
}
if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
- conn->uri->server, conn->uri->port) < 0) {
- virReportOOMError();
+ conn->uri->server, conn->uri->port) < 0)
goto cleanup;
- }
if (esxVI_Context_Alloc(&priv->host) < 0 ||
esxVI_Context_Connect(priv->host, url, ipAddress, username, password,
}
if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
- hostname, conn->uri->port) < 0) {
- virReportOOMError();
+ hostname, conn->uri->port) < 0)
goto cleanup;
- }
if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
}
/* Allocate per-connection private data */
- if (VIR_ALLOC(priv) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(priv) < 0)
goto cleanup;
- }
if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) {
goto cleanup;
if (VIR_STRDUP(complete, hostName) < 0)
goto cleanup;
} else {
- if (virAsprintf(&complete, "%s.%s", hostName, domainName) < 0) {
- virReportOOMError();
+ if (virAsprintf(&complete, "%s.%s", hostName, domainName) < 0)
goto cleanup;
- }
}
cleanup:
if (directoryName == NULL) {
if (virAsprintf(&data.datastorePathWithoutFileName, "[%s]",
- datastoreName) < 0) {
- virReportOOMError();
+ datastoreName) < 0)
goto cleanup;
- }
} else {
if (virAsprintf(&data.datastorePathWithoutFileName, "[%s] %s",
- datastoreName, directoryName) < 0) {
- virReportOOMError();
+ datastoreName, directoryName) < 0)
goto cleanup;
- }
}
ctx.opaque = &data;
/* Register the domain */
if (directoryName != NULL) {
if (virAsprintf(&datastoreRelatedPath, "[%s] %s/%s.vmx", datastoreName,
- directoryName, escapedName) < 0) {
- virReportOOMError();
+ directoryName, escapedName) < 0)
goto cleanup;
- }
} else {
if (virAsprintf(&datastoreRelatedPath, "[%s] %s.vmx", datastoreName,
- escapedName) < 0) {
- virReportOOMError();
+ escapedName) < 0)
goto cleanup;
- }
}
if (esxVI_RegisterVM_Task(priv->primary, priv->primary->datacenter->vmFolder,
if (virAsprintf(uri_out, "vpxmigr://%s/%s/%s",
priv->vCenter->ipAddress,
priv->vCenter->computeResource->resourcePool->value,
- priv->vCenter->hostSystem->_reference->value) < 0) {
- virReportOOMError();
+ priv->vCenter->hostSystem->_reference->value) < 0)
return -1;
- }
}
return 0;
!MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE))) {
if (domains &&
VIR_ALLOC_N(*domains, 1) < 0)
- goto no_memory;
+ goto cleanup;
ret = 0;
goto cleanup;
if (domains) {
if (VIR_ALLOC_N(doms, 1) < 0)
- goto no_memory;
+ goto cleanup;
ndoms = 1;
}
}
if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
- goto no_memory;
+ goto cleanup;
if (!(dom = virGetDomain(conn, name, uuid)))
goto cleanup;
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
return ret;
-
-no_memory:
- virReportOOMError();
- goto cleanup;
}
#undef MATCH
if (VIR_ALLOC(*bandwidth) < 0 ||
VIR_ALLOC((*bandwidth)->in) < 0 ||
- VIR_ALLOC((*bandwidth)->out) < 0) {
- virReportOOMError();
+ VIR_ALLOC((*bandwidth)->out) < 0)
return -1;
- }
if (shapingPolicy->averageBandwidth != NULL) {
/* Scale bits per second to kilobytes per second */
return NULL;
}
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(def) < 0)
goto cleanup;
- }
/* Lookup HostVirtualSwitch */
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network_->name,
if (count > 0) {
def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
- if (VIR_ALLOC_N(def->forward.ifs, count) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->forward.ifs, count) < 0)
goto cleanup;
- }
/* Find PhysicalNic by key */
if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) {
}
if (count > 0) {
- if (VIR_ALLOC_N(def->portGroups, count) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def->portGroups, count) < 0)
goto cleanup;
- }
/* Lookup Network list and create name list */
if (esxVI_String_AppendValueToList(&propertyNameList, "name") < 0 ||
def.source.nhost = 1;
- if (VIR_ALLOC_N(def.source.hosts, def.source.nhost) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def.source.hosts, def.source.nhost) < 0)
goto cleanup;
- }
def.source.hosts[0].name = target->address;
if (esxVI_LocalDatastoreInfo_DynamicCast(info) != NULL) {
def.type = VIR_STORAGE_POOL_DIR;
} else if ((nasInfo = esxVI_NasDatastoreInfo_DynamicCast(info)) != NULL) {
- if (VIR_ALLOC_N(def.source.hosts, 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(def.source.hosts, 1) < 0)
goto cleanup;
- }
def.type = VIR_STORAGE_POOL_NETFS;
def.source.hosts[0].name = nasInfo->nas->remoteHost;
def.source.dir = nasInfo->nas->remotePath;
goto cleanup;
} else if (virAsprintf(&names[count], "%s/%s", directoryAndFileName,
fileInfo->path) < 0) {
- virReportOOMError();
goto cleanup;
}
char *datastorePath = NULL;
char *key = NULL;
- if (virAsprintf(&datastorePath, "[%s] %s", pool->name, name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&datastorePath, "[%s] %s", pool->name, name) < 0)
goto cleanup;
- }
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary,
datastorePath, &key) < 0) {
} else if (virAsprintf(&volumeName, "%s/%s",
directoryAndFileName,
fileInfo->path) < 0) {
- virReportOOMError();
goto cleanup;
}
if (virAsprintf(&datastorePath, "[%s] %s", datastoreName,
- volumeName) < 0) {
- virReportOOMError();
+ volumeName) < 0)
goto cleanup;
- }
if (esxVI_VmDiskFileInfo_DynamicCast(fileInfo) == NULL) {
/* Only a VirtualDisk has a UUID */
}
if (virAsprintf(&unescapedDatastorePath, "[%s] %s", pool->name,
- def->name) < 0) {
- virReportOOMError();
+ def->name) < 0)
goto cleanup;
- }
if (def->target.format == VIR_STORAGE_FILE_VMDK) {
/* Parse and escape datastore path */
}
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name,
- directoryName) < 0) {
- virReportOOMError();
+ directoryName) < 0)
goto cleanup;
- }
if (virAsprintf(&datastorePath, "[%s] %s/%s", pool->name, directoryName,
- fileName) < 0) {
- virReportOOMError();
+ fileName) < 0)
goto cleanup;
- }
/* Create directory, if it doesn't exist yet */
if (esxVI_LookupFileInfoByDatastorePath
}
if (priv->primary->hasQueryVirtualDiskUuid) {
- if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0)
goto cleanup;
- }
if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
}
if (virAsprintf(&sourceDatastorePath, "[%s] %s", sourceVolume->pool,
- sourceVolume->name) < 0) {
- virReportOOMError();
+ sourceVolume->name) < 0)
goto cleanup;
- }
/* Parse config */
def = virStorageVolDefParseString(&poolDef, xmldesc);
}
if (virAsprintf(&unescapedDatastorePath, "[%s] %s", pool->name,
- def->name) < 0) {
- virReportOOMError();
+ def->name) < 0)
goto cleanup;
- }
if (def->target.format == VIR_STORAGE_FILE_VMDK) {
/* Parse and escape datastore path */
}
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name,
- directoryName) < 0) {
- virReportOOMError();
+ directoryName) < 0)
goto cleanup;
- }
if (virAsprintf(&datastorePath, "[%s] %s/%s", pool->name, directoryName,
- fileName) < 0) {
- virReportOOMError();
+ fileName) < 0)
goto cleanup;
- }
/* Create directory, if it doesn't exist yet */
if (esxVI_LookupFileInfoByDatastorePath
}
if (priv->primary->hasQueryVirtualDiskUuid) {
- if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0)
goto cleanup;
- }
if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
virCheckFlags(0, -1);
- if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0)
goto cleanup;
- }
if (esxVI_DeleteVirtualDisk_Task(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
virCheckFlags(0, -1);
- if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0)
goto cleanup;
- }
if (esxVI_ZeroFillVirtualDisk_Task(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
memset(info, 0, sizeof(*info));
- if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0)
goto cleanup;
- }
if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath,
false, &fileInfo,
}
/* Lookup file info */
- if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0)
goto cleanup;
- }
if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath,
false, &fileInfo,
{
char *path;
- if (virAsprintf(&path, "[%s] %s", volume->pool, volume->name) < 0) {
- virReportOOMError();
- return NULL;
- }
-
+ ignore_value(virAsprintf(&path, "[%s] %s", volume->pool, volume->name));
return path;
}
return -1;
}
- if (VIR_ALLOC(*parsedUri) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(*parsedUri) < 0)
return -1;
- }
for (i = 0; i < uri->paramsCount; i++) {
virURIParamPtr queryParam = &uri->params[i];
int \
esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \
{ \
- return esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##_type)); \
+ return esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##_type), \
+ __FILE__, __FUNCTION__, __LINE__); \
}
return -1;
}
- if (virAsprintf(&range, "%llu-%llu", offset, offset + *length - 1) < 0) {
- virReportOOMError();
+ if (virAsprintf(&range, "%llu-%llu", offset, offset + *length - 1) < 0)
goto cleanup;
- }
} else if (offset > 0) {
- if (virAsprintf(&range, "%llu-", offset) < 0) {
- virReportOOMError();
+ if (virAsprintf(&range, "%llu-", offset) < 0)
goto cleanup;
- }
}
virMutexLock(&curl->lock);
return -1;
}
- if (VIR_ALLOC(ctx->sessionLock) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ctx->sessionLock) < 0)
return -1;
- }
if (virMutexInit(ctx->sessionLock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
} else {
if (virAsprintf(&xpathExpression,
"/soapenv:Envelope/soapenv:Body/vim:%sResponse",
- methodName) < 0) {
- virReportOOMError();
+ methodName) < 0)
goto cleanup;
- }
responseNode = virXPathNode(xpathExpression, xpathContext);
*/
int
-esxVI_Alloc(void **ptrptr, size_t size)
+esxVI_Alloc(void **ptrptr, size_t size, const char *file,
+ const char *function, size_t linenr)
{
if (ptrptr == NULL || *ptrptr != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (virAllocN(ptrptr, size, 1, false, 0, NULL, NULL, 0) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAllocN(ptrptr, size, 1, true, VIR_FROM_THIS,
+ file, function, linenr);
}
* that the <path> part is actually the file name.
*/
if (virAsprintf(&datastorePathWithoutFileName, "[%s]",
- datastoreName) < 0) {
- virReportOOMError();
+ datastoreName) < 0)
goto cleanup;
- }
if (VIR_STRDUP(fileName, directoryAndFileName) < 0) {
goto cleanup;
}
} else {
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s",
- datastoreName, directoryName) < 0) {
- virReportOOMError();
+ datastoreName, directoryName) < 0)
goto cleanup;
- }
length = strlen(directoryName);
}
/* Search datastore for files */
- if (virAsprintf(&datastorePath, "[%s]", datastoreName) < 0) {
- virReportOOMError();
+ if (virAsprintf(&datastorePath, "[%s]", datastoreName) < 0)
goto cleanup;
- }
if (esxVI_SearchDatastoreSubFolders_Task(ctx, hostDatastoreBrowser,
datastorePath, searchSpec,
goto cleanup;
}
- if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0)
goto cleanup;
- }
if (esxUtil_ReformatUuid(uuid_string, *key) < 0) {
goto cleanup;
} else {
if (virAsprintf(errorMessage, "%s - %s",
taskInfo->error->fault->_actualType,
- taskInfo->error->localizedMessage) < 0) {
- virReportOOMError();
+ taskInfo->error->localizedMessage) < 0)
goto cleanup;
- }
}
}
* - 'get' functions get information from a local object
*/
-int esxVI_Alloc(void **ptrptr, size_t size);
+int esxVI_Alloc(void **ptrptr, size_t size, const char *file,
+ const char *function, size_t linenr);
int esxVI_BuildSelectSet
(esxVI_SelectionSpec **selectSet, const char *name,
int \
esxVI_##__type##_Alloc(esxVI_##__type **ptrptr) \
{ \
- if (esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##__type)) < 0) { \
+ if (esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##__type), \
+ __FILE__, __FUNCTION__, __LINE__) < 0) { \
return -1; \
} \
\