const char *hostname,
const char *hostSystemIPAddress)
{
- int result = -1;
g_autofree char *ipAddress = NULL;
g_autofree char *username = NULL;
g_autofree char *password = NULL;
} else {
if (!(username = virAuthGetUsername(conn, auth, "esx", "administrator",
hostname)))
- goto cleanup;
+ return -1;
}
if (!(password = virAuthGetPassword(conn, auth, "esx", username, hostname)))
- goto cleanup;
+ return -1;
url = g_strdup_printf("%s://%s:%d/sdk", priv->parsedUri->transport, hostname,
conn->uri->port);
if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
password, priv->parsedUri) < 0) {
- goto cleanup;
+ return -1;
}
if (priv->vCenter->productLine != esxVI_ProductLine_VPX) {
hostname,
esxVI_ProductLineToDisplayName(esxVI_ProductLine_VPX),
esxVI_ProductLineToDisplayName(priv->vCenter->productLine));
- goto cleanup;
+ return -1;
}
if (hostSystemIPAddress) {
- if (esxVI_Context_LookupManagedObjectsByHostSystemIp
- (priv->vCenter, hostSystemIPAddress) < 0) {
- goto cleanup;
- }
+ if (esxVI_Context_LookupManagedObjectsByHostSystemIp(priv->vCenter, hostSystemIPAddress) < 0)
+ return -1;
} else {
if (esxVI_Context_LookupManagedObjectsByPath(priv->vCenter,
priv->parsedUri->path) < 0) {
- goto cleanup;
+ return -1;
}
}
- result = 0;
-
- cleanup:
- return result;
+ return 0;
}
esxStorageVolLookupByName(virStoragePoolPtr pool,
const char *name)
{
- virStorageVolPtr volume = NULL;
esxPrivate *priv = pool->conn->privateData;
g_autofree char *datastorePath = NULL;
g_autofree char *key = NULL;
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary,
datastorePath, &key) < 0) {
- goto cleanup;
+ return NULL;
}
- volume = virGetStorageVol(pool->conn, pool->name, name, key,
- &esxStorageBackendVMFS, NULL);
-
- cleanup:
- return volume;
+ return virGetStorageVol(pool->conn, pool->name, name, key,
+ &esxStorageBackendVMFS, NULL);
}
static virStorageVolPtr
esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
{
- virStorageVolPtr volume = NULL;
esxPrivate *priv = conn->privateData;
g_autofree char *datastoreName = NULL;
g_autofree char *directoryAndFileName = NULL;
if (esxUtil_ParseDatastorePath(path, &datastoreName, NULL,
&directoryAndFileName) < 0) {
- goto cleanup;
+ return NULL;
}
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, path,
&key) < 0) {
- goto cleanup;
+ return NULL;
}
- volume = virGetStorageVol(conn, datastoreName, directoryAndFileName, key,
- &esxStorageBackendVMFS, NULL);
-
- cleanup:
- return volume;
+ return virGetStorageVol(conn, datastoreName, directoryAndFileName, key,
+ &esxStorageBackendVMFS, NULL);
}
const char *ipAddress, const char *username,
const char *password, esxUtil_ParsedUri *parsedUri)
{
- int result = -1;
g_autofree char *escapedPassword = NULL;
if (!ctx || !url || !ipAddress || !username ||
if (!escapedPassword) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to escape password for XML"));
- goto cleanup;
+ return -1;
}
if (esxVI_CURL_Alloc(&ctx->curl) < 0 ||
esxVI_CURL_Connect(ctx->curl, parsedUri) < 0) {
- goto cleanup;
+ return -1;
}
ctx->url = g_strdup(url);
if (virMutexInit(ctx->sessionLock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not initialize session mutex"));
- goto cleanup;
+ return -1;
}
if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0)
- goto cleanup;
+ return -1;
if (STRNEQ(ctx->service->about->apiType, "HostAgent") &&
STRNEQ(ctx->service->about->apiType, "VirtualCenter")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expecting VI API type 'HostAgent' or 'VirtualCenter' "
"but found '%s'"), ctx->service->about->apiType);
- goto cleanup;
+ return -1;
}
if (virParseVersionString(ctx->service->about->apiVersion,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse VI API version '%s'"),
ctx->service->about->apiVersion);
- goto cleanup;
+ return -1;
}
if (ctx->apiVersion < 1000000 * 2 + 1000 * 5 /* 2.5 */) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Minimum supported %s version is %s but found version '%s'"),
"VI API", "2.5", ctx->service->about->apiVersion);
- goto cleanup;
+ return -1;
}
if (virParseVersionString(ctx->service->about->version,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse product version '%s'"),
ctx->service->about->version);
- goto cleanup;
+ return -1;
}
if (STREQ(ctx->service->about->productLineId, "gsx")) {
_("Minimum supported %s version is %s but found version '%s'"),
esxVI_ProductLineToDisplayName(esxVI_ProductLine_GSX),
"2.0", ctx->service->about->version);
- goto cleanup;
+ return -1;
}
ctx->productLine = esxVI_ProductLine_GSX;
_("Minimum supported %s version is %s but found version '%s'"),
esxVI_ProductLineToDisplayName(esxVI_ProductLine_ESX),
"3.5", ctx->service->about->version);
- goto cleanup;
+ return -1;
}
ctx->productLine = esxVI_ProductLine_ESX;
_("Minimum supported %s version is %s but found version '%s'"),
esxVI_ProductLineToDisplayName(esxVI_ProductLine_VPX),
"2.5", ctx->service->about->version);
- goto cleanup;
+ return -1;
}
ctx->productLine = esxVI_ProductLine_VPX;
_("Expecting product 'gsx' or 'esx' or 'embeddedEsx' "
"or 'vpx' but found '%s'"),
ctx->service->about->productLineId);
- goto cleanup;
+ return -1;
}
if (ctx->productLine == esxVI_ProductLine_ESX) {
if (esxVI_Login(ctx, username, escapedPassword, NULL, &ctx->session) < 0 ||
esxVI_BuildSelectSetCollection(ctx) < 0) {
- goto cleanup;
+ return -1;
}
- result = 0;
-
- cleanup:
- return result;
+ return 0;
}
int
esxVI_VirtualMachineQuestionInfo *questionInfo, bool autoAnswer,
bool *blocked)
{
- int result = -1;
esxVI_ElementDescription *elementDescription = NULL;
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
esxVI_ElementDescription *answerChoice = NULL;
questionInfo->text);
*blocked = true;
- goto cleanup;
+ return -1;
} else if (!answerChoice) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Pending question blocks virtual machine execution, "
possibleAnswers);
*blocked = true;
- goto cleanup;
+ return -1;
}
VIR_INFO("Pending question blocks virtual machine execution, "
if (esxVI_AnswerVM(ctx, virtualMachine, questionInfo->id,
answerChoice->key) < 0) {
- goto cleanup;
+ return -1;
}
} else {
if (possibleAnswers) {
}
*blocked = true;
- goto cleanup;
+ return -1;
}
- result = 0;
+ return 0;
- cleanup:
- return result;
}