As stated in our contributor guidelines, we don't want curly brackets
around oneline code block (with some exceptions).
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/esx/esx_device_monitor.c | 3 +-
src/esx/esx_driver.c | 838 ++++++++++++------------------------
src/esx/esx_interface_driver.c | 36 +-
src/esx/esx_network_driver.c | 132 ++----
src/esx/esx_nwfilter_driver.c | 3 +-
src/esx/esx_secret_driver.c | 3 +-
src/esx/esx_storage_backend_iscsi.c | 78 ++--
src/esx/esx_storage_backend_vmfs.c | 204 +++------
src/esx/esx_storage_driver.c | 81 ++--
src/esx/esx_util.c | 51 +--
src/esx/esx_vi.c | 606 +++++++++-----------------
src/esx/esx_vi_methods.c | 3 +-
src/esx/esx_vi_types.c | 54 +--
13 files changed, 700 insertions(+), 1392 deletions(-)
diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c
index c02b00f..b1bc07a 100644
--- a/src/esx/esx_device_monitor.c
+++ b/src/esx/esx_device_monitor.c
@@ -43,9 +43,8 @@ esxNodeDeviceOpen(virConnectPtr conn,
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->driver->no != VIR_DRV_ESX) {
+ if (conn->driver->no != VIR_DRV_ESX)
return VIR_DRV_OPEN_DECLINED;
- }
conn->nodeDevicePrivateData = conn->privateData;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 0770e89..bceb448 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -66,9 +66,8 @@ struct _esxVMX_Data {
static void
esxFreePrivate(esxPrivate **priv)
{
- if (!priv || !(*priv)) {
+ if (!priv || !(*priv))
return;
- }
esxVI_Context_Free(&(*priv)->host);
esxVI_Context_Free(&(*priv)->vCenter);
@@ -154,9 +153,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
if (esxVI_String_AppendValueToList(&propertyNameList,
"summary.name") < 0 ||
esxVI_LookupDatastoreList(data->ctx, propertyNameList,
- &datastoreList) < 0) {
+ &datastoreList) < 0)
return NULL;
- }
/* Search for datastore by mount path */
for (datastore = datastoreList; datastore;
@@ -168,32 +166,27 @@ esxParseVMXFileName(const char *fileName, void *opaque)
&hostMount,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetStringValue(datastore, "summary.name",
&datastoreName,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
tmp = (char *)STRSKIP(fileName, hostMount->mountInfo->path);
- if (!tmp) {
+ if (!tmp)
continue;
- }
/* Found a match. Strip leading separators */
- while (*tmp == '/' || *tmp == '\\') {
+ while (*tmp == '/' || *tmp == '\\')
++tmp;
- }
- if (VIR_STRDUP(strippedFileName, tmp) < 0) {
+ if (VIR_STRDUP(strippedFileName, tmp) < 0)
goto cleanup;
- }
tmp = strippedFileName;
/* Convert \ to / */
while (*tmp != '\0') {
- if (*tmp == '\\') {
+ if (*tmp == '\\')
*tmp = '/';
- }
++tmp;
}
@@ -207,9 +200,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
/* Fallback to direct datastore name match */
if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) {
- if (VIR_STRDUP(copyOfFileName, fileName) < 0) {
+ if (VIR_STRDUP(copyOfFileName, fileName) < 0)
goto cleanup;
- }
/* Expected format: '/vmfs/volumes/<datastore>/<path>'
*/
if (!(tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) ||
@@ -225,9 +217,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
if (esxVI_LookupDatastoreByName(data->ctx, datastoreName,
NULL, &datastoreList,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!datastoreList) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -244,9 +235,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
/* If it's an absolute path outside of a datastore just use it as is */
if (!result && *fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
- if (VIR_STRDUP(result, fileName) < 0) {
+ if (VIR_STRDUP(result, fileName) < 0)
goto cleanup;
- }
}
if (!result) {
@@ -299,29 +289,25 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
if (*fileName == '[') {
/* Parse datastore path and lookup datastore */
if (esxUtil_ParseDatastorePath(fileName, &datastoreName, NULL,
- &directoryAndFileName) < 0) {
+ &directoryAndFileName) < 0)
goto cleanup;
- }
if (esxVI_LookupDatastoreByName(data->ctx, datastoreName, NULL,
&datastore,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_LookupDatastoreHostMount(data->ctx, datastore->obj,
&hostMount,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* Detect separator type */
- if (strchr(hostMount->mountInfo->path, '\\')) {
+ if (strchr(hostMount->mountInfo->path, '\\'))
separator = '\\';
- }
/* Strip trailing separators */
length = strlen(hostMount->mountInfo->path);
- while (length > 0 && hostMount->mountInfo->path[length - 1] ==
separator) {
+ while (length > 0 && hostMount->mountInfo->path[length - 1] ==
separator)
--length;
- }
/* Format as <mount>[/<directory>]/<file>, convert / to \ when
necessary */
virBufferAdd(&buffer, hostMount->mountInfo->path, length);
@@ -330,9 +316,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
tmp = directoryAndFileName;
while (*tmp != '\0') {
- if (*tmp == '/') {
+ if (*tmp == '/')
*tmp = separator;
- }
++tmp;
}
@@ -347,9 +332,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
result = virBufferContentAndReset(&buffer);
} else if (*fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
- if (VIR_STRDUP(result, fileName) < 0) {
+ if (VIR_STRDUP(result, fileName) < 0)
goto cleanup;
- }
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not handle file name '%s'"),
fileName);
@@ -399,9 +383,8 @@ esxAutodetectSCSIControllerModel(virDomainDiskDefPtr def, int *model,
if (esxVI_LookupFileInfoByDatastorePath(data->ctx, src,
false, &fileInfo,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo);
@@ -451,36 +434,31 @@ esxSupportsLongMode(esxPrivate *priv)
esxVI_ParsedHostCpuIdInfo parsedHostCpuIdInfo;
char edxLongModeBit = '?';
- if (priv->supportsLongMode != esxVI_Boolean_Undefined) {
+ if (priv->supportsLongMode != esxVI_Boolean_Undefined)
return priv->supportsLongMode;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return esxVI_Boolean_Undefined;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"hardware.cpuFeature") < 0 ||
esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "hardware.cpuFeature")) {
if (esxVI_HostCpuIdInfo_CastListFromAnyType
- (dynamicProperty->val, &hostCpuIdInfoList) < 0) {
+ (dynamicProperty->val, &hostCpuIdInfoList) < 0)
goto cleanup;
- }
for (hostCpuIdInfo = hostCpuIdInfoList; hostCpuIdInfo;
hostCpuIdInfo = hostCpuIdInfo->_next) {
if (hostCpuIdInfo->level->value == -2147483647) { /* 0x80000001 */
if (esxVI_ParseHostCpuIdInfo(&parsedHostCpuIdInfo,
- hostCpuIdInfo) < 0) {
+ hostCpuIdInfo) < 0)
goto cleanup;
- }
edxLongModeBit = parsedHostCpuIdInfo.edx[29];
@@ -529,18 +507,16 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid)
esxVI_ObjectContent *hostSystem = NULL;
char *uuid_string = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"hardware.systemInfo.uuid") < 0 ||
esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
&hostSystem) < 0 ||
esxVI_GetStringValue(hostSystem, "hardware.systemInfo.uuid",
- &uuid_string, esxVI_Occurrence_RequiredItem) < 0) {
+ &uuid_string, esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (strlen(uuid_string) > 0) {
if (virUUIDParse(uuid_string, uuid) < 0) {
@@ -571,15 +547,13 @@ esxCapsInit(esxPrivate *priv)
virCapsPtr caps = NULL;
virCapsGuestPtr guest = NULL;
- if (supportsLongMode == esxVI_Boolean_Undefined) {
+ if (supportsLongMode == esxVI_Boolean_Undefined)
return NULL;
- }
- if (supportsLongMode == esxVI_Boolean_True) {
+ if (supportsLongMode == esxVI_Boolean_True)
caps = virCapabilitiesNew(VIR_ARCH_X86_64, true, true);
- } else {
+ else
caps = virCapabilitiesNew(VIR_ARCH_I686, true, true);
- }
if (!caps)
return NULL;
@@ -587,9 +561,8 @@ esxCapsInit(esxPrivate *priv)
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
- if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) {
+ if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0)
goto failure;
- }
/* i686 */
guest = virCapabilitiesAddGuest(caps, "hvm",
@@ -597,13 +570,11 @@ esxCapsInit(esxPrivate *priv)
NULL, NULL, 0,
NULL);
- if (!guest) {
+ if (!guest)
goto failure;
- }
- if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL))
{
+ if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL))
goto failure;
- }
/* x86_64 */
if (supportsLongMode == esxVI_Boolean_True) {
@@ -612,13 +583,11 @@ esxCapsInit(esxPrivate *priv)
NULL, NULL,
0, NULL);
- if (!guest) {
+ if (!guest)
goto failure;
- }
- if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL)) {
+ if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL))
goto failure;
- }
}
return caps;
@@ -655,9 +624,8 @@ esxConnectToHost(esxPrivate *priv,
return -1;
}
- if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0)
{
+ if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0)
return -1;
- }
if (conn->uri->user) {
if (VIR_STRDUP(username, conn->uri->user) < 0)
@@ -680,9 +648,8 @@ esxConnectToHost(esxPrivate *priv,
password = esxUtil_EscapeForXml(unescapedPassword);
- if (!password) {
+ if (!password)
goto cleanup;
- }
if (virAsprintf(&url, "%s://%s:%d/sdk",
priv->parsedUri->transport,
conn->uri->server, conn->uri->port) < 0)
@@ -691,9 +658,8 @@ esxConnectToHost(esxPrivate *priv,
if (esxVI_Context_Alloc(&priv->host) < 0 ||
esxVI_Context_Connect(priv->host, url, ipAddress, username, password,
priv->parsedUri) < 0 ||
- esxVI_Context_LookupManagedObjects(priv->host) < 0) {
+ esxVI_Context_LookupManagedObjects(priv->host) < 0)
goto cleanup;
- }
if (expectedProductVersion == esxVI_ProductVersion_ESX) {
if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
@@ -727,14 +693,12 @@ esxConnectToHost(esxPrivate *priv,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetStringValue(hostSystem, "summary.managementServerIp",
vCenterIpAddress,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
/* Warn if host is in maintenance mode */
- if (inMaintenanceMode == esxVI_Boolean_True) {
+ if (inMaintenanceMode == esxVI_Boolean_True)
VIR_WARN("The server is in maintenance mode");
- }
if (VIR_STRDUP(*vCenterIpAddress, *vCenterIpAddress) < 0)
goto cleanup;
@@ -775,14 +739,12 @@ esxConnectToVCenter(esxPrivate *priv,
return -1;
}
- if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) {
+ if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0)
return -1;
- }
if (conn->uri->user) {
- if (VIR_STRDUP(username, conn->uri->user) < 0) {
+ if (VIR_STRDUP(username, conn->uri->user) < 0)
goto cleanup;
- }
} else {
username = virAuthGetUsername(conn, auth, "esx",
"administrator", hostname);
@@ -801,9 +763,8 @@ esxConnectToVCenter(esxPrivate *priv,
password = esxUtil_EscapeForXml(unescapedPassword);
- if (!password) {
+ if (!password)
goto cleanup;
- }
if (virAsprintf(&url, "%s://%s:%d/sdk",
priv->parsedUri->transport,
hostname, conn->uri->port) < 0)
@@ -811,9 +772,8 @@ esxConnectToVCenter(esxPrivate *priv,
if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
- password, priv->parsedUri) < 0) {
+ password, priv->parsedUri) < 0)
goto cleanup;
- }
if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
priv->vCenter->productVersion != esxVI_ProductVersion_VPX40 &&
@@ -830,14 +790,12 @@ esxConnectToVCenter(esxPrivate *priv,
if (hostSystemIpAddress) {
if (esxVI_Context_LookupManagedObjectsByHostSystemIp
- (priv->vCenter, hostSystemIpAddress) < 0) {
+ (priv->vCenter, hostSystemIpAddress) < 0)
goto cleanup;
- }
} else {
if (esxVI_Context_LookupManagedObjectsByPath(priv->vCenter,
- priv->parsedUri->path) < 0)
{
+ priv->parsedUri->path) <
0)
goto cleanup;
- }
}
result = 0;
@@ -911,9 +869,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Decline if the URI is NULL or the scheme is NULL */
- if (!conn->uri || !conn->uri->scheme) {
+ if (!conn->uri || !conn->uri->scheme)
return VIR_DRV_OPEN_DECLINED;
- }
/* Decline if the scheme is not one of {vpx|esx|gsx} */
plus = strchr(conn->uri->scheme, '+');
@@ -921,16 +878,14 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
if (!plus) {
if (STRCASENEQ(conn->uri->scheme, "vpx") &&
STRCASENEQ(conn->uri->scheme, "esx") &&
- STRCASENEQ(conn->uri->scheme, "gsx")) {
+ STRCASENEQ(conn->uri->scheme, "gsx"))
return VIR_DRV_OPEN_DECLINED;
- }
} else {
if (plus - conn->uri->scheme != 3 ||
(STRCASENEQLEN(conn->uri->scheme, "vpx", 3) &&
STRCASENEQLEN(conn->uri->scheme, "esx", 3) &&
- STRCASENEQLEN(conn->uri->scheme, "gsx", 3))) {
+ STRCASENEQLEN(conn->uri->scheme, "gsx", 3)))
return VIR_DRV_OPEN_DECLINED;
- }
virReportError(VIR_ERR_INVALID_ARG,
_("Transport '%s' in URI scheme is not supported, try
again "
@@ -962,9 +917,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
if (VIR_ALLOC(priv) < 0)
goto cleanup;
- if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) {
+ if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0)
goto cleanup;
- }
priv->maxVcpus = -1;
priv->supportsVMotion = esxVI_Boolean_Undefined;
@@ -999,9 +953,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
STRCASEEQ(conn->uri->scheme, "gsx")) {
/* Connect to host */
if (esxConnectToHost(priv, conn, auth,
- &potentialVCenterIpAddress) < 0) {
+ &potentialVCenterIpAddress) < 0)
goto cleanup;
- }
/* Connect to vCenter */
if (priv->parsedUri->vCenter) {
@@ -1021,9 +974,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
}
} else {
if (esxUtil_ResolveHostname(priv->parsedUri->vCenter,
- vCenterIpAddress, NI_MAXHOST) < 0) {
+ vCenterIpAddress, NI_MAXHOST) < 0)
goto cleanup;
- }
if (potentialVCenterIpAddress &&
STRNEQ(vCenterIpAddress, potentialVCenterIpAddress)) {
@@ -1039,9 +991,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
if (esxConnectToVCenter(priv, conn, auth,
vCenterIpAddress,
- priv->host->ipAddress) < 0) {
+ priv->host->ipAddress) < 0)
goto cleanup;
- }
}
priv->primary = priv->host;
@@ -1049,9 +1000,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
/* Connect to vCenter */
if (esxConnectToVCenter(priv, conn, auth,
conn->uri->server,
- NULL) < 0) {
+ NULL) < 0)
goto cleanup;
- }
priv->primary = priv->vCenter;
}
@@ -1059,9 +1009,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
/* Setup capabilities */
priv->caps = esxCapsInit(priv);
- if (!priv->caps) {
+ if (!priv->caps)
goto cleanup;
- }
if (!(priv->xmlopt = virVMXDomainXMLConfInit()))
goto cleanup;
@@ -1087,16 +1036,14 @@ esxConnectClose(virConnectPtr conn)
if (priv->host) {
if (esxVI_EnsureSession(priv->host) < 0 ||
- esxVI_Logout(priv->host) < 0) {
+ esxVI_Logout(priv->host) < 0)
result = -1;
- }
}
if (priv->vCenter) {
if (esxVI_EnsureSession(priv->vCenter) < 0 ||
- esxVI_Logout(priv->vCenter) < 0) {
+ esxVI_Logout(priv->vCenter) < 0)
result = -1;
- }
}
esxFreePrivate(&priv);
@@ -1114,13 +1061,11 @@ esxSupportsVMotion(esxPrivate *priv)
esxVI_String *propertyNameList = NULL;
esxVI_ObjectContent *hostSystem = NULL;
- if (priv->supportsVMotion != esxVI_Boolean_Undefined) {
+ if (priv->supportsVMotion != esxVI_Boolean_Undefined)
return priv->supportsVMotion;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return esxVI_Boolean_Undefined;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"capability.vmotionSupported") < 0
||
@@ -1128,9 +1073,8 @@ esxSupportsVMotion(esxPrivate *priv)
&hostSystem) < 0 ||
esxVI_GetBoolean(hostSystem, "capability.vmotionSupported",
&priv->supportsVMotion,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
cleanup:
/*
@@ -1189,9 +1133,8 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
case VIR_DRV_FEATURE_MIGRATION_V1:
supportsVMotion = esxSupportsVMotion(priv);
- if (supportsVMotion == esxVI_Boolean_Undefined) {
+ if (supportsVMotion == esxVI_Boolean_Undefined)
return -1;
- }
/* Migration is only possible via a vCenter and if VMotion is enabled */
return priv->vCenter &&
@@ -1242,35 +1185,31 @@ esxConnectGetHostname(virConnectPtr conn)
const char *domainName = NULL;
char *complete = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList
(&propertyNameList,
"config.network.dnsConfig.hostName\0"
"config.network.dnsConfig.domainName\0") < 0 ||
esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name,
"config.network.dnsConfig.hostName")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ esxVI_Type_String) < 0)
goto cleanup;
- }
hostName = dynamicProperty->val->string;
} else if (STREQ(dynamicProperty->name,
"config.network.dnsConfig.domainName")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ esxVI_Type_String) < 0)
goto cleanup;
- }
domainName = dynamicProperty->val->string;
} else {
@@ -1324,9 +1263,8 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
memset(nodeinfo, 0, sizeof(*nodeinfo));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"hardware.cpuInfo.hz\0"
@@ -1337,64 +1275,56 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
"hardware.numaInfo.numNodes\0"
"summary.hardware.cpuModel\0") <
0 ||
esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "hardware.cpuInfo.hz")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
cpuInfo_hz = dynamicProperty->val->int64;
} else if (STREQ(dynamicProperty->name,
"hardware.cpuInfo.numCpuCores")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Short) < 0) {
+ esxVI_Type_Short) < 0)
goto cleanup;
- }
cpuInfo_numCpuCores = dynamicProperty->val->int16;
} else if (STREQ(dynamicProperty->name,
"hardware.cpuInfo.numCpuPackages")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Short) < 0) {
+ esxVI_Type_Short) < 0)
goto cleanup;
- }
cpuInfo_numCpuPackages = dynamicProperty->val->int16;
} else if (STREQ(dynamicProperty->name,
"hardware.cpuInfo.numCpuThreads")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Short) < 0) {
+ esxVI_Type_Short) < 0)
goto cleanup;
- }
cpuInfo_numCpuThreads = dynamicProperty->val->int16;
} else if (STREQ(dynamicProperty->name, "hardware.memorySize")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
memorySize = dynamicProperty->val->int64;
} else if (STREQ(dynamicProperty->name,
"hardware.numaInfo.numNodes")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Int) < 0) {
+ esxVI_Type_Int) < 0)
goto cleanup;
- }
numaInfo_numNodes = dynamicProperty->val->int32;
} else if (STREQ(dynamicProperty->name,
"summary.hardware.cpuModel")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ esxVI_Type_String) < 0)
goto cleanup;
- }
ptr = dynamicProperty->val->string;
@@ -1471,31 +1401,26 @@ esxConnectListDomains(virConnectPtr conn, int *ids, int maxids)
esxVI_VirtualMachinePowerState powerState;
int count = 0;
- if (maxids == 0) {
+ if (maxids == 0)
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineList(priv->primary, propertyNameList,
- &virtualMachineList) < 0) {
+ &virtualMachineList) < 0)
goto cleanup;
- }
for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
- &powerState) < 0) {
+ &powerState) < 0)
goto cleanup;
- }
- if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) {
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOn)
continue;
- }
if (esxUtil_ParseVirtualMachineIDString(virtualMachine->obj->value,
&ids[count]) < 0 ||
@@ -1508,9 +1433,8 @@ esxConnectListDomains(virConnectPtr conn, int *ids, int maxids)
count++;
- if (count >= maxids) {
+ if (count >= maxids)
break;
- }
}
success = true;
@@ -1529,9 +1453,8 @@ esxConnectNumOfDomains(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return esxVI_LookupNumberOfDomainsByPowerState
(priv->primary, esxVI_VirtualMachinePowerState_PoweredOn, false);
@@ -1552,9 +1475,8 @@ esxDomainLookupByID(virConnectPtr conn, int id)
unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"configStatus\0"
@@ -1562,48 +1484,41 @@ esxDomainLookupByID(virConnectPtr conn, int id)
"runtime.powerState\0"
"config.uuid\0") < 0 ||
esxVI_LookupVirtualMachineList(priv->primary, propertyNameList,
- &virtualMachineList) < 0) {
+ &virtualMachineList) < 0)
goto cleanup;
- }
for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
- &powerState) < 0) {
+ &powerState) < 0)
goto cleanup;
- }
/* Only running/suspended domains have an ID != -1 */
- if (powerState == esxVI_VirtualMachinePowerState_PoweredOff) {
+ if (powerState == esxVI_VirtualMachinePowerState_PoweredOff)
continue;
- }
VIR_FREE(name_candidate);
if (esxVI_GetVirtualMachineIdentity(virtualMachine,
&id_candidate, &name_candidate,
- uuid_candidate) < 0) {
+ uuid_candidate) < 0)
goto cleanup;
- }
- if (id != id_candidate) {
+ if (id != id_candidate)
continue;
- }
domain = virGetDomain(conn, name_candidate, uuid_candidate);
- if (!domain) {
+ if (!domain)
goto cleanup;
- }
domain->id = id;
break;
}
- if (!domain) {
+ if (!domain)
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
- }
cleanup:
esxVI_String_Free(&propertyNameList);
@@ -1626,9 +1541,8 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char
*uuid)
char *name = NULL;
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
@@ -1637,22 +1551,19 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char
*uuid)
&virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachineIdentity(virtualMachine, &id, &name, NULL) < 0
||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
domain = virGetDomain(conn, name, uuid);
- if (!domain) {
+ if (!domain)
goto cleanup;
- }
/* Only running/suspended virtual machines have an ID != -1 */
- if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
domain->id = id;
- } else {
+ else
domain->id = -1;
- }
cleanup:
esxVI_String_Free(&propertyNameList);
@@ -1675,9 +1586,8 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
unsigned char uuid[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"configStatus\0"
@@ -1685,9 +1595,8 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
"config.uuid\0") < 0 ||
esxVI_LookupVirtualMachineByName(priv->primary, name, propertyNameList,
&virtualMachine,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!virtualMachine) {
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with name
'%s'"), name);
@@ -1695,22 +1604,19 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
}
if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, uuid) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
domain = virGetDomain(conn, name, uuid);
- if (!domain) {
+ if (!domain)
goto cleanup;
- }
/* Only running/suspended virtual machines have an ID != -1 */
- if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
domain->id = id;
- } else {
+ else
domain->id = -1;
- }
cleanup:
esxVI_String_Free(&propertyNameList);
@@ -1733,18 +1639,16 @@ esxDomainSuspend(virDomainPtr domain)
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -1756,9 +1660,8 @@ esxDomainSuspend(virDomainPtr domain)
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not suspend domain:
%s"),
@@ -1791,18 +1694,16 @@ esxDomainResume(virDomainPtr domain)
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_Suspended) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not
suspended"));
@@ -1814,9 +1715,8 @@ esxDomainResume(virDomainPtr domain)
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not resume domain:
%s"),
@@ -1848,18 +1748,16 @@ esxDomainShutdownFlags(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -1867,9 +1765,8 @@ esxDomainShutdownFlags(virDomainPtr domain, unsigned int flags)
goto cleanup;
}
- if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0) {
+ if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0)
goto cleanup;
- }
result = 0;
@@ -1899,18 +1796,16 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -1918,9 +1813,8 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags)
goto cleanup;
}
- if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0) {
+ if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0)
goto cleanup;
- }
result = 0;
@@ -1949,24 +1843,21 @@ esxDomainDestroyFlags(virDomainPtr domain,
virCheckFlags(0, -1);
- if (priv->vCenter) {
+ if (priv->vCenter)
ctx = priv->vCenter;
- } else {
+ else
ctx = priv->host;
- }
- if (esxVI_EnsureSession(ctx) < 0) {
+ if (esxVI_EnsureSession(ctx) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(ctx, domain->uuid, propertyNameList, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -1978,9 +1869,8 @@ esxDomainDestroyFlags(virDomainPtr domain,
esxVI_WaitForTaskCompletion(ctx, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not destroy domain:
%s"),
@@ -2028,25 +1918,22 @@ esxDomainGetMaxMemory(virDomainPtr domain)
esxVI_DynamicProperty *dynamicProperty = NULL;
unsigned long memoryMB = 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return 0;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.hardware.memoryMB") < 0 ||
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.hardware.memoryMB")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Int) < 0) {
+ esxVI_Type_Int) < 0)
goto cleanup;
- }
if (dynamicProperty->val->int32 < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2084,18 +1971,16 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2104,9 +1989,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
}
if (esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
- esxVI_Long_Alloc(&spec->memoryMB) < 0) {
+ esxVI_Long_Alloc(&spec->memoryMB) < 0)
goto cleanup;
- }
/* max-memory must be a multiple of 4096 kilobyte */
spec->memoryMB->value =
@@ -2117,9 +2001,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2153,18 +2036,16 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0 ||
- esxVI_Long_Alloc(&spec->memoryAllocation->limit) < 0) {
+ esxVI_Long_Alloc(&spec->memoryAllocation->limit) < 0)
goto cleanup;
- }
spec->memoryAllocation->limit->value =
VIR_DIV_UP(memory, 1024); /* Scale from kilobytes to megabytes */
@@ -2174,9 +2055,8 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2234,9 +2114,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
memset(info, 0, sizeof(*info));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"runtime.powerState\0"
@@ -2245,9 +2124,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
"config.memoryAllocation.limit\0")
< 0 ||
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
info->state = VIR_DOMAIN_NOSTATE;
@@ -2255,38 +2133,33 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.powerState")) {
if (esxVI_VirtualMachinePowerState_CastFromAnyType
- (dynamicProperty->val, &powerState) < 0) {
+ (dynamicProperty->val, &powerState) < 0)
goto cleanup;
- }
info->state = esxVI_VirtualMachinePowerState_ConvertToLibvirt
(powerState);
} else if (STREQ(dynamicProperty->name, "config.hardware.memoryMB"))
{
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Int) < 0) {
+ esxVI_Type_Int) < 0)
goto cleanup;
- }
info->maxMem = dynamicProperty->val->int32 * 1024; /* Scale from
megabyte to kilobyte */
} else if (STREQ(dynamicProperty->name, "config.hardware.numCPU"))
{
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Int) < 0) {
+ esxVI_Type_Int) < 0)
goto cleanup;
- }
info->nrVirtCpu = dynamicProperty->val->int32;
} else if (STREQ(dynamicProperty->name,
"config.memoryAllocation.limit")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
memory_limit = dynamicProperty->val->int64;
- if (memory_limit > 0) {
+ if (memory_limit > 0)
memory_limit *= 1024; /* Scale from megabyte to kilobyte */
- }
} else {
VIR_WARN("Unexpected '%s' property",
dynamicProperty->name);
}
@@ -2300,20 +2173,17 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
/* FIXME: Currently no host for a vpx:// connection */
if (priv->host) {
if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId
>= 0) {
- if (esxVI_Int_Alloc(&counterId) < 0) {
+ if (esxVI_Int_Alloc(&counterId) < 0)
goto cleanup;
- }
counterId->value = priv->usedCpuTimeCounterId;
- if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0)
goto cleanup;
- }
if (esxVI_QueryPerfCounter(priv->host, counterIdList,
- &perfCounterInfo) < 0) {
+ &perfCounterInfo) < 0)
goto cleanup;
- }
if (STRNEQ(perfCounterInfo->groupInfo->key, "cpu") ||
STRNEQ(perfCounterInfo->nameInfo->key, "used") ||
@@ -2335,9 +2205,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId
< 0) {
if (esxVI_QueryAvailablePerfMetric(priv->host, virtualMachine->obj,
NULL, NULL, NULL,
- &perfMetricIdList) < 0) {
+ &perfMetricIdList) < 0)
goto cleanup;
- }
for (perfMetricId = perfMetricIdList; perfMetricId;
perfMetricId = perfMetricId->_next) {
@@ -2347,15 +2216,13 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
counterId = NULL;
if (esxVI_Int_DeepCopy(&counterId, perfMetricId->counterId) < 0
||
- esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ esxVI_Int_AppendToList(&counterIdList, counterId) < 0)
goto cleanup;
- }
}
if (esxVI_QueryPerfCounter(priv->host, counterIdList,
- &perfCounterInfoList) < 0) {
+ &perfCounterInfoList) < 0)
goto cleanup;
- }
for (perfCounterInfo = perfCounterInfoList; perfCounterInfo;
perfCounterInfo = perfCounterInfo->_next) {
@@ -2376,9 +2243,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
}
}
- if (priv->usedCpuTimeCounterId < 0) {
+ if (priv->usedCpuTimeCounterId < 0)
VIR_WARN("Could not find 'used CPU time' performance
counter");
- }
}
/*
@@ -2391,9 +2257,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
if (esxVI_PerfQuerySpec_Alloc(&querySpec) < 0 ||
esxVI_Int_Alloc(&querySpec->maxSample) < 0 ||
esxVI_PerfMetricId_Alloc(&querySpec->metricId) < 0 ||
- esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0) {
+ esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0)
goto cleanup;
- }
querySpec->entity = virtualMachine->obj;
querySpec->maxSample->value = 1;
@@ -2402,9 +2267,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
querySpec->format = (char *)"normal";
if (esxVI_QueryPerf(priv->host, querySpec,
- &perfEntityMetricBaseList) < 0) {
+ &perfEntityMetricBaseList) < 0)
goto cleanup;
- }
for (perfEntityMetricBase = perfEntityMetricBaseList;
perfEntityMetricBase;
@@ -2437,9 +2301,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
for (value = perfMetricIntSeries->value;
value;
- value = value->_next) {
+ value = value->_next)
VIR_DEBUG("value %lld", (long long
int)value->value);
- }
}
}
@@ -2465,9 +2328,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
querySpec->entity = NULL;
querySpec->format = NULL;
- if (querySpec->metricId) {
+ if (querySpec->metricId)
querySpec->metricId->instance = NULL;
- }
}
#endif
@@ -2500,18 +2362,16 @@ esxDomainGetState(virDomainPtr domain,
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
*state = esxVI_VirtualMachinePowerState_ConvertToLibvirt(powerState);
@@ -2631,15 +2491,13 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
return -1;
}
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
maxVcpus = esxDomainGetMaxVcpus(domain);
- if (maxVcpus < 0) {
+ if (maxVcpus < 0)
return -1;
- }
if (nvcpus > maxVcpus) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -2653,9 +2511,8 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
- esxVI_Int_Alloc(&spec->numCPUs) < 0) {
+ esxVI_Int_Alloc(&spec->numCPUs) < 0)
goto cleanup;
- }
spec->numCPUs->value = nvcpus;
@@ -2664,9 +2521,8 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2709,30 +2565,26 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
return -1;
}
- if (priv->maxVcpus > 0) {
+ if (priv->maxVcpus > 0)
return priv->maxVcpus;
- }
priv->maxVcpus = -1;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"capability.maxSupportedVcpus") < 0
||
esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "capability.maxSupportedVcpus")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Int) < 0) {
+ esxVI_Type_Int) < 0)
goto cleanup;
- }
priv->maxVcpus = dynamicProperty->val->int32;
break;
@@ -2783,9 +2635,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
memset(&data, 0, sizeof(data));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"config.files.vmPathName\0"
@@ -2796,14 +2647,12 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0 ||
esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, NULL) < 0 ||
esxVI_GetStringValue(virtualMachine, "config.files.vmPathName",
- &vmPathName, esxVI_Occurrence_RequiredItem) < 0) {
+ &vmPathName, esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (esxUtil_ParseDatastorePath(vmPathName, &datastoreName, &directoryName,
- &directoryAndFileName) < 0) {
+ &directoryAndFileName) < 0)
goto cleanup;
- }
virBufferAsprintf(&buffer, "%s://%s:%d/folder/",
priv->parsedUri->transport,
domain->conn->uri->server,
domain->conn->uri->port);
@@ -2818,9 +2667,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
url = virBufferContentAndReset(&buffer);
- if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0) {
+ if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0)
goto cleanup;
- }
data.ctx = priv->primary;
@@ -2842,17 +2690,15 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
def = virVMXParseConfig(&ctx, priv->xmlopt, vmx);
if (def) {
- if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
def->id = id;
- }
xml = virDomainDefFormat(def, flags);
}
cleanup:
- if (!url) {
+ if (!url)
virBufferFreeAndReset(&buffer);
- }
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachine);
@@ -2900,9 +2746,8 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, const char
*nativeFormat,
def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig);
- if (def) {
+ if (def)
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
- }
virDomainDefFree(def);
@@ -2936,17 +2781,15 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const char
*nativeFormat,
virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion
(priv->primary->productVersion);
- if (virtualHW_version < 0) {
+ if (virtualHW_version < 0)
return NULL;
- }
def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt,
1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE);
- if (!def) {
+ if (!def)
return NULL;
- }
data.ctx = priv->primary;
data.datastorePathWithoutFileName = NULL;
@@ -2977,54 +2820,46 @@ esxConnectListDefinedDomains(virConnectPtr conn, char **const
names, int maxname
int count = 0;
size_t i;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
"runtime.powerState\0") < 0 ||
esxVI_LookupVirtualMachineList(priv->primary, propertyNameList,
- &virtualMachineList) < 0) {
+ &virtualMachineList) < 0)
goto cleanup;
- }
for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
- &powerState) < 0) {
+ &powerState) < 0)
goto cleanup;
- }
- if (powerState == esxVI_VirtualMachinePowerState_PoweredOn) {
+ if (powerState == esxVI_VirtualMachinePowerState_PoweredOn)
continue;
- }
names[count] = NULL;
if (esxVI_GetVirtualMachineIdentity(virtualMachine, NULL, &names[count],
- NULL) < 0) {
+ NULL) < 0)
goto cleanup;
- }
++count;
- if (count >= maxnames) {
+ if (count >= maxnames)
break;
- }
}
success = true;
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
@@ -3042,9 +2877,8 @@ esxConnectNumOfDefinedDomains(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return esxVI_LookupNumberOfDomainsByPowerState
(priv->primary, esxVI_VirtualMachinePowerState_PoweredOn, true);
@@ -3067,9 +2901,8 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
@@ -3077,9 +2910,8 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0 ||
- esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, NULL) < 0) {
+ esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, NULL) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -3092,9 +2924,8 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not start domain:
%s"),
@@ -3153,32 +2984,28 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
memset(&data, 0, sizeof(data));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
/* Parse domain XML */
def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE);
- if (!def) {
+ if (!def)
return NULL;
- }
/* Check if an existing domain should be edited */
if (esxVI_LookupVirtualMachineByUuid(priv->primary, def->uuid, NULL,
&virtualMachine,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!virtualMachine &&
esxVI_LookupVirtualMachineByName(priv->primary, def->name, NULL,
&virtualMachine,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (virtualMachine) {
/* FIXME */
@@ -3192,9 +3019,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion
(priv->primary->productVersion);
- if (virtualHW_version < 0) {
+ if (virtualHW_version < 0)
goto cleanup;
- }
data.ctx = priv->primary;
data.datastorePathWithoutFileName = NULL;
@@ -3206,9 +3032,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version);
- if (!vmx) {
+ if (!vmx)
goto cleanup;
- }
/*
* Build VMX datastore URL. Use the source of the first file-based harddisk
@@ -3248,9 +3073,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
}
if (esxUtil_ParseDatastorePath(src, &datastoreName, &directoryName,
- NULL) < 0) {
+ NULL) < 0)
goto cleanup;
- }
if (! virFileHasSuffix(src, ".vmdk")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3269,9 +3093,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
escapedName = esxUtil_EscapeDatastoreItem(def->name);
- if (!escapedName) {
+ if (!escapedName)
goto cleanup;
- }
virBufferURIEncodeString(&buffer, escapedName);
virBufferAddLit(&buffer, ".vmx?dcPath=");
@@ -3290,9 +3113,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
/* Upload VMX file */
VIR_DEBUG("Uploading .vmx config, url='%s' vmx='%s'", url,
vmx);
- if (esxVI_CURL_Upload(priv->primary->curl, url, vmx) < 0) {
+ if (esxVI_CURL_Upload(priv->primary->curl, url, vmx) < 0)
goto cleanup;
- }
/* Register the domain */
if (directoryName) {
@@ -3313,9 +3135,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
esxVI_WaitForTaskCompletion(priv->primary, task, def->uuid,
esxVI_Occurrence_OptionalItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not define domain:
%s"),
@@ -3325,16 +3146,14 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
domain = virGetDomain(conn, def->name, def->uuid);
- if (domain) {
+ if (domain)
domain->id = -1;
- }
/* FIXME: Add proper rollback in case of an error */
cleanup:
- if (!url) {
+ if (!url)
virBufferFreeAndReset(&buffer);
- }
virDomainDefFree(def);
VIR_FREE(vmx);
@@ -3371,24 +3190,21 @@ esxDomainUndefineFlags(virDomainPtr domain,
* ESX, so we can trivially ignore that flag. */
virCheckFlags(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, -1);
- if (priv->vCenter) {
+ if (priv->vCenter)
ctx = priv->vCenter;
- } else {
+ else
ctx = priv->host;
- }
- if (esxVI_EnsureSession(ctx) < 0) {
+ if (esxVI_EnsureSession(ctx) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuid(ctx, domain->uuid, propertyNameList,
&virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
if (powerState != esxVI_VirtualMachinePowerState_Suspended &&
powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
@@ -3397,9 +3213,8 @@ esxDomainUndefineFlags(virDomainPtr domain,
goto cleanup;
}
- if (esxVI_UnregisterVM(ctx, virtualMachine->obj) < 0) {
+ if (esxVI_UnregisterVM(ctx, virtualMachine->obj) < 0)
goto cleanup;
- }
result = 0;
@@ -3430,14 +3245,12 @@ esxDomainGetAutostart(virDomainPtr domain, int *autostart)
*autostart = 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* Check general autostart config */
- if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) {
+ if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0)
goto cleanup;
- }
if (defaults->enabled != esxVI_Boolean_True) {
/* Autostart is disabled in general, exit early here */
@@ -3446,9 +3259,8 @@ esxDomainGetAutostart(virDomainPtr domain, int *autostart)
}
/* Check specific autostart config */
- if (esxVI_LookupAutoStartPowerInfoList(priv->primary, &powerInfoList) < 0)
{
+ if (esxVI_LookupAutoStartPowerInfoList(priv->primary, &powerInfoList) < 0)
goto cleanup;
- }
if (!powerInfoList) {
/* powerInfo list is empty, exit early here */
@@ -3458,16 +3270,14 @@ esxDomainGetAutostart(virDomainPtr domain, int *autostart)
if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
NULL, &virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (powerInfo = powerInfoList; powerInfo;
powerInfo = powerInfo->_next) {
if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) {
- if (STRCASEEQ(powerInfo->startAction, "powerOn")) {
+ if (STRCASEEQ(powerInfo->startAction, "powerOn"))
*autostart = 1;
- }
break;
}
@@ -3498,16 +3308,14 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
esxVI_AutoStartPowerInfo *powerInfo = NULL;
esxVI_AutoStartPowerInfo *newPowerInfo = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
NULL, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_HostAutoStartManagerConfig_Alloc(&spec) < 0) {
+ esxVI_HostAutoStartManagerConfig_Alloc(&spec) < 0)
goto cleanup;
- }
if (autostart) {
/*
@@ -3516,9 +3324,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
* autostart. If it's enabled then the autostart behavior depends on
* the per-domain autostart config.
*/
- if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) {
+ if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0)
goto cleanup;
- }
if (defaults->enabled != esxVI_Boolean_True) {
/*
@@ -3528,9 +3335,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
* behavior of other domains.
*/
if (esxVI_LookupAutoStartPowerInfoList(priv->primary,
- &powerInfoList) < 0) {
+ &powerInfoList) < 0)
goto cleanup;
- }
for (powerInfo = powerInfoList; powerInfo;
powerInfo = powerInfo->_next) {
@@ -3543,9 +3349,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
}
/* Enable autostart in general */
- if (esxVI_AutoStartDefaults_Alloc(&spec->defaults) < 0) {
+ if (esxVI_AutoStartDefaults_Alloc(&spec->defaults) < 0)
goto cleanup;
- }
spec->defaults->enabled = esxVI_Boolean_True;
}
@@ -3554,9 +3359,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
if (esxVI_AutoStartPowerInfo_Alloc(&newPowerInfo) < 0 ||
esxVI_Int_Alloc(&newPowerInfo->startOrder) < 0 ||
esxVI_Int_Alloc(&newPowerInfo->startDelay) < 0 ||
- esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0) {
+ esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0)
goto cleanup;
- }
newPowerInfo->key = virtualMachine->obj;
newPowerInfo->startOrder->value = -1; /* no specific start order */
@@ -3567,18 +3371,16 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
newPowerInfo->stopAction = (char *)"none";
if (esxVI_AutoStartPowerInfo_AppendToList(&spec->powerInfo,
- newPowerInfo) < 0) {
+ newPowerInfo) < 0)
goto cleanup;
- }
newPowerInfo = NULL;
if (esxVI_ReconfigureAutostart
(priv->primary,
priv->primary->hostSystem->configManager->autoStartManager,
- spec) < 0) {
+ spec) < 0)
goto cleanup;
- }
result = 0;
@@ -3639,9 +3441,8 @@ esxDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int
*nparams)
if (VIR_STRDUP(type, "allocation") < 0)
return NULL;
- if (nparams) {
+ if (nparams)
*nparams = 3; /* reservation, limit, shares */
- }
return type;
}
@@ -3664,9 +3465,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"config.cpuAllocation.reservation\0"
@@ -3674,9 +3474,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
"config.cpuAllocation.shares\0")
< 0 ||
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = virtualMachine->propSet;
dynamicProperty && mask != 7 && i < 3 && i <
*nparams;
@@ -3684,9 +3483,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
if (STREQ(dynamicProperty->name, "config.cpuAllocation.reservation")
&&
! (mask & (1 << 0))) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
if (virTypedParameterAssign(¶ms[i],
VIR_DOMAIN_SCHEDULER_RESERVATION,
VIR_TYPED_PARAM_LLONG,
@@ -3698,9 +3496,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
"config.cpuAllocation.limit") &&
! (mask & (1 << 1))) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
if (virTypedParameterAssign(¶ms[i],
VIR_DOMAIN_SCHEDULER_LIMIT,
VIR_TYPED_PARAM_LLONG,
@@ -3716,9 +3513,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
VIR_TYPED_PARAM_INT, 0) < 0)
goto cleanup;
if (esxVI_SharesInfo_CastFromAnyType(dynamicProperty->val,
- &sharesInfo) < 0) {
+ &sharesInfo) < 0)
goto cleanup;
- }
switch (sharesInfo->level) {
case esxVI_SharesLevel_Custom:
@@ -3798,23 +3594,20 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
NULL) < 0)
return -1;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
- esxVI_ResourceAllocationInfo_Alloc(&spec->cpuAllocation) < 0) {
+ esxVI_ResourceAllocationInfo_Alloc(&spec->cpuAllocation) < 0)
goto cleanup;
- }
for (i = 0; i < nparams; ++i) {
if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_RESERVATION)) {
- if (esxVI_Long_Alloc(&spec->cpuAllocation->reservation) < 0) {
+ if (esxVI_Long_Alloc(&spec->cpuAllocation->reservation) < 0)
goto cleanup;
- }
if (params[i].value.l < 0) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -3825,9 +3618,8 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
spec->cpuAllocation->reservation->value = params[i].value.l;
} else if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_LIMIT)) {
- if (esxVI_Long_Alloc(&spec->cpuAllocation->limit) < 0) {
+ if (esxVI_Long_Alloc(&spec->cpuAllocation->limit) < 0)
goto cleanup;
- }
if (params[i].value.l < -1) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -3840,9 +3632,8 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
spec->cpuAllocation->limit->value = params[i].value.l;
} else if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_SHARES)) {
if (esxVI_SharesInfo_Alloc(&sharesInfo) < 0 ||
- esxVI_Int_Alloc(&sharesInfo->shares) < 0) {
+ esxVI_Int_Alloc(&sharesInfo->shares) < 0)
goto cleanup;
- }
spec->cpuAllocation->shares = sharesInfo;
sharesInfo = NULL;
@@ -3885,9 +3676,8 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3986,9 +3776,8 @@ esxDomainMigratePerform(virDomainPtr domain,
return -1;
}
- if (esxVI_EnsureSession(priv->vCenter) < 0) {
+ if (esxVI_EnsureSession(priv->vCenter) < 0)
return -1;
- }
/* Parse migration URI */
if (!(parsedUri = virURIParse(uri)))
@@ -4029,16 +3818,14 @@ esxDomainMigratePerform(virDomainPtr domain,
/* Lookup VirtualMachine */
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->vCenter, domain->uuid, NULL, &virtualMachine,
- priv->parsedUri->autoAnswer) < 0) {
+ priv->parsedUri->autoAnswer) < 0)
goto cleanup;
- }
/* Validate the purposed migration */
if (esxVI_ValidateMigration(priv->vCenter, virtualMachine->obj,
esxVI_VirtualMachinePowerState_Undefined, NULL,
- &resourcePool, &hostSystem, &eventList) <
0) {
+ &resourcePool, &hostSystem, &eventList) <
0)
goto cleanup;
- }
if (eventList) {
/*
@@ -4067,9 +3854,8 @@ esxDomainMigratePerform(virDomainPtr domain,
esxVI_WaitForTaskCompletion(priv->vCenter, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4117,9 +3903,8 @@ esxNodeGetFreeMemory(virConnectPtr conn)
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return 0;
- }
/* Get memory usage of resource pool */
if (esxVI_String_AppendValueToList(&propertyNameList,
@@ -4128,17 +3913,15 @@ esxNodeGetFreeMemory(virConnectPtr conn)
priv->primary->computeResource->resourcePool,
"ResourcePool", propertyNameList,
&resourcePool,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = resourcePool->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.memory")) {
if (esxVI_ResourcePoolResourceUsage_CastFromAnyType
- (dynamicProperty->val, &resourcePoolResourceUsage) < 0) {
+ (dynamicProperty->val, &resourcePoolResourceUsage) < 0)
goto cleanup;
- }
break;
} else {
@@ -4169,11 +3952,10 @@ esxConnectIsEncrypted(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (STRCASEEQ(priv->parsedUri->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https"))
return 1;
- } else {
+ else
return 0;
- }
}
@@ -4183,11 +3965,10 @@ esxConnectIsSecure(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (STRCASEEQ(priv->parsedUri->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https"))
return 1;
- } else {
+ else
return 0;
- }
}
@@ -4218,24 +3999,21 @@ esxDomainIsActive(virDomainPtr domain)
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
goto cleanup;
- }
- if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
result = 1;
- } else {
+ else
result = 0;
- }
cleanup:
esxVI_ObjectContent_Free(&virtualMachine);
@@ -4322,16 +4100,14 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char
*xmlDesc,
VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE |
VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
def = virDomainSnapshotDefParseString(xmlDesc, priv->caps,
priv->xmlopt, 0, 0);
- if (!def) {
+ if (!def)
return NULL;
- }
if (def->ndisks) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -4346,9 +4122,8 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char
*xmlDesc,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,
&snapshotTree, NULL,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (snapshotTree) {
virReportError(VIR_ERR_OPERATION_INVALID,
@@ -4364,9 +4139,8 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char
*xmlDesc,
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not create snapshot:
%s"),
@@ -4404,26 +4178,23 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
memset(&def, 0, sizeof(def));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
def.name = snapshot->name;
def.description = snapshotTree->description;
def.parent = snapshotTreeParent ? snapshotTreeParent->name : NULL;
if (esxVI_DateTime_ConvertToCalendarTime(snapshotTree->createTime,
- &def.creationTime) < 0) {
+ &def.creationTime) < 0)
goto cleanup;
- }
def.state = esxVI_VirtualMachinePowerState_ConvertToLibvirt
(snapshotTree->state);
@@ -4456,18 +4227,16 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* ESX snapshots do not require libvirt to maintain any metadata. */
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA)
return 0;
if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
- &rootSnapshotTreeList) < 0) {
+ &rootSnapshotTreeList) < 0)
return -1;
- }
count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse,
leaves);
@@ -4501,18 +4270,15 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int
nameslen,
return -1;
}
- if (nameslen == 0 || (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA)) {
+ if (nameslen == 0 || (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA))
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
- &rootSnapshotTreeList) < 0) {
+ &rootSnapshotTreeList) < 0)
return -1;
- }
result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen,
recurse, leaves);
@@ -4541,17 +4307,15 @@ esxDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
unsigned int flags)
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) != 0;
leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotTreeList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, snapshot->name,
&snapshotTree, NULL,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* ESX snapshots do not require libvirt to maintain any metadata. */
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) {
@@ -4594,21 +4358,18 @@ esxDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
return -1;
}
- if (nameslen == 0) {
+ if (nameslen == 0)
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotTreeList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, snapshot->name,
&snapshotTree, NULL,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* ESX snapshots do not require libvirt to maintain any metadata. */
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) {
@@ -4638,17 +4399,15 @@ esxDomainSnapshotLookupByName(virDomainPtr domain, const char
*name,
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, name, &snapshotTree,
NULL,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
snapshot = virGetDomainSnapshot(domain, name);
@@ -4668,15 +4427,13 @@ esxDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int
flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
return -1;
- }
if (currentSnapshotTree) {
esxVI_VirtualMachineSnapshotTree_Free(¤tSnapshotTree);
@@ -4699,17 +4456,15 @@ esxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned
int flags)
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (!snapshotTreeParent) {
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
@@ -4737,15 +4492,13 @@ esxDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return NULL;
- }
snapshot = virGetDomainSnapshot(domain, currentSnapshotTree->name);
@@ -4766,24 +4519,21 @@ esxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned
int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* Check that snapshot exists. */
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, NULL,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (esxVI_LookupCurrentSnapshotTree(priv->primary, snapshot->domain->uuid,
¤tSnapshotTree,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
ret = STREQ(snapshot->name, currentSnapshotTree->name);
@@ -4804,18 +4554,16 @@ esxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* Check that snapshot exists. If so, there is no metadata. */
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, NULL,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
ret = 0;
@@ -4838,26 +4586,23 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned
int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, NULL,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (esxVI_RevertToSnapshot_Task(priv->primary, snapshotTree->snapshot, NULL,
esxVI_Boolean_Undefined, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task,
snapshot->domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4893,21 +4638,18 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned
int flags)
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
- if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) {
+ if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)
removeChildren = esxVI_Boolean_True;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, NULL,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* ESX snapshots do not require any libvirt metadata, making this
* flag trivial once we know we have a valid snapshot. */
@@ -4921,9 +4663,8 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int
flags)
esxVI_WaitForTaskCompletion(priv->primary, task,
snapshot->domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4964,23 +4705,20 @@ esxDomainSetMemoryParameters(virDomainPtr domain,
virTypedParameterPtr params,
NULL) < 0)
return -1;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
- esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0) {
+ esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0)
goto cleanup;
- }
for (i = 0; i < nparams; ++i) {
if (STREQ(params[i].field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) {
- if (esxVI_Long_Alloc(&spec->memoryAllocation->reservation) < 0)
{
+ if (esxVI_Long_Alloc(&spec->memoryAllocation->reservation) < 0)
goto cleanup;
- }
spec->memoryAllocation->reservation->value =
VIR_DIV_UP(params[i].value.ul, 1024); /* Scale from kilobytes to megabytes
*/
@@ -4992,9 +4730,8 @@ esxDomainSetMemoryParameters(virDomainPtr domain,
virTypedParameterPtr params,
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -5033,9 +4770,8 @@ esxDomainGetMemoryParameters(virDomainPtr domain,
virTypedParameterPtr params,
return 0;
}
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList
(&propertyNameList, "config.memoryAllocation.reservation") < 0
||
@@ -5043,9 +4779,8 @@ esxDomainGetMemoryParameters(virDomainPtr domain,
virTypedParameterPtr params,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetLong(virtualMachine, "config.memoryAllocation.reservation",
- &reservation, esxVI_Occurrence_RequiredItem) < 0) {
+ &reservation, esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* Scale from megabytes to kilobytes */
if (virTypedParameterAssign(params, VIR_DOMAIN_MEMORY_MIN_GUARANTEE,
@@ -5116,15 +4851,13 @@ esxConnectListAllDomains(virConnectPtr conn,
/* check system default autostart value */
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART)) {
if (esxVI_LookupAutoStartDefaults(priv->primary,
- &autoStartDefaults) < 0) {
+ &autoStartDefaults) < 0)
goto cleanup;
- }
if (autoStartDefaults->enabled == esxVI_Boolean_True) {
if (esxVI_LookupAutoStartPowerInfoList(priv->primary,
- &powerInfoList) < 0) {
+ &powerInfoList) < 0)
goto cleanup;
- }
}
}
@@ -5136,9 +4869,8 @@ esxConnectListAllDomains(virConnectPtr conn,
if (esxVI_String_AppendValueListToList(&propertyNameList,
"configStatus\0"
"name\0"
- "config.uuid\0") < 0) {
+ "config.uuid\0") < 0)
goto cleanup;
- }
}
needPowerState = MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) ||
@@ -5147,9 +4879,8 @@ esxConnectListAllDomains(virConnectPtr conn,
if (needPowerState) {
if (esxVI_String_AppendValueToList(&propertyNameList,
- "runtime.powerState") < 0) {
+ "runtime.powerState") < 0)
goto cleanup;
- }
}
if (esxVI_LookupVirtualMachineList(priv->primary, propertyNameList,
@@ -5168,16 +4899,14 @@ esxConnectListAllDomains(virConnectPtr conn,
VIR_FREE(name);
if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id,
- &name, uuid) < 0) {
+ &name, uuid) < 0)
goto cleanup;
- }
}
if (needPowerState) {
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
- &powerState) < 0) {
+ &powerState) < 0)
goto cleanup;
- }
}
/* filter by active state */
@@ -5193,9 +4922,8 @@ esxConnectListAllDomains(virConnectPtr conn,
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
if (esxVI_LookupRootSnapshotTreeList(priv->primary, uuid,
- &rootSnapshotTreeList) < 0) {
+ &rootSnapshotTreeList) < 0)
goto cleanup;
- }
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) &&
rootSnapshotTreeList) ||
@@ -5272,9 +5000,8 @@ esxConnectListAllDomains(virConnectPtr conn,
cleanup:
if (doms) {
- for (id = 0; id < count; id++) {
+ for (id = 0; id < count; id++)
virDomainFree(doms[id]);
- }
VIR_FREE(doms);
}
@@ -5382,9 +5109,8 @@ esxRegister(void)
esxStorageRegister() < 0 ||
esxDeviceRegister() < 0 ||
esxSecretRegister() < 0 ||
- esxNWFilterRegister() < 0) {
+ esxNWFilterRegister() < 0)
return -1;
- }
return 0;
}
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index ecc5313..14a2ea1 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -46,9 +46,8 @@ esxInterfaceOpen(virConnectPtr conn,
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->driver->no != VIR_DRV_ESX) {
+ if (conn->driver->no != VIR_DRV_ESX)
return VIR_DRV_OPEN_DECLINED;
- }
conn->interfacePrivateData = conn->privateData;
@@ -76,14 +75,12 @@ esxConnectNumOfInterfaces(virConnectPtr conn)
int count = 0;
if (esxVI_EnsureSession(priv->primary) < 0 ||
- esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) {
+ esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
return -1;
- }
for (physicalNic = physicalNicList; physicalNic;
- physicalNic = physicalNic->_next) {
+ physicalNic = physicalNic->_next)
++count;
- }
esxVI_PhysicalNic_Free(&physicalNicList);
@@ -102,14 +99,12 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int
maxnames)
int count = 0;
size_t i;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
if (esxVI_EnsureSession(priv->primary) < 0 ||
- esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) {
+ esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
return -1;
- }
for (physicalNic = physicalNicList; physicalNic;
physicalNic = physicalNic->_next) {
@@ -123,9 +118,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int
maxnames)
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
@@ -166,9 +160,8 @@ esxInterfaceLookupByName(virConnectPtr conn, const char *name)
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupPhysicalNicByMACAddress(priv->primary, name, &physicalNic,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return NULL;
- }
iface = virGetInterface(conn, physicalNic->device, physicalNic->mac);
@@ -188,9 +181,8 @@ esxInterfaceLookupByMACString(virConnectPtr conn, const char *mac)
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupPhysicalNicByMACAddress(priv->primary, mac, &physicalNic,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return NULL;
- }
iface = virGetInterface(conn, physicalNic->device, physicalNic->mac);
@@ -225,9 +217,8 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupPhysicalNicByMACAddress(priv->primary, iface->mac,
&physicalNic,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return NULL;
- }
def.type = VIR_INTERFACE_TYPE_ETHERNET;
def.name = physicalNic->device;
@@ -238,16 +229,14 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
if (physicalNic->spec->ip) {
protocol.family = (char *)"ipv4";
- if (physicalNic->spec->ip->dhcp == esxVI_Boolean_True) {
+ if (physicalNic->spec->ip->dhcp == esxVI_Boolean_True)
protocol.dhcp = 1;
- }
if (physicalNic->spec->ip->ipAddress &&
physicalNic->spec->ip->subnetMask &&
strlen(physicalNic->spec->ip->ipAddress) > 0 &&
- strlen(physicalNic->spec->ip->subnetMask) > 0) {
+ strlen(physicalNic->spec->ip->subnetMask) > 0)
hasAddress = true;
- }
if (protocol.dhcp || hasAddress) {
protocols = &protocol;
@@ -262,9 +251,8 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
protocol.ips = &ips;
if (virSocketAddrParseIPv4(&socketAddress,
- physicalNic->spec->ip->subnetMask) <
0) {
+ physicalNic->spec->ip->subnetMask) <
0)
goto cleanup;
- }
ip.address = physicalNic->spec->ip->ipAddress;
ip.prefix = virSocketAddrGetNumNetmaskBits(&socketAddress);
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index c6f325c..02d61a6 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -52,9 +52,8 @@ esxNetworkOpen(virConnectPtr conn,
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->driver->no != VIR_DRV_ESX) {
+ if (conn->driver->no != VIR_DRV_ESX)
return VIR_DRV_OPEN_DECLINED;
- }
conn->networkPrivateData = conn->privateData;
@@ -83,14 +82,12 @@ esxConnectNumOfNetworks(virConnectPtr conn)
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupHostVirtualSwitchList(priv->primary,
- &hostVirtualSwitchList) < 0) {
+ &hostVirtualSwitchList) < 0)
return -1;
- }
for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch;
- hostVirtualSwitch = hostVirtualSwitch->_next) {
+ hostVirtualSwitch = hostVirtualSwitch->_next)
++count;
- }
esxVI_HostVirtualSwitch_Free(&hostVirtualSwitchList);
@@ -109,15 +106,13 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int
maxnames)
int count = 0;
size_t i;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupHostVirtualSwitchList(priv->primary,
- &hostVirtualSwitchList) < 0) {
+ &hostVirtualSwitchList) < 0)
return -1;
- }
for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch;
hostVirtualSwitch = hostVirtualSwitch->_next) {
@@ -131,9 +126,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int
maxnames)
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
@@ -177,17 +171,15 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char
*uuid)
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupHostVirtualSwitchList(priv->primary,
- &hostVirtualSwitchList) < 0) {
+ &hostVirtualSwitchList) < 0)
return NULL;
- }
for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch;
hostVirtualSwitch = hostVirtualSwitch->_next) {
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5);
- if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break;
- }
}
if (!hostVirtualSwitch) {
@@ -221,9 +213,8 @@ esxNetworkLookupByName(virConnectPtr conn, const char *name)
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupHostVirtualSwitchByName(priv->primary, name,
&hostVirtualSwitch,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return NULL;
- }
/*
* HostVirtualSwitch doesn't have a UUID, but we can use the key property
@@ -265,38 +256,33 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth,
}
if (bandwidth->in->average == 0 && bandwidth->in->peak == 0
&&
- bandwidth->in->burst == 0) {
+ bandwidth->in->burst == 0)
return 0;
- }
- if (esxVI_HostNetworkTrafficShapingPolicy_Alloc(shapingPolicy) < 0) {
+ if (esxVI_HostNetworkTrafficShapingPolicy_Alloc(shapingPolicy) < 0)
goto cleanup;
- }
(*shapingPolicy)->enabled = esxVI_Boolean_True;
if (bandwidth->in->average > 0) {
- if (esxVI_Long_Alloc(&(*shapingPolicy)->averageBandwidth) < 0) {
+ if (esxVI_Long_Alloc(&(*shapingPolicy)->averageBandwidth) < 0)
goto cleanup;
- }
/* Scale kilobytes per second to bits per second */
(*shapingPolicy)->averageBandwidth->value = bandwidth->in->average *
8 * 1000;
}
if (bandwidth->in->peak > 0) {
- if (esxVI_Long_Alloc(&(*shapingPolicy)->peakBandwidth) < 0) {
+ if (esxVI_Long_Alloc(&(*shapingPolicy)->peakBandwidth) < 0)
goto cleanup;
- }
/* Scale kilobytes per second to bits per second */
(*shapingPolicy)->peakBandwidth->value = bandwidth->in->peak * 8 *
1000;
}
if (bandwidth->in->burst > 0) {
- if (esxVI_Long_Alloc(&(*shapingPolicy)->burstSize) < 0) {
+ if (esxVI_Long_Alloc(&(*shapingPolicy)->burstSize) < 0)
goto cleanup;
- }
/* Scale kilobytes to bytes */
(*shapingPolicy)->burstSize->value = bandwidth->in->burst * 1024;
@@ -305,9 +291,8 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth,
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
esxVI_HostNetworkTrafficShapingPolicy_Free(shapingPolicy);
- }
return result;
}
@@ -332,23 +317,20 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
unsigned char md5[MD5_DIGEST_SIZE]; /* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
/* Parse network XML */
def = virNetworkDefParseString(xml);
- if (!def) {
+ if (!def)
return NULL;
- }
/* Check if an existing HostVirtualSwitch should be edited */
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, def->name,
&hostVirtualSwitch,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (hostVirtualSwitch) {
/* FIXME */
@@ -376,9 +358,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
/* Verify that specified HostPortGroups don't exist already */
if (def->nPortGroups > 0) {
- if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) <
0) {
+ if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) <
0)
goto cleanup;
- }
for (i = 0; i < def->nPortGroups; ++i) {
for (hostPortGroup = hostPortGroupList; hostPortGroup;
@@ -395,23 +376,20 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
/* Create HostVirtualSwitch */
if (esxVI_HostVirtualSwitchSpec_Alloc(&hostVirtualSwitchSpec) < 0 ||
- esxVI_Int_Alloc(&hostVirtualSwitchSpec->numPorts) < 0) {
+ esxVI_Int_Alloc(&hostVirtualSwitchSpec->numPorts) < 0)
goto cleanup;
- }
if (def->forward.type != VIR_NETWORK_FORWARD_NONE && def->forward.nifs
> 0) {
if (esxVI_HostVirtualSwitchBondBridge_Alloc
- (&hostVirtualSwitchBondBridge) < 0) {
+ (&hostVirtualSwitchBondBridge) < 0)
goto cleanup;
- }
hostVirtualSwitchSpec->bridge =
(esxVI_HostVirtualSwitchBridge *)hostVirtualSwitchBondBridge;
/* Lookup PhysicalNic list and match by name to get key */
- if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
{
+ if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
goto cleanup;
- }
for (i = 0; i < def->forward.nifs; ++i) {
bool found = false;
@@ -430,9 +408,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
if (STREQ(def->forward.ifs[i].device.dev, physicalNic->device)) {
if (esxVI_String_AppendValueToList
(&hostVirtualSwitchBondBridge->nicDevice,
- physicalNic->key) < 0) {
+ physicalNic->key) < 0)
goto cleanup;
- }
found = true;
break;
@@ -451,23 +428,20 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
hostVirtualSwitchSpec->numPorts->value = 128;
if (def->bandwidth) {
- if (esxVI_HostNetworkPolicy_Alloc(&hostVirtualSwitchSpec->policy) < 0)
{
+ if (esxVI_HostNetworkPolicy_Alloc(&hostVirtualSwitchSpec->policy) < 0)
goto cleanup;
- }
if (esxBandwidthToShapingPolicy
(def->bandwidth,
- &hostVirtualSwitchSpec->policy->shapingPolicy) < 0) {
+ &hostVirtualSwitchSpec->policy->shapingPolicy) < 0)
goto cleanup;
- }
}
if (esxVI_AddVirtualSwitch
(priv->primary,
priv->primary->hostSystem->configManager->networkSystem,
- def->name, hostVirtualSwitchSpec) < 0) {
+ def->name, hostVirtualSwitchSpec) < 0)
goto cleanup;
- }
/* Create HostPortGroup(s) */
for (i = 0; i < def->nPortGroups; ++i) {
@@ -477,34 +451,30 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
esxVI_HostNetworkPolicy_Alloc(&hostPortGroupSpec->policy) < 0 ||
esxVI_Int_Alloc(&hostPortGroupSpec->vlanId) < 0 ||
VIR_STRDUP(hostPortGroupSpec->name, def->portGroups[i].name) < 0 ||
- VIR_STRDUP(hostPortGroupSpec->vswitchName, def->name) < 0) {
+ VIR_STRDUP(hostPortGroupSpec->vswitchName, def->name) < 0)
goto cleanup;
- }
hostPortGroupSpec->vlanId->value = 0;
if (def->portGroups[i].bandwidth) {
if (esxBandwidthToShapingPolicy
(def->portGroups[i].bandwidth,
- &hostPortGroupSpec->policy->shapingPolicy) < 0) {
+ &hostPortGroupSpec->policy->shapingPolicy) < 0)
goto cleanup;
- }
}
if (esxVI_AddPortGroup
(priv->primary,
priv->primary->hostSystem->configManager->networkSystem,
- hostPortGroupSpec) < 0) {
+ hostPortGroupSpec) < 0)
goto cleanup;
- }
}
/* Lookup created HostVirtualSwitch to get the UUID */
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, def->name,
&hostVirtualSwitch,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5);
@@ -534,17 +504,15 @@ esxNetworkUndefine(virNetworkPtr network)
esxVI_HostPortGroup *hostPortGroup = NULL;
esxVI_HostPortGroupPort *hostPortGroupPort = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* Lookup HostVirtualSwitch and HostPortGroup list*/
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network->name,
&hostVirtualSwitch,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0)
{
+ esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0)
goto cleanup;
- }
/* Verify that the HostVirtualSwitch is connected to virtual machines only */
for (hostPortGroupKey = hostVirtualSwitch->portgroup;
@@ -589,9 +557,8 @@ esxNetworkUndefine(virNetworkPtr network)
if (esxVI_RemovePortGroup
(priv->primary,
priv->primary->hostSystem->configManager->networkSystem,
- hostPortGroup->spec->name) < 0) {
+ hostPortGroup->spec->name) < 0)
goto cleanup;
- }
found = true;
break;
@@ -610,9 +577,8 @@ esxNetworkUndefine(virNetworkPtr network)
if (esxVI_RemoveVirtualSwitch
(priv->primary,
priv->primary->hostSystem->configManager->networkSystem,
- network->name) < 0) {
+ network->name) < 0)
goto cleanup;
- }
result = 0;
@@ -634,9 +600,8 @@ esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy
*shapingPolicy
return -1;
}
- if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True) {
+ if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True)
return 0;
- }
if (VIR_ALLOC(*bandwidth) < 0 ||
VIR_ALLOC((*bandwidth)->in) < 0 ||
@@ -686,9 +651,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
esxVI_String *networkName = NULL;
virNetworkDefPtr def;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (VIR_ALLOC(def) < 0)
goto cleanup;
@@ -696,9 +660,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
/* Lookup HostVirtualSwitch */
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network_->name,
&hostVirtualSwitch,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key),
def->uuid);
@@ -711,9 +674,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
count = 0;
for (physicalNicKey = hostVirtualSwitch->pnic;
- physicalNicKey; physicalNicKey = physicalNicKey->_next) {
+ physicalNicKey; physicalNicKey = physicalNicKey->_next)
++count;
- }
if (count > 0) {
def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
@@ -722,9 +684,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
goto cleanup;
/* Find PhysicalNic by key */
- if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
{
+ if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
goto cleanup;
- }
for (physicalNicKey = hostVirtualSwitch->pnic;
physicalNicKey; physicalNicKey = physicalNicKey->_next) {
@@ -759,9 +720,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
count = 0;
for (hostPortGroupKey = hostVirtualSwitch->portgroup;
- hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next) {
+ hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next)
++count;
- }
if (count > 0) {
if (VIR_ALLOC_N(def->portGroups, count) < 0)
@@ -770,24 +730,21 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
/* Lookup Network list and create name list */
if (esxVI_String_AppendValueToList(&propertyNameList, "name") <
0 ||
esxVI_LookupNetworkList(priv->primary, propertyNameList,
- &networkList) < 0) {
+ &networkList) < 0)
goto cleanup;
- }
for (network = networkList; network; network = network->_next) {
char *tmp = NULL;
if (esxVI_GetStringValue(network, "name", &tmp,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_String_AppendValueToList(&networkNameList, tmp) < 0) {
+ esxVI_String_AppendValueToList(&networkNameList, tmp) < 0)
goto cleanup;
- }
}
/* Find HostPortGroup by key */
- if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) <
0) {
+ if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) <
0)
goto cleanup;
- }
for (hostPortGroupKey = hostVirtualSwitch->portgroup;
hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next) {
@@ -835,9 +792,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
if (hostVirtualSwitch->spec->policy) {
if (esxShapingPolicyToBandwidth
(hostVirtualSwitch->spec->policy->shapingPolicy,
- &def->bandwidth) < 0) {
+ &def->bandwidth) < 0)
goto cleanup;
- }
}
xml = virNetworkDefFormat(def, flags);
diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c
index 3cf70d0..5f0e747 100644
--- a/src/esx/esx_nwfilter_driver.c
+++ b/src/esx/esx_nwfilter_driver.c
@@ -43,9 +43,8 @@ esxNWFilterOpen(virConnectPtr conn,
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->driver->no != VIR_DRV_ESX) {
+ if (conn->driver->no != VIR_DRV_ESX)
return VIR_DRV_OPEN_DECLINED;
- }
conn->nwfilterPrivateData = conn->privateData;
diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c
index 558cf07..745115a 100644
--- a/src/esx/esx_secret_driver.c
+++ b/src/esx/esx_secret_driver.c
@@ -41,9 +41,8 @@ esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth
ATTRIBUTE_UNUSED,
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->driver->no != VIR_DRV_ESX) {
+ if (conn->driver->no != VIR_DRV_ESX)
return VIR_DRV_OPEN_DECLINED;
- }
conn->secretPrivateData = conn->privateData;
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index 41f895d..1b5fc0d 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -79,9 +79,8 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
* return iSCSI names for all static targets to avoid duplicate names.
*/
for (target = hostInternetScsiHba->configuredStaticTarget;
- target; target = target->_next) {
+ target; target = target->_next)
++count;
- }
success = true;
@@ -104,9 +103,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
esxVI_HostInternetScsiHbaStaticTarget *target;
size_t i;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
if (esxVI_LookupHostInternetScsiHba(priv->primary,
&hostInternetScsiHba) < 0) {
@@ -140,9 +138,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
}
esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba);
@@ -168,9 +165,8 @@ esxStoragePoolLookupByName(virConnectPtr conn,
* parameter
*/
if (esxVI_LookupHostInternetScsiHbaStaticTargetByName
- (priv->primary, name, &target, esxVI_Occurrence_OptionalItem) < 0) {
+ (priv->primary, name, &target, esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!target) {
/* pool not found, error handling done by the base driver */
@@ -222,9 +218,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
target; target = target->_next) {
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5);
- if (memcmp(uuid, md5, VIR_UUID_STRING_BUFLEN) == 0) {
+ if (memcmp(uuid, md5, VIR_UUID_STRING_BUFLEN) == 0)
break;
- }
}
if (!target) {
@@ -254,9 +249,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool,
virCheckFlags(0, -1);
if (esxVI_LookupHostInternetScsiHba(priv->primary,
- &hostInternetScsiHba) < 0) {
+ &hostInternetScsiHba) < 0)
goto cleanup;
- }
/*
* ESX does not allow rescan on a particular target,
@@ -264,9 +258,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool,
*/
if (esxVI_RescanHba(priv->primary,
priv->primary->hostSystem->configManager->storageSystem,
- hostInternetScsiHba->device) < 0) {
+ hostInternetScsiHba->device) < 0)
goto cleanup;
- }
result = 0;
@@ -304,15 +297,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int
flags)
memset(&def, 0, sizeof(def));
- if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba)) {
+ if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba))
goto cleanup;
- }
for (target = hostInternetScsiHba->configuredStaticTarget;
target; target = target->_next) {
- if (STREQ(target->iScsiName, pool->name)) {
+ if (STREQ(target->iScsiName, pool->name))
break;
- }
}
if (!target) {
@@ -338,9 +329,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
def.source.hosts[0].name = target->address;
- if (target->port) {
+ if (target->port)
def.source.hosts[0].port = target->port->value;
- }
/* TODO: add CHAP authentication params */
xml = virStoragePoolDefFormat(&def);
@@ -363,15 +353,13 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
esxVI_HostScsiTopologyLun *hostScsiTopologyLun;
if (esxVI_LookupHostScsiTopologyLunListByTargetName
- (priv->primary, pool->name, &hostScsiTopologyLunList) < 0) {
+ (priv->primary, pool->name, &hostScsiTopologyLunList) < 0)
return -1;
- }
for (hostScsiTopologyLun = hostScsiTopologyLunList;
hostScsiTopologyLun;
- hostScsiTopologyLun = hostScsiTopologyLun->_next) {
+ hostScsiTopologyLun = hostScsiTopologyLun->_next)
++count;
- }
esxVI_HostScsiTopologyLun_Free(&hostScsiTopologyLunList);
@@ -394,18 +382,16 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const
names,
size_t i;
if (esxVI_LookupHostScsiTopologyLunListByTargetName
- (priv->primary, pool->name, &hostScsiTopologyLunList) < 0) {
+ (priv->primary, pool->name, &hostScsiTopologyLunList) < 0)
goto cleanup;
- }
if (!hostScsiTopologyLunList) {
/* iSCSI adapter may not be enabled on ESX host */
return 0;
}
- if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) {
+ if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup;
- }
for (scsiLun = scsiLunList; scsiLun && count < maxnames;
scsiLun = scsiLun->_next) {
@@ -425,9 +411,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
@@ -452,9 +437,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
unsigned char md5[MD5_DIGEST_SIZE];
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
- if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) {
+ if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup;
- }
for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) {
@@ -500,9 +484,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
unsigned char md5[MD5_DIGEST_SIZE];
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
- if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) {
+ if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup;
- }
for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) {
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
@@ -513,9 +496,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary,
hostScsiDisk->key,
- &poolName) < 0) {
+ &poolName) < 0)
goto cleanup;
- }
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
virUUIDFormat(md5, uuid_string);
@@ -548,13 +530,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
/* key may be LUN device path */
- if (STRPREFIX(key, "/")) {
+ if (STRPREFIX(key, "/"))
return esxStorageVolLookupByPath(conn, key);
- }
- if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) {
+ if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup;
- }
for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) {
@@ -570,9 +550,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary,
scsiLun->key,
- &poolName) < 0) {
+ &poolName) < 0)
goto cleanup;
- }
volume = virGetStorageVol(conn, poolName, scsiLun->deviceName,
uuid_string, &esxStorageBackendISCSI,
@@ -631,18 +610,16 @@ esxStorageVolGetInfo(virStorageVolPtr volume,
esxVI_ScsiLun *scsiLun;
esxVI_HostScsiDisk *hostScsiDisk = NULL;
- if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) {
+ if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup;
- }
for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) {
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
if (hostScsiDisk &&
- STREQ(hostScsiDisk->deviceName, volume->name)) {
+ STREQ(hostScsiDisk->deviceName, volume->name))
break;
- }
}
if (!hostScsiDisk) {
@@ -687,18 +664,16 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def));
- if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) {
+ if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup;
- }
for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) {
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
if (hostScsiDisk &&
- STREQ(hostScsiDisk->deviceName, volume->name)) {
+ STREQ(hostScsiDisk->deviceName, volume->name))
break;
- }
}
if (!hostScsiDisk) {
@@ -715,9 +690,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
virUUIDFormat(md5, uuid_string);
- if (VIR_STRDUP(def.key, uuid_string) < 0) {
+ if (VIR_STRDUP(def.key, uuid_string) < 0)
goto cleanup;
- }
/* iSCSI LUN exposes a block device */
def.type = VIR_STORAGE_VOL_BLOCK;
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index cf0da84..1d2a1d8 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -67,9 +67,8 @@ esxLookupVMFSStoragePoolType(esxVI_Context *ctx, const char *poolName,
if (esxVI_String_AppendValueToList(&propertyNameList, "info") < 0
||
esxVI_LookupDatastoreByName(ctx, poolName, propertyNameList, &datastore,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!datastore) {
/* Not found, let the base storage driver handle error reporting */
@@ -80,9 +79,8 @@ esxLookupVMFSStoragePoolType(esxVI_Context *ctx, const char *poolName,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "info")) {
if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val,
- &datastoreInfo) < 0) {
+ &datastoreInfo) < 0)
goto cleanup;
- }
break;
}
@@ -120,14 +118,12 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
esxVI_ObjectContent *datastoreList = NULL;
esxVI_ObjectContent *datastore = NULL;
- if (esxVI_LookupDatastoreList(priv->primary, NULL, &datastoreList) < 0) {
+ if (esxVI_LookupDatastoreList(priv->primary, NULL, &datastoreList) < 0)
return -1;
- }
for (datastore = datastoreList; datastore;
- datastore = datastore->_next) {
+ datastore = datastore->_next)
++count;
- }
esxVI_ObjectContent_Free(&datastoreList);
@@ -149,16 +145,14 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
int count = 0;
size_t i;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"summary.name") < 0 ||
esxVI_LookupDatastoreList(priv->primary, propertyNameList,
- &datastoreList) < 0) {
+ &datastoreList) < 0)
goto cleanup;
- }
for (datastore = datastoreList; datastore;
datastore = datastore->_next) {
@@ -166,9 +160,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "summary.name")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ esxVI_Type_String) < 0)
goto cleanup;
- }
if (VIR_STRDUP(names[count], dynamicProperty->val->string) < 0)
goto cleanup;
@@ -185,9 +178,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
@@ -212,9 +204,8 @@ esxStoragePoolLookupByName(virConnectPtr conn,
virStoragePoolPtr pool = NULL;
if (esxVI_LookupDatastoreByName(priv->primary, name, NULL, &datastore,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!datastore) {
/* Not found, let the base storage driver handle error reporting */
@@ -230,9 +221,8 @@ esxStoragePoolLookupByName(virConnectPtr conn,
* considered to be collision-free enough for this use case.
*/
if (esxVI_LookupDatastoreHostMount(priv->primary, datastore->obj,
&hostMount,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!hostMount) {
/* Not found, let the base storage driver handle error reporting */
@@ -270,9 +260,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
if (esxVI_String_AppendValueToList(&propertyNameList, "summary.name")
< 0 ||
esxVI_LookupDatastoreList(priv->primary, propertyNameList,
- &datastoreList) < 0) {
+ &datastoreList) < 0)
goto cleanup;
- }
for (datastore = datastoreList; datastore;
datastore = datastore->_next) {
@@ -280,9 +269,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
if (esxVI_LookupDatastoreHostMount(priv->primary, datastore->obj,
&hostMount,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!hostMount) {
/*
@@ -295,9 +283,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
md5_buffer(hostMount->mountInfo->path,
strlen(hostMount->mountInfo->path), md5);
- if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break;
- }
}
if (!datastore) {
@@ -306,9 +293,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
}
if (esxVI_GetStringValue(datastore, "summary.name", &name,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
pool = virGetStoragePool(conn, name, uuid, &esxStorageBackendVMFS, NULL);
@@ -333,9 +319,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags)
if (esxVI_LookupDatastoreByName(priv->primary, pool->name, NULL,
&datastore,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_RefreshDatastore(priv->primary, datastore->obj) < 0) {
+ esxVI_RefreshDatastore(priv->primary, datastore->obj) < 0)
goto cleanup;
- }
result = 0;
@@ -366,9 +351,8 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool,
propertyNameList, &datastore,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetBoolean(datastore, "summary.accessible",
- &accessible, esxVI_Occurrence_RequiredItem) < 0) {
+ &accessible, esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (accessible == esxVI_Boolean_True) {
info->state = VIR_STORAGE_POOL_RUNNING;
@@ -377,16 +361,14 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "summary.capacity")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
info->capacity = dynamicProperty->val->int64;
} else if (STREQ(dynamicProperty->name, "summary.freeSpace")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
info->available = dynamicProperty->val->int64;
}
@@ -437,9 +419,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
esxVI_GetBoolean(datastore, "summary.accessible",
&accessible, esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_LookupDatastoreHostMount(priv->primary, datastore->obj,
&hostMount,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
def.name = pool->name;
memcpy(def.uuid, pool->uuid, VIR_UUID_BUFLEN);
@@ -451,16 +432,14 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int
flags)
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "summary.capacity")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
def.capacity = dynamicProperty->val->int64;
} else if (STREQ(dynamicProperty->name, "summary.freeSpace")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Long) < 0) {
+ esxVI_Type_Long) < 0)
goto cleanup;
- }
def.available = dynamicProperty->val->int64;
}
@@ -473,9 +452,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "info")) {
if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val,
- &info) < 0) {
+ &info) < 0)
goto cleanup;
- }
break;
}
@@ -538,17 +516,15 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
int count = 0;
if (esxVI_LookupDatastoreContentByDatastoreName(priv->primary, pool->name,
- &searchResultsList) < 0) {
+ &searchResultsList) < 0)
goto cleanup;
- }
/* Interpret search result */
for (searchResults = searchResultsList; searchResults;
searchResults = searchResults->_next) {
for (fileInfo = searchResults->file; fileInfo;
- fileInfo = fileInfo->_next) {
+ fileInfo = fileInfo->_next)
++count;
- }
}
success = true;
@@ -580,14 +556,12 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const
names,
return -1;
}
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
if (esxVI_LookupDatastoreContentByDatastoreName(priv->primary, pool->name,
- &searchResultsList) < 0) {
+ &searchResultsList) < 0)
goto cleanup;
- }
/* Interpret search result */
for (searchResults = searchResultsList; searchResults;
@@ -595,9 +569,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
VIR_FREE(directoryAndFileName);
if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, NULL,
- &directoryAndFileName) < 0) {
+ &directoryAndFileName) < 0)
goto cleanup;
- }
/* Strip trailing separators */
length = strlen(directoryAndFileName);
@@ -614,9 +587,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
if (VIR_STRDUP(names[count], fileInfo->path) < 0)
goto cleanup;
} else if (virAsprintf(&names[count], "%s/%s",
directoryAndFileName,
- fileInfo->path) < 0) {
+ fileInfo->path) < 0)
goto cleanup;
- }
++count;
}
@@ -626,9 +598,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
@@ -654,9 +625,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
goto cleanup;
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary,
- datastorePath, &key) < 0) {
+ datastorePath, &key) < 0)
goto cleanup;
- }
volume = virGetStorageVol(pool->conn, pool->name, name, key,
&esxStorageBackendVMFS, NULL);
@@ -680,14 +650,12 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
char *key = NULL;
if (esxUtil_ParseDatastorePath(path, &datastoreName, NULL,
- &directoryAndFileName) < 0) {
+ &directoryAndFileName) < 0)
goto cleanup;
- }
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, path,
- &key) < 0) {
+ &key) < 0)
goto cleanup;
- }
volume = virGetStorageVol(conn, datastoreName, directoryAndFileName, key,
&esxStorageBackendVMFS, NULL);
@@ -736,26 +704,23 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
/* Lookup all datastores */
if (esxVI_String_AppendValueToList(&propertyNameList, "summary.name")
< 0 ||
esxVI_LookupDatastoreList(priv->primary, propertyNameList,
- &datastoreList) < 0) {
+ &datastoreList) < 0)
goto cleanup;
- }
for (datastore = datastoreList; datastore;
datastore = datastore->_next) {
datastoreName = NULL;
if (esxVI_GetStringValue(datastore, "summary.name",
&datastoreName,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* Lookup datastore content */
esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList);
if (esxVI_LookupDatastoreContentByDatastoreName
- (priv->primary, datastoreName, &searchResultsList) < 0) {
+ (priv->primary, datastoreName, &searchResultsList) < 0)
goto cleanup;
- }
/* Interpret search result */
for (searchResults = searchResultsList; searchResults;
@@ -763,9 +728,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
VIR_FREE(directoryAndFileName);
if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL,
- NULL, &directoryAndFileName) < 0) {
+ NULL, &directoryAndFileName) < 0)
goto cleanup;
- }
/* Strip trailing separators */
length = strlen(directoryAndFileName);
@@ -785,9 +749,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
goto cleanup;
} else if (virAsprintf(&volumeName, "%s/%s",
directoryAndFileName,
- fileInfo->path) < 0) {
+ fileInfo->path) < 0)
goto cleanup;
- }
if (virAsprintf(&datastorePath, "[%s] %s", datastoreName,
volumeName) < 0)
@@ -803,13 +766,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
if (esxVI_QueryVirtualDiskUuid
(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
- &uuid_string) < 0) {
+ &uuid_string) < 0)
goto cleanup;
- }
- if (esxUtil_ReformatUuid(uuid_string, key_candidate) < 0) {
+ if (esxUtil_ReformatUuid(uuid_string, key_candidate) < 0)
goto cleanup;
- }
if (STREQ(key, key_candidate)) {
/* Found matching UUID */
@@ -866,16 +827,14 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
memset(&poolDef, 0, sizeof(poolDef));
if (esxLookupVMFSStoragePoolType(priv->primary, pool->name,
- &poolDef.type) < 0) {
+ &poolDef.type) < 0)
goto cleanup;
- }
/* Parse config */
def = virStorageVolDefParseString(&poolDef, xmldesc);
- if (!def) {
+ if (!def)
goto cleanup;
- }
if (def->type != VIR_STORAGE_VOL_FILE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -908,22 +867,19 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
/* Parse and escape datastore path */
if (esxUtil_ParseDatastorePath(unescapedDatastorePath, NULL,
&unescapedDirectoryName,
- &unescapedDirectoryAndFileName) < 0) {
+ &unescapedDirectoryAndFileName) < 0)
goto cleanup;
- }
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
- if (!directoryName) {
+ if (!directoryName)
goto cleanup;
- }
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
strlen(unescapedDirectoryName) + 1);
- if (!fileName) {
+ if (!fileName)
goto cleanup;
- }
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s",
pool->name,
directoryName) < 0)
@@ -936,23 +892,20 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
/* Create directory, if it doesn't exist yet */
if (esxVI_LookupFileInfoByDatastorePath
(priv->primary, datastorePathWithoutFileName, true, &fileInfo,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!fileInfo) {
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
priv->primary->datacenter->_reference,
- esxVI_Boolean_True) < 0) {
+ esxVI_Boolean_True) < 0)
goto cleanup;
- }
}
/* Create VirtualDisk */
if (esxVI_FileBackedVirtualDiskSpec_Alloc(&virtualDiskSpec) < 0 ||
- esxVI_Long_Alloc(&virtualDiskSpec->capacityKb) < 0) {
+ esxVI_Long_Alloc(&virtualDiskSpec->capacityKb) < 0)
goto cleanup;
- }
/* From the vSphere API documentation about VirtualDiskType ... */
if (def->target.allocation == def->target.capacity) {
@@ -991,9 +944,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
esxVI_Occurrence_None,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1008,18 +960,15 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
- &uuid_string) < 0) {
+ &uuid_string) < 0)
goto cleanup;
- }
- if (esxUtil_ReformatUuid(uuid_string, key) < 0) {
+ if (esxUtil_ReformatUuid(uuid_string, key) < 0)
goto cleanup;
- }
} else {
/* Fall back to the path as key */
- if (VIR_STRDUP(key, datastorePath) < 0) {
+ if (VIR_STRDUP(key, datastorePath) < 0)
goto cleanup;
- }
}
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1088,9 +1037,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
memset(&poolDef, 0, sizeof(poolDef));
if (esxLookupVMFSStoragePoolType(priv->primary, pool->name,
- &poolDef.type) < 0) {
+ &poolDef.type) < 0)
goto cleanup;
- }
if (virAsprintf(&sourceDatastorePath, "[%s] %s",
sourceVolume->pool,
sourceVolume->name) < 0)
@@ -1099,9 +1047,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
/* Parse config */
def = virStorageVolDefParseString(&poolDef, xmldesc);
- if (!def) {
+ if (!def)
goto cleanup;
- }
if (def->type != VIR_STORAGE_VOL_FILE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1134,22 +1081,19 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
/* Parse and escape datastore path */
if (esxUtil_ParseDatastorePath(unescapedDatastorePath, NULL,
&unescapedDirectoryName,
- &unescapedDirectoryAndFileName) < 0) {
+ &unescapedDirectoryAndFileName) < 0)
goto cleanup;
- }
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
- if (!directoryName) {
+ if (!directoryName)
goto cleanup;
- }
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
strlen(unescapedDirectoryName) + 1);
- if (!fileName) {
+ if (!fileName)
goto cleanup;
- }
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s",
pool->name,
directoryName) < 0)
@@ -1162,16 +1106,14 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
/* Create directory, if it doesn't exist yet */
if (esxVI_LookupFileInfoByDatastorePath
(priv->primary, datastorePathWithoutFileName, true, &fileInfo,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!fileInfo) {
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
priv->primary->datacenter->_reference,
- esxVI_Boolean_True) < 0) {
+ esxVI_Boolean_True) < 0)
goto cleanup;
- }
}
/* Copy VirtualDisk */
@@ -1184,9 +1126,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
esxVI_Occurrence_None,
priv->parsedUri->autoAnswer,
&taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not copy volume:
%s"),
@@ -1200,18 +1141,15 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
- &uuid_string) < 0) {
+ &uuid_string) < 0)
goto cleanup;
- }
- if (esxUtil_ReformatUuid(uuid_string, key) < 0) {
+ if (esxUtil_ReformatUuid(uuid_string, key) < 0)
goto cleanup;
- }
} else {
/* Fall back to the path as key */
- if (VIR_STRDUP(key, datastorePath) < 0) {
+ if (VIR_STRDUP(key, datastorePath) < 0)
goto cleanup;
- }
}
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1265,9 +1203,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags)
esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
esxVI_Occurrence_None,
priv->parsedUri->autoAnswer,
- &taskInfoState, &taskInfoErrorMessage) <
0) {
+ &taskInfoState, &taskInfoErrorMessage) <
0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not delete volume:
%s"),
@@ -1308,9 +1245,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags)
esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
esxVI_Occurrence_None,
priv->parsedUri->autoAnswer,
- &taskInfoState, &taskInfoErrorMessage) <
0) {
+ &taskInfoState, &taskInfoErrorMessage) <
0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not wipe volume: %s"),
@@ -1347,9 +1283,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume,
if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath,
false, &fileInfo,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo);
@@ -1395,9 +1330,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
memset(&def, 0, sizeof(def));
if (esxLookupVMFSStoragePoolType(priv->primary, volume->pool,
- &pool.type) < 0) {
+ &pool.type) < 0)
return NULL;
- }
/* Lookup file info */
if (virAsprintf(&datastorePath, "[%s] %s", volume->pool,
volume->name) < 0)
@@ -1405,9 +1339,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath,
false, &fileInfo,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo);
isoImageFileInfo = esxVI_IsoImageFileInfo_DynamicCast(fileInfo);
@@ -1416,9 +1349,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
def.name = volume->name;
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, datastorePath,
- &def.key) < 0) {
+ &def.key) < 0)
goto cleanup;
- }
def.type = VIR_STORAGE_VOL_FILE;
def.target.path = datastorePath;
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index cae53ed..5b3b8c9 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -60,9 +60,8 @@ esxStorageOpen(virConnectPtr conn,
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->driver->no != VIR_DRV_ESX) {
+ if (conn->driver->no != VIR_DRV_ESX)
return VIR_DRV_OPEN_DECLINED;
- }
conn->storagePrivateData = conn->privateData;
@@ -89,16 +88,14 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
size_t i;
int tmp;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
for (i = 0; i < LAST_BACKEND; ++i) {
tmp = backends[i]->connectNumOfStoragePools(conn);
- if (tmp < 0) {
+ if (tmp < 0)
return -1;
- }
count += tmp;
}
@@ -117,20 +114,17 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
int maxnames)
size_t i;
int tmp;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
for (i = 0; i < LAST_BACKEND; ++i) {
tmp = backends[i]->connectListStoragePools(conn, &names[count], maxnames -
count);
- if (tmp < 0) {
+ if (tmp < 0)
goto cleanup;
- }
count += tmp;
}
@@ -139,9 +133,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int
maxnames)
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
@@ -180,16 +173,14 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
virCheckNonNullArgReturn(name, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
for (i = 0; i < LAST_BACKEND; ++i) {
pool = backends[i]->storagePoolLookupByName(conn, name);
- if (pool) {
+ if (pool)
return pool;
- }
}
virReportError(VIR_ERR_NO_STORAGE_POOL,
@@ -208,17 +199,15 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char
*uuid)
virStoragePoolPtr pool;
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
/* invoke backend drive method to search all known pools */
for (i = 0; i < LAST_BACKEND; ++i) {
pool = backends[i]->storagePoolLookupByUUID(conn, uuid);
- if (pool) {
+ if (pool)
return pool;
- }
}
virUUIDFormat(uuid, uuid_string);
@@ -247,9 +236,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags)
virCheckNonNullArgReturn(pool->privateData, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return backend->storagePoolRefresh(pool, flags);
}
@@ -266,9 +254,8 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr
info)
memset(info, 0, sizeof(*info));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return backend->storagePoolGetInfo(pool, info);
}
@@ -283,9 +270,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
virCheckNonNullArgReturn(pool->privateData, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
return backend->storagePoolGetXMLDesc(pool, flags);
}
@@ -330,9 +316,8 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
virCheckNonNullArgReturn(pool->privateData, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return backend->storagePoolNumOfVolumes(pool);
}
@@ -348,9 +333,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
virCheckNonNullArgReturn(pool->privateData, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return backend->storagePoolListVolumes(pool, names, maxnames);
}
@@ -365,9 +349,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, const char *name)
virCheckNonNullArgReturn(pool->privateData, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
return backend->storageVolLookupByName(pool, name);
}
@@ -379,9 +362,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
{
esxPrivate *priv = conn->storagePrivateData;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
/*
* FIXME: calling backends blindly may set unwanted error codes
@@ -412,16 +394,14 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
esxPrivate *priv = conn->storagePrivateData;
size_t i;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
for (i = 0; i < LAST_BACKEND; ++i) {
volume = backends[i]->storageVolLookupByKey(conn, key);
- if (volume) {
+ if (volume)
return volume;
- }
}
virReportError(VIR_ERR_NO_STORAGE_VOL,
@@ -442,9 +422,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc,
virCheckNonNullArgReturn(pool->privateData, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
return backend->storageVolCreateXML(pool, xmldesc, flags);
}
@@ -460,9 +439,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, const char
*xmldesc,
virCheckNonNullArgReturn(pool->privateData, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
return backend->storageVolCreateXMLFrom(pool, xmldesc, sourceVolume, flags);
}
@@ -477,9 +455,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn(volume->privateData, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return backend->storageVolDelete(volume, flags);
}
@@ -494,9 +471,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn(volume->privateData, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return backend->storageVolWipe(volume, flags);
}
@@ -511,9 +487,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr
info)
virCheckNonNullArgReturn(volume->privateData, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return backend->storageVolGetInfo(volume, info);
}
@@ -528,9 +503,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn(volume->privateData, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
return backend->storageVolGetXMLDesc(volume, flags);
}
@@ -545,9 +519,8 @@ esxStorageVolGetPath(virStorageVolPtr volume)
virCheckNonNullArgReturn(volume->privateData, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
return backend->storageVolGetPath(volume);
}
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 9a41241..641a5c8 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -166,9 +166,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
esxUtil_FreeParsedUri(parsedUri);
- }
return result;
}
@@ -179,9 +178,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
void
esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri)
{
- if (!parsedUri || !(*parsedUri)) {
+ if (!parsedUri || !(*parsedUri))
return;
- }
VIR_FREE((*parsedUri)->transport);
VIR_FREE((*parsedUri)->vCenter);
@@ -197,18 +195,16 @@ int
esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id)
{
/* Try to parse an integer from the complete string. */
- if (virStrToLong_i(id_string, NULL, 10, id) == 0) {
+ if (virStrToLong_i(id_string, NULL, 10, id) == 0)
return 0;
- }
/*
* If that fails try to parse an integer from the string tail
* assuming the naming scheme Virtual Center seems to use.
*/
if (STRPREFIX(id_string, "vm-")) {
- if (virStrToLong_i(id_string + 3, NULL, 10, id) == 0) {
+ if (virStrToLong_i(id_string + 3, NULL, 10, id) == 0)
return 0;
- }
}
return -1;
@@ -234,9 +230,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char
**datastoreName,
return -1;
}
- if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0) {
+ if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0)
goto cleanup;
- }
/* Expected format: '[<datastore>] <path>' where <path> is
optional */
if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' ||
@@ -248,9 +243,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char
**datastoreName,
}
if (datastoreName &&
- VIR_STRDUP(*datastoreName, preliminaryDatastoreName) < 0) {
+ VIR_STRDUP(*datastoreName, preliminaryDatastoreName) < 0)
goto cleanup;
- }
preliminaryDirectoryAndFileName = strtok_r(NULL, "", &saveptr);
@@ -262,38 +256,32 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char
**datastoreName,
}
if (directoryAndFileName &&
- VIR_STRDUP(*directoryAndFileName, preliminaryDirectoryAndFileName) < 0) {
+ VIR_STRDUP(*directoryAndFileName, preliminaryDirectoryAndFileName) < 0)
goto cleanup;
- }
if (directoryName) {
/* Split <path> into <directory>/<file> and remove
/<file> */
tmp = strrchr(preliminaryDirectoryAndFileName, '/');
- if (tmp) {
+ if (tmp)
*tmp = '\0';
- }
- if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0) {
+ if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0)
goto cleanup;
- }
}
result = 0;
cleanup:
if (result < 0) {
- if (datastoreName) {
+ if (datastoreName)
VIR_FREE(*datastoreName);
- }
- if (directoryName) {
+ if (directoryName)
VIR_FREE(*directoryName);
- }
- if (directoryAndFileName) {
+ if (directoryAndFileName)
VIR_FREE(*directoryAndFileName);
- }
}
VIR_FREE(copyOfDatastorePath);
@@ -408,20 +396,17 @@ esxUtil_EscapeBase64(const char *string)
virBufferAddChar(&buffer, base64[(c1 >> 2) & 0x3f]);
virBufferAddChar(&buffer, base64[((c1 << 4) + (c2 >> 4))
& 0x3f]);
- if (length > 1) {
+ if (length > 1)
virBufferAddChar(&buffer, base64[((c2 << 2) + (c3 >>
6)) & 0x3f]);
- }
- if (length > 2) {
+ if (length > 2)
virBufferAddChar(&buffer, base64[c3 & 0x3f]);
- }
length -= length > 3 ? 3 : length;
}
- if (*tmp1 != '\0') {
+ if (*tmp1 != '\0')
virBufferAddChar(&buffer, '-');
- }
}
}
@@ -450,9 +435,8 @@ esxUtil_ReplaceSpecialWindowsPathChars(char *string)
--length;
}
- if (*tmp != '\0') {
+ if (*tmp != '\0')
++tmp;
- }
}
}
@@ -472,9 +456,8 @@ esxUtil_EscapeDatastoreItem(const char *string)
escaped1 = virVMXEscapeHexPercent(replaced);
- if (!escaped1) {
+ if (!escaped1)
goto cleanup;
- }
escaped2 = esxUtil_EscapeBase64(escaped1);
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index b00d8e7..4db1dd4 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -98,26 +98,22 @@ ESX_VI__TEMPLATE__FREE(CURL,
if (shared) {
esxVI_SharedCURL_Remove(shared, item);
- if (shared->count == 0) {
+ if (shared->count == 0)
esxVI_SharedCURL_Free(&shared);
- }
}
if (multi) {
esxVI_MultiCURL_Remove(multi, item);
- if (multi->count == 0) {
+ if (multi->count == 0)
esxVI_MultiCURL_Free(&multi);
- }
}
- if (item->handle) {
+ if (item->handle)
curl_easy_cleanup(item->handle);
- }
- if (item->headers) {
+ if (item->headers)
curl_slist_free_all(item->headers);
- }
virMutexDestroy(&item->lock);
})
@@ -129,19 +125,16 @@ esxVI_CURL_ReadString(char *data, size_t size, size_t nmemb, void
*userdata)
size_t available = 0;
size_t requested = size * nmemb;
- if (!content) {
+ if (!content)
return 0;
- }
available = strlen(content);
- if (available == 0) {
+ if (available == 0)
return 0;
- }
- if (requested > available) {
+ if (requested > available)
requested = available;
- }
memcpy(data, content, requested);
@@ -162,9 +155,8 @@ esxVI_CURL_WriteBuffer(char *data, size_t size, size_t nmemb, void
*userdata)
* are meant to download small things such as VMX files, VMDK metadata
* files and SOAP responses.
*/
- if (size * nmemb > INT32_MAX / 2 - virBufferUse(buffer)) {
+ if (size * nmemb > INT32_MAX / 2 - virBufferUse(buffer))
return 0;
- }
virBufferAdd(buffer, data, size * nmemb);
@@ -193,9 +185,8 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type,
* To handle this properly in order to pass the info string to VIR_DEBUG
* a zero terminated copy of the info string has to be allocated.
*/
- if (VIR_ALLOC_N(buffer, size + 1) < 0) {
+ if (VIR_ALLOC_N(buffer, size + 1) < 0)
return 0;
- }
if (!virStrncpy(buffer, info, size, size + 1)) {
VIR_FREE(buffer);
@@ -204,9 +195,8 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type,
switch (type) {
case CURLINFO_TEXT:
- if (size > 0 && buffer[size - 1] == '\n') {
+ if (size > 0 && buffer[size - 1] == '\n')
buffer[size - 1] = '\0';
- }
VIR_DEBUG("CURLINFO_TEXT [[[[%s]]]]", buffer);
break;
@@ -430,9 +420,8 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char
**content,
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
- if (length) {
+ if (length)
*length = virBufferUse(&buffer);
- }
*content = virBufferContentAndReset(&buffer);
@@ -557,13 +546,11 @@ ESX_VI__TEMPLATE__FREE(SharedCURL,
return;
}
- if (item->handle) {
+ if (item->handle)
curl_share_cleanup(item->handle);
- }
- for (i = 0; i < ARRAY_CARDINALITY(item->locks); ++i) {
+ for (i = 0; i < ARRAY_CARDINALITY(item->locks); ++i)
virMutexDestroy(&item->locks[i]);
- }
})
int
@@ -735,9 +722,8 @@ ESX_VI__TEMPLATE__FREE(MultiCURL,
return;
}
- if (item->handle) {
+ if (item->handle)
curl_multi_cleanup(item->handle);
- }
#if ESX_EMULATE_CURL_MULTI_WAIT
VIR_FREE(item->pollfds);
@@ -856,9 +842,8 @@ esxVI_MultiCURL_Wait(esxVI_MultiCURL *multi, int *runningHandles)
curl_multi_timeout(multi->handle, &timeout);
- if (timeout < 0) {
+ if (timeout < 0)
timeout = 1000; /* default to 1 sec timeout */
- }
do {
rc = poll(multi->pollfds, multi->npollfds, timeout);
@@ -980,9 +965,8 @@ ESX_VI__TEMPLATE__ALLOC(Context)
/* esxVI_Context_Free */
ESX_VI__TEMPLATE__FREE(Context,
{
- if (item->sessionLock) {
+ if (item->sessionLock)
virMutexDestroy(item->sessionLock);
- }
esxVI_CURL_Free(&item->curl);
VIR_FREE(item->url);
@@ -1023,9 +1007,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
VIR_STRDUP(ctx->url, url) < 0 ||
VIR_STRDUP(ctx->ipAddress, ipAddress) < 0 ||
VIR_STRDUP(ctx->username, username) < 0 ||
- VIR_STRDUP(ctx->password, password) < 0) {
+ VIR_STRDUP(ctx->password, password) < 0)
return -1;
- }
if (VIR_ALLOC(ctx->sessionLock) < 0)
return -1;
@@ -1036,9 +1019,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
return -1;
}
- if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0) {
+ if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0)
return -1;
- }
if (STREQ(ctx->service->about->apiType, "HostAgent") ||
STREQ(ctx->service->about->apiType, "VirtualCenter")) {
@@ -1142,14 +1124,12 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
ctx->hasQueryVirtualDiskUuid = true;
}
- if (ctx->productVersion & esxVI_ProductVersion_VPX) {
+ if (ctx->productVersion & esxVI_ProductVersion_VPX)
ctx->hasSessionIsActive = true;
- }
if (esxVI_Login(ctx, username, password, NULL, &ctx->session) < 0 ||
- esxVI_BuildSelectSetCollection(ctx) < 0) {
+ esxVI_BuildSelectSetCollection(ctx) < 0)
return -1;
- }
return 0;
}
@@ -1160,9 +1140,8 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx)
/* Lookup Datacenter */
if (esxVI_LookupDatacenter(ctx, NULL, ctx->service->rootFolder, NULL,
&ctx->datacenter,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return -1;
- }
if (VIR_STRDUP(ctx->datacenterPath, ctx->datacenter->name) < 0)
return -1;
@@ -1170,9 +1149,8 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx)
/* Lookup (Cluster)ComputeResource */
if (esxVI_LookupComputeResource(ctx, NULL, ctx->datacenter->hostFolder,
NULL, &ctx->computeResource,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return -1;
- }
if (!ctx->computeResource->resourcePool) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1186,9 +1164,8 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx)
/* Lookup HostSystem */
if (esxVI_LookupHostSystem(ctx, NULL, ctx->computeResource->_reference,
NULL, &ctx->hostSystem,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
return -1;
- }
if (VIR_STRDUP(ctx->hostSystemName, ctx->hostSystem->name) < 0)
return -1;
@@ -1227,30 +1204,26 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const
char *path)
/* Try to lookup item as a folder */
if (esxVI_LookupFolder(ctx, item, root, NULL, &folder,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (folder) {
/* It's a folder, use it as new lookup root */
- if (root != ctx->service->rootFolder) {
+ if (root != ctx->service->rootFolder)
esxVI_ManagedObjectReference_Free(&root);
- }
root = folder->_reference;
folder->_reference = NULL;
} else {
/* Try to lookup item as a datacenter */
if (esxVI_LookupDatacenter(ctx, item, root, NULL, &ctx->datacenter,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
}
/* Build datacenter path */
- if (virBufferUse(&buffer) > 0) {
+ if (virBufferUse(&buffer) > 0)
virBufferAddChar(&buffer, '/');
- }
virBufferAdd(&buffer, item, -1);
@@ -1276,9 +1249,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const
char *path)
goto cleanup;
}
- if (root != ctx->service->rootFolder) {
+ if (root != ctx->service->rootFolder)
esxVI_ManagedObjectReference_Free(&root);
- }
root = ctx->datacenter->hostFolder;
@@ -1287,15 +1259,13 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const
char *path)
/* Try to lookup item as a folder */
if (esxVI_LookupFolder(ctx, item, root, NULL, &folder,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (folder) {
/* It's a folder, use it as new lookup root */
- if (root != ctx->datacenter->hostFolder) {
+ if (root != ctx->datacenter->hostFolder)
esxVI_ManagedObjectReference_Free(&root);
- }
root = folder->_reference;
folder->_reference = NULL;
@@ -1303,15 +1273,13 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const
char *path)
/* Try to lookup item as a compute resource */
if (esxVI_LookupComputeResource(ctx, item, root, NULL,
&ctx->computeResource,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
}
/* Build compute resource path */
- if (virBufferUse(&buffer) > 0) {
+ if (virBufferUse(&buffer) > 0)
virBufferAddChar(&buffer, '/');
- }
virBufferAdd(&buffer, item, -1);
@@ -1363,9 +1331,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const
char *path)
if (esxVI_LookupHostSystem(ctx, ctx->hostSystemName,
ctx->computeResource->_reference, NULL,
&ctx->hostSystem,
- esxVI_Occurrence_OptionalItem) < 0) {
+ esxVI_Occurrence_OptionalItem) < 0)
goto cleanup;
- }
if (!ctx->hostSystem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1376,14 +1343,12 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const
char *path)
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
virBufferFreeAndReset(&buffer);
- }
if (root != ctx->service->rootFolder &&
- (!ctx->datacenter || root != ctx->datacenter->hostFolder)) {
+ (!ctx->datacenter || root != ctx->datacenter->hostFolder))
esxVI_ManagedObjectReference_Free(&root);
- }
VIR_FREE(tmp);
esxVI_Folder_Free(&folder);
@@ -1403,16 +1368,14 @@ esxVI_Context_LookupManagedObjectsByHostSystemIp(esxVI_Context
*ctx,
&managedObjectReference) < 0 ||
esxVI_LookupHostSystem(ctx, NULL, managedObjectReference, NULL,
&ctx->hostSystem,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* Lookup (Cluster)ComputeResource */
if (esxVI_LookupComputeResource(ctx, NULL, ctx->hostSystem->_reference,
NULL, &ctx->computeResource,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (!ctx->computeResource->resourcePool) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1423,9 +1386,8 @@ esxVI_Context_LookupManagedObjectsByHostSystemIp(esxVI_Context
*ctx,
/* Lookup Datacenter */
if (esxVI_LookupDatacenter(ctx, NULL, ctx->computeResource->_reference,
NULL, &ctx->datacenter,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
result = 0;
@@ -1452,9 +1414,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
return -1;
}
- if (esxVI_Response_Alloc(response) < 0) {
+ if (esxVI_Response_Alloc(response) < 0)
return -1;
- }
virMutexLock(&ctx->curl->lock);
@@ -1469,9 +1430,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
virMutexUnlock(&ctx->curl->lock);
- if ((*response)->responseCode < 0) {
+ if ((*response)->responseCode < 0)
goto cleanup;
- }
if (virBufferCheckError(&buffer) < 0)
goto cleanup;
@@ -1483,9 +1443,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
_("(esx execute
response)"),
&xpathContext);
- if (!(*response)->document) {
+ if (!(*response)->document)
goto cleanup;
- }
xmlXPathRegisterNs(xpathContext, BAD_CAST "soapenv",
BAD_CAST
"http://schemas.xmlsoap.org/soap/envelope/");
@@ -1731,9 +1690,8 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration,
*value = 0; /* undefined */
- if (esxVI_String_DeserializeValue(node, &name) < 0) {
+ if (esxVI_String_DeserializeValue(node, &name) < 0)
return -1;
- }
for (i = 0; enumeration->values[i].name; ++i) {
if (STREQ(name, enumeration->values[i].name)) {
@@ -1776,9 +1734,8 @@ esxVI_List_Append(esxVI_List **list, esxVI_List *item)
next = *list;
- while (next->_next) {
+ while (next->_next)
next = next->_next;
- }
next->_next = item;
@@ -1800,9 +1757,8 @@ esxVI_List_DeepCopy(esxVI_List **destList, esxVI_List *srcList,
for (src = srcList; src; src = src->_next) {
if (deepCopyFunc(&dest, src) < 0 ||
- esxVI_List_Append(destList, dest) < 0) {
+ esxVI_List_Append(destList, dest) < 0)
goto failure;
- }
dest = NULL;
}
@@ -1831,9 +1787,8 @@ esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List
**list,
return -1;
}
- if (!anyType) {
+ if (!anyType)
return 0;
- }
if (! STRPREFIX(anyType->other, "ArrayOf")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1854,9 +1809,8 @@ esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List
**list,
if (esxVI_AnyType_Deserialize(childNode, &childAnyType) < 0 ||
castFromAnyTypeFunc(childAnyType, &item) < 0 ||
- esxVI_List_Append(list, item) < 0) {
+ esxVI_List_Append(list, item) < 0)
goto cleanup;
- }
item = NULL;
}
@@ -1886,14 +1840,12 @@ esxVI_List_Serialize(esxVI_List *list, const char *element,
return -1;
}
- if (!list) {
+ if (!list)
return 0;
- }
for (item = list; item; item = item->_next) {
- if (serializeFunc(item, element, output) < 0) {
+ if (serializeFunc(item, element, output) < 0)
return -1;
- }
}
return 0;
@@ -1911,9 +1863,8 @@ esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
return -1;
}
- if (!node) {
+ if (!node)
return 0;
- }
for (; node; node = node->next) {
if (node->type != XML_ELEMENT_NODE) {
@@ -1923,9 +1874,8 @@ esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
}
if (deserializeFunc(node, &item) < 0 ||
- esxVI_List_Append(list, item) < 0) {
+ esxVI_List_Append(list, item) < 0)
goto failure;
- }
item = NULL;
}
@@ -1970,9 +1920,8 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet,
if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0 ||
VIR_STRDUP(traversalSpec->name, name) < 0 ||
VIR_STRDUP(traversalSpec->type, type) < 0 ||
- VIR_STRDUP(traversalSpec->path, path) < 0) {
+ VIR_STRDUP(traversalSpec->path, path) < 0)
goto failure;
- }
traversalSpec->skip = esxVI_Boolean_False;
@@ -1983,9 +1932,8 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet,
if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 ||
VIR_STRDUP(selectionSpec->name, currentSelectSetName) < 0 ||
esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet,
- selectionSpec) < 0) {
+ selectionSpec) < 0)
goto failure;
- }
selectionSpec = NULL;
currentSelectSetName += strlen(currentSelectSetName) + 1;
@@ -1994,9 +1942,8 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet,
if (esxVI_SelectionSpec_AppendToList(selectSet,
esxVI_SelectionSpec_DynamicCast
- (traversalSpec)) < 0) {
+ (traversalSpec)) < 0)
goto failure;
- }
return 0;
@@ -2015,16 +1962,14 @@ esxVI_BuildSelectSetCollection(esxVI_Context *ctx)
/* Folder -> childEntity (ManagedEntity) */
if (esxVI_BuildSelectSet(&ctx->selectSet_folderToChildEntity,
"folderToChildEntity",
- "Folder", "childEntity", NULL) < 0)
{
+ "Folder", "childEntity", NULL) < 0)
return -1;
- }
/* ComputeResource -> host (HostSystem) */
if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToHost,
"computeResourceToHost",
- "ComputeResource", "host", NULL) < 0)
{
+ "ComputeResource", "host", NULL) <
0)
return -1;
- }
/* ComputeResource -> datastore (Datastore) *//*
if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToDatastore,
@@ -2052,45 +1997,39 @@ esxVI_BuildSelectSetCollection(esxVI_Context *ctx)
/* HostSystem -> parent (ComputeResource) */
if (esxVI_BuildSelectSet(&ctx->selectSet_hostSystemToParent,
"hostSystemToParent",
- "HostSystem", "parent", NULL) < 0) {
+ "HostSystem", "parent", NULL) < 0)
return -1;
- }
/* HostSystem -> vm (VirtualMachine) */
if (esxVI_BuildSelectSet(&ctx->selectSet_hostSystemToVm,
"hostSystemToVm",
- "HostSystem", "vm", NULL) < 0) {
+ "HostSystem", "vm", NULL) < 0)
return -1;
- }
/* HostSystem -> datastore (Datastore) */
if (esxVI_BuildSelectSet(&ctx->selectSet_hostSystemToDatastore,
"hostSystemToDatastore",
- "HostSystem", "datastore", NULL) < 0)
{
+ "HostSystem", "datastore", NULL) <
0)
return -1;
- }
/* Folder -> parent (Folder, Datacenter) */
if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToParentToParent,
"managedEntityToParent",
- "ManagedEntity", "parent", NULL) < 0)
{
+ "ManagedEntity", "parent", NULL) <
0)
return -1;
- }
/* ComputeResource -> parent (Folder) */
if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToParentToParent,
"computeResourceToParent",
"ComputeResource", "parent",
- "managedEntityToParent\0") < 0) {
+ "managedEntityToParent\0") < 0)
return -1;
- }
/* Datacenter -> network (Network) */
if (esxVI_BuildSelectSet(&ctx->selectSet_datacenterToNetwork,
"datacenterToNetwork",
- "Datacenter", "network", NULL) < 0)
{
+ "Datacenter", "network", NULL) < 0)
return -1;
- }
return 0;
}
@@ -2125,17 +2064,15 @@ esxVI_EnsureSession(esxVI_Context *ctx)
* connection, and re-login if there isn't.
*/
if (esxVI_SessionIsActive(ctx, ctx->session->key,
- ctx->session->userName, &active) < 0) {
+ ctx->session->userName, &active) < 0)
goto cleanup;
- }
if (active != esxVI_Boolean_True) {
esxVI_UserSession_Free(&ctx->session);
if (esxVI_Login(ctx, ctx->username, ctx->password, NULL,
- &ctx->session) < 0) {
+ &ctx->session) < 0)
goto cleanup;
- }
}
} else {
/*
@@ -2147,17 +2084,15 @@ esxVI_EnsureSession(esxVI_Context *ctx)
esxVI_LookupObjectContentByType(ctx, ctx->service->sessionManager,
"SessionManager",
propertyNameList,
&sessionManager,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = sessionManager->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "currentSession")) {
if (esxVI_UserSession_CastFromAnyType(dynamicProperty->val,
- ¤tSession) < 0) {
+ ¤tSession) < 0)
goto cleanup;
- }
break;
} else {
@@ -2169,9 +2104,8 @@ esxVI_EnsureSession(esxVI_Context *ctx)
esxVI_UserSession_Free(&ctx->session);
if (esxVI_Login(ctx, ctx->username, ctx->password, NULL,
- &ctx->session) < 0) {
+ &ctx->session) < 0)
goto cleanup;
- }
} else if (STRNEQ(ctx->session->key, currentSession->key)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Key of the current session differs from the key at
"
@@ -2214,9 +2148,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
return -1;
}
- if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) {
+ if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0)
return -1;
- }
objectSpec->obj = root;
objectSpec->skip = esxVI_Boolean_False;
@@ -2275,32 +2208,28 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
}
}
- if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) {
+ if (esxVI_PropertySpec_Alloc(&propertySpec) < 0)
goto cleanup;
- }
propertySpec->type = (char *)type;
propertySpec->pathSet = propertyNameList;
if (esxVI_PropertyFilterSpec_Alloc(&propertyFilterSpec) < 0 ||
esxVI_PropertySpec_AppendToList(&propertyFilterSpec->propSet,
- propertySpec) < 0) {
+ propertySpec) < 0)
goto cleanup;
- }
propertySpec_isAppended = true;
if (esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet,
- objectSpec) < 0) {
+ objectSpec) < 0)
goto cleanup;
- }
objectSpec_isAppended = true;
if (esxVI_RetrieveProperties(ctx, propertyFilterSpec,
- objectContentList) < 0) {
+ objectContentList) < 0)
goto cleanup;
- }
if (!(*objectContentList)) {
switch (occurrence) {
@@ -2346,13 +2275,11 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
propertySpec->pathSet = NULL;
}
- if (!objectSpec_isAppended) {
+ if (!objectSpec_isAppended)
esxVI_ObjectSpec_Free(&objectSpec);
- }
- if (!propertySpec_isAppended) {
+ if (!propertySpec_isAppended)
esxVI_PropertySpec_Free(&propertySpec);
- }
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
@@ -2423,9 +2350,8 @@ esxVI_GetVirtualMachineQuestionInfo
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.question")) {
if (esxVI_VirtualMachineQuestionInfo_CastFromAnyType
- (dynamicProperty->val, questionInfo) < 0) {
+ (dynamicProperty->val, questionInfo) < 0)
return -1;
- }
}
}
@@ -2449,9 +2375,8 @@ esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char
*propertyName,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Boolean) < 0) {
+ esxVI_Type_Boolean) < 0)
return -1;
- }
*value = dynamicProperty->val->boolean;
break;
@@ -2484,9 +2409,8 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, const char
*propertyName,
for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
- if (esxVI_Long_CastFromAnyType(dynamicProperty->val, value) < 0) {
+ if (esxVI_Long_CastFromAnyType(dynamicProperty->val, value) < 0)
return -1;
- }
break;
}
@@ -2519,9 +2443,8 @@ esxVI_GetStringValue(esxVI_ObjectContent *objectContent,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ esxVI_Type_String) < 0)
return -1;
- }
*value = dynamicProperty->val->string;
break;
@@ -2556,9 +2479,8 @@ esxVI_GetManagedObjectReference(esxVI_ObjectContent *objectContent,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, value) < 0) {
+ (dynamicProperty->val, value) < 0)
return -1;
- }
break;
}
@@ -2591,9 +2513,8 @@ esxVI_LookupNumberOfDomainsByPowerState(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineList(ctx, propertyNameList,
- &virtualMachineList) < 0) {
+ &virtualMachineList) < 0)
goto cleanup;
- }
for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
@@ -2602,14 +2523,12 @@ esxVI_LookupNumberOfDomainsByPowerState(esxVI_Context *ctx,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.powerState")) {
if (esxVI_VirtualMachinePowerState_CastFromAnyType
- (dynamicProperty->val, &powerState_) < 0) {
+ (dynamicProperty->val, &powerState_) < 0)
goto cleanup;
- }
if ((!inverse && powerState_ == powerState) ||
- (inverse && powerState_ != powerState)) {
+ (inverse && powerState_ != powerState))
count++;
- }
} else {
VIR_WARN("Unexpected '%s' property",
dynamicProperty->name);
}
@@ -2662,9 +2581,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent
*virtualMachine,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "name")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ esxVI_Type_String) < 0)
goto failure;
- }
if (VIR_STRDUP(*name, dynamicProperty->val->string) < 0)
goto failure;
@@ -2688,9 +2606,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent
*virtualMachine,
if (uuid) {
if (esxVI_GetManagedEntityStatus(virtualMachine, "configStatus",
- &configStatus) < 0) {
+ &configStatus) < 0)
goto failure;
- }
if (configStatus == esxVI_ManagedEntityStatus_Green) {
for (dynamicProperty = virtualMachine->propSet;
@@ -2698,9 +2615,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent
*virtualMachine,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.uuid")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ esxVI_Type_String) < 0)
goto failure;
- }
uuid_string = dynamicProperty->val->string;
break;
@@ -2730,9 +2646,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent
*virtualMachine,
return 0;
failure:
- if (name) {
+ if (name)
VIR_FREE(*name);
- }
return -1;
}
@@ -2781,9 +2696,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree
*snapshotTreeList,
count++;
}
- if (count >= nameslen) {
+ if (count >= nameslen)
break;
- }
if (recurse) {
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
@@ -2791,9 +2705,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree
*snapshotTreeList,
nameslen - count,
true, leaves);
- if (result < 0) {
+ if (result < 0)
goto failure;
- }
count += result;
}
@@ -2802,9 +2715,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree
*snapshotTreeList,
return count;
failure:
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
return -1;
}
@@ -2838,9 +2750,8 @@ esxVI_GetSnapshotTreeByName
if (esxVI_GetSnapshotTreeByName(candidate->childSnapshotList, name,
snapshotTree, snapshotTreeParent,
occurrence) > 0) {
- if (snapshotTreeParent && !(*snapshotTreeParent)) {
+ if (snapshotTreeParent && !(*snapshotTreeParent))
*snapshotTreeParent = candidate;
- }
return 1;
}
@@ -2879,9 +2790,8 @@ esxVI_GetSnapshotTreeBySnapshot
}
if (esxVI_GetSnapshotTreeBySnapshot(candidate->childSnapshotList,
- snapshot, snapshotTree) >= 0) {
+ snapshot, snapshotTree) >= 0)
return 0;
- }
}
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
@@ -2940,9 +2850,8 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned
char *uuid,
if (esxVI_FindByUuid(ctx, ctx->datacenter->_reference, uuid_string,
esxVI_Boolean_True, esxVI_Boolean_Undefined,
- &managedObjectReference) < 0) {
+ &managedObjectReference) < 0)
return -1;
- }
if (!managedObjectReference) {
if (occurrence == esxVI_Occurrence_OptionalItem) {
@@ -2960,9 +2869,8 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned
char *uuid,
if (esxVI_LookupObjectContentByType(ctx, managedObjectReference,
"VirtualMachine", propertyNameList,
virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
result = 0;
@@ -2995,26 +2903,22 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, const char
*name,
propertyNameList) < 0 ||
esxVI_String_AppendValueToList(&completePropertyNameList, "name")
< 0 ||
esxVI_LookupVirtualMachineList(ctx, completePropertyNameList,
- &virtualMachineList) < 0) {
+ &virtualMachineList) < 0)
goto cleanup;
- }
for (candidate = virtualMachineList; candidate;
candidate = candidate->_next) {
VIR_FREE(name_candidate);
if (esxVI_GetVirtualMachineIdentity(candidate, NULL, &name_candidate,
- NULL) < 0) {
+ NULL) < 0)
goto cleanup;
- }
- if (STRNEQ(name, name_candidate)) {
+ if (STRNEQ(name, name_candidate))
continue;
- }
- if (esxVI_ObjectContent_DeepCopy(virtualMachine, candidate) < 0) {
+ if (esxVI_ObjectContent_DeepCopy(virtualMachine, candidate) < 0)
goto cleanup;
- }
break;
}
@@ -3066,16 +2970,14 @@ esxVI_LookupVirtualMachineByUuidAndPrepareForTask
esxVI_GetVirtualMachineQuestionInfo(*virtualMachine,
&questionInfo) < 0 ||
esxVI_LookupPendingTaskInfoListByVirtualMachine
- (ctx, *virtualMachine, &pendingTaskInfoList) < 0) {
+ (ctx, *virtualMachine, &pendingTaskInfoList) < 0)
goto cleanup;
- }
if (questionInfo &&
esxVI_HandleVirtualMachineQuestion(ctx, (*virtualMachine)->obj,
questionInfo, autoAnswer,
- &blocked) < 0) {
+ &blocked) < 0)
goto cleanup;
- }
if (pendingTaskInfoList) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -3132,9 +3034,8 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name,
esxVI_String_AppendValueToList(&completePropertyNameList,
"summary.name") < 0 ||
esxVI_LookupDatastoreList(ctx, completePropertyNameList,
- &datastoreList) < 0) {
+ &datastoreList) < 0)
goto cleanup;
- }
/* Search for a matching datastore */
for (candidate = datastoreList; candidate;
@@ -3142,14 +3043,12 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name,
name_candidate = NULL;
if (esxVI_GetStringValue(candidate, "summary.name",
&name_candidate,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (STREQ(name_candidate, name)) {
- if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) {
+ if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0)
goto cleanup;
- }
/* Found datastore with matching name */
result = 0;
@@ -3199,9 +3098,8 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
propertyNameList) < 0 ||
esxVI_String_AppendValueToList(&completePropertyNameList, "host")
< 0 ||
esxVI_LookupDatastoreList(ctx, completePropertyNameList,
- &datastoreList) < 0) {
+ &datastoreList) < 0)
goto cleanup;
- }
/* Search for a matching datastore */
for (candidate = datastoreList; candidate;
@@ -3212,30 +3110,26 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "host")) {
if (esxVI_DatastoreHostMount_CastListFromAnyType
- (dynamicProperty->val, &datastoreHostMountList) < 0) {
+ (dynamicProperty->val, &datastoreHostMountList) < 0)
goto cleanup;
- }
break;
}
}
- if (!datastoreHostMountList) {
+ if (!datastoreHostMountList)
continue;
- }
for (datastoreHostMount = datastoreHostMountList;
datastoreHostMount;
datastoreHostMount = datastoreHostMount->_next) {
if (STRNEQ(ctx->hostSystem->_reference->value,
- datastoreHostMount->key->value)) {
+ datastoreHostMount->key->value))
continue;
- }
if (STRPREFIX(absolutePath, datastoreHostMount->mountInfo->path)) {
- if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) {
+ if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0)
goto cleanup;
- }
/* Found datastore with matching mount path */
result = 0;
@@ -3285,17 +3179,15 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(&propertyNameList, "host") < 0
||
esxVI_LookupObjectContentByType(ctx, datastore, "Datastore",
propertyNameList, &objectContent,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "host")) {
if (esxVI_DatastoreHostMount_CastListFromAnyType
- (dynamicProperty->val, &hostMountList) < 0) {
+ (dynamicProperty->val, &hostMountList) < 0)
goto cleanup;
- }
break;
} else {
@@ -3305,13 +3197,11 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx,
for (candidate = hostMountList; candidate;
candidate = candidate->_next) {
- if (STRNEQ(ctx->hostSystem->_reference->value,
candidate->key->value)) {
+ if (STRNEQ(ctx->hostSystem->_reference->value,
candidate->key->value))
continue;
- }
- if (esxVI_DatastoreHostMount_DeepCopy(hostMount, candidate) < 0) {
+ if (esxVI_DatastoreHostMount_DeepCopy(hostMount, candidate) < 0)
goto cleanup;
- }
break;
}
@@ -3351,17 +3241,15 @@ esxVI_LookupTaskInfoByTask(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(&propertyNameList, "info") < 0
||
esxVI_LookupObjectContentByType(ctx, task, "Task", propertyNameList,
&objectContent,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "info")) {
if (esxVI_TaskInfo_CastFromAnyType(dynamicProperty->val,
- taskInfo) < 0) {
+ taskInfo) < 0)
goto cleanup;
- }
break;
} else {
@@ -3402,9 +3290,8 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "recentTask")) {
if (esxVI_ManagedObjectReference_CastListFromAnyType
- (dynamicProperty->val, &recentTaskList) < 0) {
+ (dynamicProperty->val, &recentTaskList) < 0)
goto cleanup;
- }
break;
}
@@ -3413,16 +3300,14 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine
/* Lookup task info for each task */
for (recentTask = recentTaskList; recentTask;
recentTask = recentTask->_next) {
- if (esxVI_LookupTaskInfoByTask(ctx, recentTask, &taskInfo) < 0) {
+ if (esxVI_LookupTaskInfoByTask(ctx, recentTask, &taskInfo) < 0)
goto cleanup;
- }
if (taskInfo->state == esxVI_TaskInfoState_Queued ||
taskInfo->state == esxVI_TaskInfoState_Running) {
if (esxVI_TaskInfo_AppendToList(pendingTaskInfoList,
- taskInfo) < 0) {
+ taskInfo) < 0)
goto cleanup;
- }
taskInfo = NULL;
} else {
@@ -3433,9 +3318,8 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
esxVI_TaskInfo_Free(pendingTaskInfoList);
- }
esxVI_String_Free(&propertyNameList);
esxVI_ManagedObjectReference_Free(&recentTaskList);
@@ -3460,22 +3344,19 @@ esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.question") < 0 ||
esxVI_LookupVirtualMachineByUuid(ctx, uuid, propertyNameList,
- &virtualMachine, occurrence) < 0) {
+ &virtualMachine, occurrence) < 0)
goto cleanup;
- }
if (virtualMachine) {
if (esxVI_GetVirtualMachineQuestionInfo(virtualMachine,
- &questionInfo) < 0) {
+ &questionInfo) < 0)
goto cleanup;
- }
if (questionInfo &&
esxVI_HandleVirtualMachineQuestion(ctx, virtualMachine->obj,
questionInfo, autoAnswer,
- blocked) < 0) {
+ blocked) < 0)
goto cleanup;
- }
}
result = 0;
@@ -3509,17 +3390,15 @@ esxVI_LookupRootSnapshotTreeList
"snapshot.rootSnapshotList") < 0 ||
esxVI_LookupVirtualMachineByUuid(ctx, virtualMachineUuid,
propertyNameList, &virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "snapshot.rootSnapshotList")) {
if (esxVI_VirtualMachineSnapshotTree_CastListFromAnyType
- (dynamicProperty->val, rootSnapshotTreeList) < 0) {
+ (dynamicProperty->val, rootSnapshotTreeList) < 0)
goto cleanup;
- }
break;
} else {
@@ -3530,9 +3409,8 @@ esxVI_LookupRootSnapshotTreeList
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
esxVI_VirtualMachineSnapshotTree_Free(rootSnapshotTreeList);
- }
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachine);
@@ -3566,22 +3444,19 @@ esxVI_LookupCurrentSnapshotTree
"snapshot.rootSnapshotList\0") <
0 ||
esxVI_LookupVirtualMachineByUuid(ctx, virtualMachineUuid,
propertyNameList, &virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "snapshot.currentSnapshot")) {
if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, ¤tSnapshot) < 0) {
+ (dynamicProperty->val, ¤tSnapshot) < 0)
goto cleanup;
- }
} else if (STREQ(dynamicProperty->name,
"snapshot.rootSnapshotList")) {
if (esxVI_VirtualMachineSnapshotTree_CastListFromAnyType
- (dynamicProperty->val, &rootSnapshotTreeList) < 0) {
+ (dynamicProperty->val, &rootSnapshotTreeList) < 0)
goto cleanup;
- }
} else {
VIR_WARN("Unexpected '%s' property",
dynamicProperty->name);
}
@@ -3608,9 +3483,8 @@ esxVI_LookupCurrentSnapshotTree
if (esxVI_GetSnapshotTreeBySnapshot(rootSnapshotTreeList, currentSnapshot,
&snapshotTree) < 0 ||
esxVI_VirtualMachineSnapshotTree_DeepCopy(currentSnapshotTree,
- snapshotTree) < 0) {
+ snapshotTree) < 0)
goto cleanup;
- }
result = 0;
@@ -3659,9 +3533,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
}
if (esxUtil_ParseDatastorePath(datastorePath, &datastoreName,
- &directoryName, &directoryAndFileName) < 0)
{
+ &directoryName, &directoryAndFileName) <
0)
goto cleanup;
- }
if (STREQ(directoryName, directoryAndFileName)) {
/*
@@ -3672,9 +3545,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
datastoreName) < 0)
goto cleanup;
- if (VIR_STRDUP(fileName, directoryAndFileName) < 0) {
+ if (VIR_STRDUP(fileName, directoryAndFileName) < 0)
goto cleanup;
- }
} else {
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s",
datastoreName, directoryName) < 0)
@@ -3690,9 +3562,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
goto cleanup;
}
- if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0) {
+ if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0)
goto cleanup;
- }
}
/* Lookup HostDatastoreBrowser */
@@ -3702,15 +3573,13 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetManagedObjectReference(datastore, "browser",
&hostDatastoreBrowser,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* Build HostDatastoreBrowserSearchSpec */
if (esxVI_HostDatastoreBrowserSearchSpec_Alloc(&searchSpec) < 0 ||
- esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0) {
+ esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0)
goto cleanup;
- }
searchSpec->details->fileType = esxVI_Boolean_True;
searchSpec->details->fileSize = esxVI_Boolean_True;
@@ -3720,18 +3589,16 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
if (esxVI_FolderFileQuery_Alloc(&folderFileQuery) < 0 ||
esxVI_FileQuery_AppendToList
(&searchSpec->query,
- esxVI_FileQuery_DynamicCast(folderFileQuery)) < 0) {
+ esxVI_FileQuery_DynamicCast(folderFileQuery)) < 0)
goto cleanup;
- }
folderFileQuery = NULL;
} else {
if (esxVI_VmDiskFileQuery_Alloc(&vmDiskFileQuery) < 0 ||
esxVI_VmDiskFileQueryFlags_Alloc(&vmDiskFileQuery->details) < 0 ||
esxVI_FileQuery_AppendToList
(&searchSpec->query,
- esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0) {
+ esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0)
goto cleanup;
- }
vmDiskFileQuery->details->diskType = esxVI_Boolean_False;
vmDiskFileQuery->details->capacityKb = esxVI_Boolean_True;
@@ -3743,23 +3610,20 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
if (esxVI_IsoImageFileQuery_Alloc(&isoImageFileQuery) < 0 ||
esxVI_FileQuery_AppendToList
(&searchSpec->query,
- esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0) {
+ esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0)
goto cleanup;
- }
isoImageFileQuery = NULL;
if (esxVI_FloppyImageFileQuery_Alloc(&floppyImageFileQuery) < 0 ||
esxVI_FileQuery_AppendToList
(&searchSpec->query,
- esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0) {
+ esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0)
goto cleanup;
- }
floppyImageFileQuery = NULL;
}
- if (esxVI_String_Alloc(&searchSpec->matchPattern) < 0) {
+ if (esxVI_String_Alloc(&searchSpec->matchPattern) < 0)
goto cleanup;
- }
searchSpec->matchPattern->value = fileName;
@@ -3769,9 +3633,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
&task) < 0 ||
esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Occurrence_None,
false, &taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3782,9 +3645,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo) < 0 ||
esxVI_HostDatastoreBrowserSearchResults_CastFromAnyType
- (taskInfo->result, &searchResults) < 0) {
+ (taskInfo->result, &searchResults) < 0)
goto cleanup;
- }
/* Interpret search result */
if (!searchResults->file) {
@@ -3807,9 +3669,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
cleanup:
/* Don't double free fileName */
- if (searchSpec && searchSpec->matchPattern) {
+ if (searchSpec && searchSpec->matchPattern)
searchSpec->matchPattern->value = NULL;
- }
VIR_FREE(datastoreName);
VIR_FREE(directoryName);
@@ -3865,15 +3726,13 @@ esxVI_LookupDatastoreContentByDatastoreName
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetManagedObjectReference(datastore, "browser",
&hostDatastoreBrowser,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
/* Build HostDatastoreBrowserSearchSpec */
if (esxVI_HostDatastoreBrowserSearchSpec_Alloc(&searchSpec) < 0 ||
- esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0) {
+ esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0)
goto cleanup;
- }
searchSpec->details->fileType = esxVI_Boolean_True;
searchSpec->details->fileSize = esxVI_Boolean_True;
@@ -3883,9 +3742,8 @@ esxVI_LookupDatastoreContentByDatastoreName
esxVI_VmDiskFileQueryFlags_Alloc(&vmDiskFileQuery->details) < 0 ||
esxVI_FileQuery_AppendToList
(&searchSpec->query,
- esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0) {
+ esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0)
goto cleanup;
- }
vmDiskFileQuery->details->diskType = esxVI_Boolean_False;
vmDiskFileQuery->details->capacityKb = esxVI_Boolean_True;
@@ -3897,17 +3755,15 @@ esxVI_LookupDatastoreContentByDatastoreName
if (esxVI_IsoImageFileQuery_Alloc(&isoImageFileQuery) < 0 ||
esxVI_FileQuery_AppendToList
(&searchSpec->query,
- esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0) {
+ esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0)
goto cleanup;
- }
isoImageFileQuery = NULL;
if (esxVI_FloppyImageFileQuery_Alloc(&floppyImageFileQuery) < 0 ||
esxVI_FileQuery_AppendToList
(&searchSpec->query,
- esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0) {
+ esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0)
goto cleanup;
- }
floppyImageFileQuery = NULL;
/* Search datastore for files */
@@ -3919,9 +3775,8 @@ esxVI_LookupDatastoreContentByDatastoreName
&task) < 0 ||
esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Occurrence_None,
false, &taskInfoState,
- &taskInfoErrorMessage) < 0) {
+ &taskInfoErrorMessage) < 0)
goto cleanup;
- }
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3932,9 +3787,8 @@ esxVI_LookupDatastoreContentByDatastoreName
if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo) < 0 ||
esxVI_HostDatastoreBrowserSearchResults_CastListFromAnyType
- (taskInfo->result, searchResultsList) < 0) {
+ (taskInfo->result, searchResultsList) < 0)
goto cleanup;
- }
result = 0;
@@ -3973,32 +3827,28 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx,
if (ctx->hasQueryVirtualDiskUuid) {
if (esxVI_LookupFileInfoByDatastorePath
(ctx, datastorePath, false, &fileInfo,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (esxVI_VmDiskFileInfo_DynamicCast(fileInfo)) {
/* VirtualDisks have a UUID, use it as key */
if (esxVI_QueryVirtualDiskUuid(ctx, datastorePath,
ctx->datacenter->_reference,
- &uuid_string) < 0) {
+ &uuid_string) < 0)
goto cleanup;
- }
if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0)
goto cleanup;
- if (esxUtil_ReformatUuid(uuid_string, *key) < 0) {
+ if (esxUtil_ReformatUuid(uuid_string, *key) < 0)
goto cleanup;
- }
}
}
if (!(*key)) {
/* Other files don't have a UUID, fall back to the path as key */
- if (VIR_STRDUP(*key, datastorePath) < 0) {
+ if (VIR_STRDUP(*key, datastorePath) < 0)
goto cleanup;
- }
}
result = 0;
@@ -4036,17 +3886,15 @@ esxVI_LookupAutoStartDefaults(esxVI_Context *ctx,
esxVI_LookupObjectContentByType
(ctx, ctx->hostSystem->configManager->autoStartManager,
"HostAutoStartManager", propertyNameList,
- &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0) {
+ &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostAutoStartManager->propSet;
dynamicProperty; dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.defaults")) {
if (esxVI_AutoStartDefaults_CastFromAnyType(dynamicProperty->val,
- defaults) < 0) {
+ defaults) < 0)
goto cleanup;
- }
break;
}
@@ -4093,17 +3941,15 @@ esxVI_LookupAutoStartPowerInfoList(esxVI_Context *ctx,
esxVI_LookupObjectContentByType
(ctx, ctx->hostSystem->configManager->autoStartManager,
"HostAutoStartManager", propertyNameList,
- &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0) {
+ &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostAutoStartManager->propSet;
dynamicProperty; dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.powerInfo")) {
if (esxVI_AutoStartPowerInfo_CastListFromAnyType
- (dynamicProperty->val, powerInfoList) < 0) {
+ (dynamicProperty->val, powerInfoList) < 0)
goto cleanup;
- }
break;
}
@@ -4137,17 +3983,15 @@ esxVI_LookupPhysicalNicList(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.network.pnic") < 0 ||
esxVI_LookupHostSystemProperties(ctx, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.network.pnic")) {
if (esxVI_PhysicalNic_CastListFromAnyType(dynamicProperty->val,
- physicalNicList) < 0) {
+ physicalNicList) < 0)
goto cleanup;
- }
} else {
VIR_WARN("Unexpected '%s' property",
dynamicProperty->name);
}
@@ -4178,17 +4022,15 @@ esxVI_LookupPhysicalNicByName(esxVI_Context *ctx, const char
*name,
return -1;
}
- if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) {
+ if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0)
goto cleanup;
- }
/* Search for a matching physical NIC */
for (candidate = physicalNicList; candidate;
candidate = candidate->_next) {
if (STRCASEEQ(candidate->device, name)) {
- if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) {
+ if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0)
goto cleanup;
- }
/* Found physical NIC with matching name */
result = 0;
@@ -4227,17 +4069,15 @@ esxVI_LookupPhysicalNicByMACAddress(esxVI_Context *ctx, const char
*mac,
return -1;
}
- if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) {
+ if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0)
goto cleanup;
- }
/* Search for a matching physical NIC */
for (candidate = physicalNicList; candidate;
candidate = candidate->_next) {
if (STRCASEEQ(candidate->mac, mac)) {
- if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) {
+ if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0)
goto cleanup;
- }
/* Found physical NIC with matching MAC address */
result = 0;
@@ -4279,17 +4119,15 @@ esxVI_LookupHostVirtualSwitchList(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.network.vswitch") < 0 ||
esxVI_LookupHostSystemProperties(ctx, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.network.vswitch")) {
if (esxVI_HostVirtualSwitch_CastListFromAnyType
- (dynamicProperty->val, hostVirtualSwitchList) < 0) {
+ (dynamicProperty->val, hostVirtualSwitchList) < 0)
goto cleanup;
- }
} else {
VIR_WARN("Unexpected '%s' property",
dynamicProperty->name);
}
@@ -4320,18 +4158,16 @@ esxVI_LookupHostVirtualSwitchByName(esxVI_Context *ctx, const char
*name,
return -1;
}
- if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0) {
+ if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0)
goto cleanup;
- }
/* Search for a matching HostVirtualSwitch */
for (candidate = hostVirtualSwitchList; candidate;
candidate = candidate->_next) {
if (STREQ(candidate->name, name)) {
if (esxVI_HostVirtualSwitch_DeepCopy(hostVirtualSwitch,
- candidate) < 0) {
+ candidate) < 0)
goto cleanup;
- }
/* Found HostVirtualSwitch with matching name */
result = 0;
@@ -4375,17 +4211,15 @@ esxVI_LookupHostPortGroupList(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.network.portgroup") < 0 ||
esxVI_LookupHostSystemProperties(ctx, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.network.portgroup")) {
if (esxVI_HostPortGroup_CastListFromAnyType
- (dynamicProperty->val, hostPortGroupList) < 0) {
+ (dynamicProperty->val, hostPortGroupList) < 0)
goto cleanup;
- }
break;
} else {
@@ -4442,15 +4276,13 @@ esxVI_HandleVirtualMachineQuestion
elementDescription = elementDescription->_next) {
virBufferAsprintf(&buffer, "'%s'",
elementDescription->label);
- if (elementDescription->_next) {
+ if (elementDescription->_next)
virBufferAddLit(&buffer, ", ");
- }
if (!answerChoice &&
questionInfo->choice->defaultIndex &&
- questionInfo->choice->defaultIndex->value == answerIndex) {
+ questionInfo->choice->defaultIndex->value == answerIndex)
answerChoice = elementDescription;
- }
++answerIndex;
}
@@ -4487,9 +4319,8 @@ esxVI_HandleVirtualMachineQuestion
possibleAnswers, answerChoice->label);
if (esxVI_AnswerVM(ctx, virtualMachine, questionInfo->id,
- answerChoice->key) < 0) {
+ answerChoice->key) < 0)
goto cleanup;
- }
} else {
if (possibleAnswers) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4510,9 +4341,8 @@ esxVI_HandleVirtualMachineQuestion
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
virBufferFreeAndReset(&buffer);
- }
VIR_FREE(possibleAnswers);
@@ -4554,16 +4384,14 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
if (VIR_STRDUP(version, "") < 0)
return -1;
- if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) {
+ if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0)
goto cleanup;
- }
objectSpec->obj = task;
objectSpec->skip = esxVI_Boolean_False;
- if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) {
+ if (esxVI_PropertySpec_Alloc(&propertySpec) < 0)
goto cleanup;
- }
propertySpec->type = task->type;
@@ -4571,23 +4399,20 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
"info.state") < 0 ||
esxVI_PropertyFilterSpec_Alloc(&propertyFilterSpec) < 0 ||
esxVI_PropertySpec_AppendToList(&propertyFilterSpec->propSet,
- propertySpec) < 0) {
+ propertySpec) < 0)
goto cleanup;
- }
propertySpec_isAppended = true;
if (esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet,
- objectSpec) < 0) {
+ objectSpec) < 0)
goto cleanup;
- }
objectSpec_isAppended = true;
if (esxVI_CreateFilter(ctx, propertyFilterSpec, esxVI_Boolean_True,
- &propertyFilter) < 0) {
+ &propertyFilter) < 0)
goto cleanup;
- }
while (state != esxVI_TaskInfoState_Success &&
state != esxVI_TaskInfoState_Error) {
@@ -4602,9 +4427,8 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
* esxVI_LookupTaskInfoByTask() and esxVI_CancelTask()
* don't overwrite the actual error
*/
- if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) {
+ if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo))
goto cleanup;
- }
if (taskInfo->cancelable == esxVI_Boolean_True) {
if (esxVI_CancelTask(ctx, task) < 0 && blocked) {
@@ -4623,17 +4447,15 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
}
}
- if (esxVI_WaitForUpdates(ctx, version, &updateSet) < 0) {
+ if (esxVI_WaitForUpdates(ctx, version, &updateSet) < 0)
goto cleanup;
- }
VIR_FREE(version);
if (VIR_STRDUP(version, updateSet->version) < 0)
goto cleanup;
- if (!updateSet->filterSet) {
+ if (!updateSet->filterSet)
continue;
- }
for (propertyFilterUpdate = updateSet->filterSet;
propertyFilterUpdate;
@@ -4655,27 +4477,22 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
}
}
- if (!propertyValue) {
+ if (!propertyValue)
continue;
- }
- if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, &state) < 0) {
+ if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, &state) < 0)
goto cleanup;
- }
}
- if (esxVI_DestroyPropertyFilter(ctx, propertyFilter) < 0) {
+ if (esxVI_DestroyPropertyFilter(ctx, propertyFilter) < 0)
VIR_DEBUG("DestroyPropertyFilter failed");
- }
- if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, finalState) < 0) {
+ if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, finalState) < 0)
goto cleanup;
- }
if (*finalState != esxVI_TaskInfoState_Success) {
- if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) {
+ if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo))
goto cleanup;
- }
if (!taskInfo->error) {
if (VIR_STRDUP(*errorMessage, _("Unknown error")) < 0)
@@ -4698,21 +4515,17 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
* Remove values given by the caller from the data structures to prevent
* them from being freed by the call to esxVI_PropertyFilterSpec_Free().
*/
- if (objectSpec) {
+ if (objectSpec)
objectSpec->obj = NULL;
- }
- if (propertySpec) {
+ if (propertySpec)
propertySpec->type = NULL;
- }
- if (!objectSpec_isAppended) {
+ if (!objectSpec_isAppended)
esxVI_ObjectSpec_Free(&objectSpec);
- }
- if (!propertySpec_isAppended) {
+ if (!propertySpec_isAppended)
esxVI_PropertySpec_Free(&propertySpec);
- }
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
esxVI_ManagedObjectReference_Free(&propertyFilter);
@@ -4842,9 +4655,8 @@ esxVI_LookupHostInternetScsiHbaStaticTargetByName
for (candidate = hostInternetScsiHba->configuredStaticTarget;
candidate; candidate = candidate->_next) {
- if (STREQ(candidate->iScsiName, name)) {
+ if (STREQ(candidate->iScsiName, name))
break;
- }
}
if (!candidate) {
@@ -4856,9 +4668,8 @@ esxVI_LookupHostInternetScsiHbaStaticTargetByName
goto cleanup;
}
- if (esxVI_HostInternetScsiHbaStaticTarget_DeepCopy(target, candidate) < 0) {
+ if (esxVI_HostInternetScsiHbaStaticTarget_DeepCopy(target, candidate) < 0)
goto cleanup;
- }
result = 0;
@@ -4884,9 +4695,8 @@ esxVI_LookupHostInternetScsiHba(esxVI_Context *ctx,
if (esxVI_String_AppendValueToList
(&propertyNameList, "config.storageDevice.hostBusAdapter") < 0
||
esxVI_LookupHostSystemProperties(ctx, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
@@ -4894,9 +4704,8 @@ esxVI_LookupHostInternetScsiHba(esxVI_Context *ctx,
"config.storageDevice.hostBusAdapter")) {
if (esxVI_HostHostBusAdapter_CastListFromAnyType
(dynamicProperty->val, &hostHostBusAdapterList) < 0 ||
- !hostHostBusAdapterList) {
+ !hostHostBusAdapterList)
goto cleanup;
- }
} else {
VIR_WARN("Unexpected '%s' property",
dynamicProperty->name);
}
@@ -4911,9 +4720,8 @@ esxVI_LookupHostInternetScsiHba(esxVI_Context *ctx,
if (candidate) {
if (esxVI_HostInternetScsiHba_DeepCopy(hostInternetScsiHba,
- candidate) < 0) {
+ candidate) < 0)
goto cleanup;
- }
break;
}
}
@@ -4941,17 +4749,15 @@ esxVI_LookupScsiLunList(esxVI_Context *ctx, esxVI_ScsiLun
**scsiLunList)
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.storageDevice.scsiLun") < 0
||
esxVI_LookupHostSystemProperties(ctx, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.storageDevice.scsiLun")) {
if (esxVI_ScsiLun_CastListFromAnyType(dynamicProperty->val,
- scsiLunList) < 0) {
+ scsiLunList) < 0)
goto cleanup;
- }
break;
} else {
@@ -4994,9 +4800,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName
(&propertyNameList,
"config.storageDevice.scsiTopology.adapter") < 0 ||
esxVI_LookupHostSystemProperties(ctx, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
@@ -5005,9 +4810,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName
esxVI_HostScsiTopologyInterface_Free(&hostScsiInterfaceList);
if (esxVI_HostScsiTopologyInterface_CastListFromAnyType
- (dynamicProperty->val, &hostScsiInterfaceList) < 0) {
+ (dynamicProperty->val, &hostScsiInterfaceList) < 0)
goto cleanup;
- }
break;
} else {
@@ -5037,9 +4841,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName
}
}
- if (!found || !hostScsiTopologyTarget) {
+ if (!found || !hostScsiTopologyTarget)
goto cleanup;
- }
if (!hostScsiTopologyTarget->lun) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -5048,9 +4851,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName
}
if (esxVI_HostScsiTopologyLun_DeepCopyList(hostScsiTopologyLunList,
- hostScsiTopologyTarget->lun) < 0) {
+ hostScsiTopologyTarget->lun) < 0)
goto cleanup;
- }
result = 0;
@@ -5089,9 +4891,8 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context *ctx,
(&propertyNameList,
"config.storageDevice.scsiTopology.adapter") < 0 ||
esxVI_LookupHostSystemProperties(ctx, propertyNameList,
- &hostSystem) < 0) {
+ &hostSystem) < 0)
goto cleanup;
- }
for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
@@ -5100,9 +4901,8 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context *ctx,
esxVI_HostScsiTopologyInterface_Free(&hostScsiInterfaceList);
if (esxVI_HostScsiTopologyInterface_CastListFromAnyType
- (dynamicProperty->val, &hostScsiInterfaceList) < 0) {
+ (dynamicProperty->val, &hostScsiInterfaceList) < 0)
goto cleanup;
- }
break;
} else {
@@ -5305,9 +5105,8 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx,
if (esxVI_LookupObjectContentByType(ctx, root, type, propertyNameList,
objectContentList,
- esxVI_Occurrence_OptionalList) < 0) {
+ esxVI_Occurrence_OptionalList) < 0)
goto cleanup;
- }
/* Search for a matching item */
if (name) {
@@ -5316,9 +5115,8 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx,
name_candidate = NULL;
if (esxVI_GetStringValue(candidate, "name", &name_candidate,
- esxVI_Occurrence_RequiredItem) < 0) {
+ esxVI_Occurrence_RequiredItem) < 0)
goto cleanup;
- }
if (STREQ(name_candidate, name)) {
/* Found item with matching name */
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 184b01f..7fbb652 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -239,9 +239,8 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx,
if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request,
&response, esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_ServiceContent_Deserialize(response->node, serviceContent) < 0) {
+ esxVI_ServiceContent_Deserialize(response->node, serviceContent) < 0)
goto cleanup;
- }
result = 0;
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 4c7dc30..e815f74 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -944,13 +944,11 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
return -1;
}
- if (!src) {
+ if (!src)
return 0;
- }
- if (esxVI_AnyType_Alloc(dest) < 0) {
+ if (esxVI_AnyType_Alloc(dest) < 0)
goto failure;
- }
(*dest)->_type = src->_type;
(*dest)->node = xmlCopyNode(src->node, 1);
@@ -964,9 +962,8 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
(*dest)->type = src->type;
if (VIR_STRDUP((*dest)->other, src->other) < 0 ||
- VIR_STRDUP((*dest)->value, src->value) < 0) {
+ VIR_STRDUP((*dest)->value, src->value) < 0)
goto failure;
- }
switch (src->type) {
case esxVI_Type_Boolean:
@@ -1015,9 +1012,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
return -1;
}
- if (esxVI_AnyType_Alloc(anyType) < 0) {
+ if (esxVI_AnyType_Alloc(anyType) < 0)
return -1;
- }
(*anyType)->node = xmlCopyNode(node, 1);
@@ -1151,9 +1147,8 @@ esxVI_String_ListContainsValue(esxVI_String *stringList, const char
*value)
esxVI_String *string;
for (string = stringList; string; string = string->_next) {
- if (STREQ(string->value, value)) {
+ if (STREQ(string->value, value))
return true;
- }
}
return false;
@@ -1167,16 +1162,14 @@ esxVI_String_AppendValueToList(esxVI_String **stringList, const
char *value)
{
esxVI_String *string = NULL;
- if (esxVI_String_Alloc(&string) < 0) {
+ if (esxVI_String_Alloc(&string) < 0)
return -1;
- }
if (VIR_STRDUP(string->value, value) < 0)
goto failure;
- if (esxVI_String_AppendToList(stringList, string) < 0) {
+ if (esxVI_String_AppendToList(stringList, string) < 0)
goto failure;
- }
return 0;
@@ -1194,16 +1187,14 @@ esxVI_String_AppendValueListToList(esxVI_String **stringList,
const char *value = valueList;
while (value && *value != '\0') {
- if (esxVI_String_AppendValueToList(&stringListToAppend, value) < 0) {
+ if (esxVI_String_AppendValueToList(&stringListToAppend, value) < 0)
goto failure;
- }
value += strlen(value) + 1;
}
- if (esxVI_String_AppendToList(stringList, stringListToAppend) < 0) {
+ if (esxVI_String_AppendToList(stringList, stringListToAppend) < 0)
goto failure;
- }
return 0;
@@ -1230,9 +1221,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
return -1;
}
- if (!src) {
+ if (!src)
return 0;
- }
return VIR_STRDUP(*dest, src);
}
@@ -1263,9 +1253,8 @@ esxVI_String_SerializeValue(const char *value, const char *element,
return -1;
}
- if (!value) {
+ if (!value)
return 0;
- }
ESV_VI__XML_TAG__OPEN(output, element, "xsd:string");
@@ -1285,9 +1274,8 @@ esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string)
}
if (esxVI_String_Alloc(string) < 0 ||
- esxVI_String_DeserializeValue(node, &(*string)->value) < 0) {
+ esxVI_String_DeserializeValue(node, &(*string)->value) < 0)
goto failure;
- }
return 0;
@@ -1483,9 +1471,8 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime
**dateTime)
return -1;
}
- if (esxVI_DateTime_Alloc(dateTime) < 0) {
+ if (esxVI_DateTime_Alloc(dateTime) < 0)
return -1;
- }
(*dateTime)->value =
(char *)xmlNodeListGetString(node->doc, node->children, 1);
@@ -1577,9 +1564,8 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
tz_offset = tz_hours * 60 * 60 + tz_minutes * 60;
- if (sign == '-') {
+ if (sign == '-')
tz_offset = -tz_offset;
- }
} else if (STREQ(tmp, "Z")) {
/* Z refers to UTC. tz_offset is already initialized to zero */
} else {
@@ -1657,9 +1643,8 @@ esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault
**methodFault)
return -1;
}
- if (esxVI_MethodFault_Alloc(methodFault) < 0) {
+ if (esxVI_MethodFault_Alloc(methodFault) < 0)
return -1;
- }
(*methodFault)->_actualType =
(char *)xmlGetNsProp(node, BAD_CAST "type",
@@ -1723,9 +1708,8 @@ esxVI_ManagedObjectReference_Serialize
return -1;
}
- if (!managedObjectReference) {
+ if (!managedObjectReference)
return 0;
- }
virBufferAddLit(output, "<");
virBufferAdd(output, element, -1);
@@ -1753,9 +1737,8 @@ esxVI_ManagedObjectReference_Deserialize
return -1;
}
- if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0) {
+ if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0)
return -1;
- }
(*managedObjectReference)->type =
(char *)xmlGetNoNsProp(node, BAD_CAST "type");
@@ -1767,9 +1750,8 @@ esxVI_ManagedObjectReference_Deserialize
}
if (esxVI_String_DeserializeValue(node,
- &(*managedObjectReference)->value) < 0)
{
+ &(*managedObjectReference)->value) < 0)
goto failure;
- }
return 0;
--
2.1.3