提交 247ad915 编写于 作者: M Martin Kletzander

Remove unnecessary curly brackets in rest of src/esx/

Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 090cb1e6
...@@ -43,9 +43,8 @@ esxNodeDeviceOpen(virConnectPtr conn, ...@@ -43,9 +43,8 @@ esxNodeDeviceOpen(virConnectPtr conn,
{ {
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); 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; return VIR_DRV_OPEN_DECLINED;
}
return VIR_DRV_OPEN_SUCCESS; return VIR_DRV_OPEN_SUCCESS;
} }
......
...@@ -46,9 +46,8 @@ esxInterfaceOpen(virConnectPtr conn, ...@@ -46,9 +46,8 @@ esxInterfaceOpen(virConnectPtr conn,
{ {
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); 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; return VIR_DRV_OPEN_DECLINED;
}
return VIR_DRV_OPEN_SUCCESS; return VIR_DRV_OPEN_SUCCESS;
} }
...@@ -98,9 +97,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames) ...@@ -98,9 +97,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames)
int count = 0; int count = 0;
size_t i; size_t i;
if (maxnames == 0) { if (maxnames == 0)
return 0; return 0;
}
if (esxVI_EnsureSession(priv->primary) < 0 || if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) { esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) {
...@@ -119,9 +117,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames) ...@@ -119,9 +117,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames)
cleanup: cleanup:
if (! success) { if (! success) {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
}
count = -1; count = -1;
} }
...@@ -234,9 +231,8 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) ...@@ -234,9 +231,8 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
if (physicalNic->spec->ip) { if (physicalNic->spec->ip) {
protocol.family = (char *)"ipv4"; protocol.family = (char *)"ipv4";
if (physicalNic->spec->ip->dhcp == esxVI_Boolean_True) { if (physicalNic->spec->ip->dhcp == esxVI_Boolean_True)
protocol.dhcp = 1; protocol.dhcp = 1;
}
if (physicalNic->spec->ip->ipAddress && if (physicalNic->spec->ip->ipAddress &&
physicalNic->spec->ip->subnetMask && physicalNic->spec->ip->subnetMask &&
......
...@@ -52,9 +52,8 @@ esxNetworkOpen(virConnectPtr conn, ...@@ -52,9 +52,8 @@ esxNetworkOpen(virConnectPtr conn,
{ {
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); 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; return VIR_DRV_OPEN_DECLINED;
}
return VIR_DRV_OPEN_SUCCESS; return VIR_DRV_OPEN_SUCCESS;
} }
...@@ -105,9 +104,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames) ...@@ -105,9 +104,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
int count = 0; int count = 0;
size_t i; size_t i;
if (maxnames == 0) { if (maxnames == 0)
return 0; return 0;
}
if (esxVI_EnsureSession(priv->primary) < 0 || if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupHostVirtualSwitchList(priv->primary, esxVI_LookupHostVirtualSwitchList(priv->primary,
...@@ -127,9 +125,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames) ...@@ -127,9 +125,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
cleanup: cleanup:
if (! success) { if (! success) {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
}
count = -1; count = -1;
} }
...@@ -181,9 +178,8 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) ...@@ -181,9 +178,8 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
hostVirtualSwitch = hostVirtualSwitch->_next) { hostVirtualSwitch = hostVirtualSwitch->_next) {
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5); 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; break;
}
} }
if (!hostVirtualSwitch) { if (!hostVirtualSwitch) {
...@@ -265,34 +261,30 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth, ...@@ -265,34 +261,30 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth,
return 0; return 0;
} }
if (esxVI_HostNetworkTrafficShapingPolicy_Alloc(shapingPolicy) < 0) { if (esxVI_HostNetworkTrafficShapingPolicy_Alloc(shapingPolicy) < 0)
goto cleanup; goto cleanup;
}
(*shapingPolicy)->enabled = esxVI_Boolean_True; (*shapingPolicy)->enabled = esxVI_Boolean_True;
if (bandwidth->in->average > 0) { if (bandwidth->in->average > 0) {
if (esxVI_Long_Alloc(&(*shapingPolicy)->averageBandwidth) < 0) { if (esxVI_Long_Alloc(&(*shapingPolicy)->averageBandwidth) < 0)
goto cleanup; goto cleanup;
}
/* Scale kilobytes per second to bits per second */ /* Scale kilobytes per second to bits per second */
(*shapingPolicy)->averageBandwidth->value = bandwidth->in->average * 8 * 1000; (*shapingPolicy)->averageBandwidth->value = bandwidth->in->average * 8 * 1000;
} }
if (bandwidth->in->peak > 0) { if (bandwidth->in->peak > 0) {
if (esxVI_Long_Alloc(&(*shapingPolicy)->peakBandwidth) < 0) { if (esxVI_Long_Alloc(&(*shapingPolicy)->peakBandwidth) < 0)
goto cleanup; goto cleanup;
}
/* Scale kilobytes per second to bits per second */ /* Scale kilobytes per second to bits per second */
(*shapingPolicy)->peakBandwidth->value = bandwidth->in->peak * 8 * 1000; (*shapingPolicy)->peakBandwidth->value = bandwidth->in->peak * 8 * 1000;
} }
if (bandwidth->in->burst > 0) { if (bandwidth->in->burst > 0) {
if (esxVI_Long_Alloc(&(*shapingPolicy)->burstSize) < 0) { if (esxVI_Long_Alloc(&(*shapingPolicy)->burstSize) < 0)
goto cleanup; goto cleanup;
}
/* Scale kilobytes to bytes */ /* Scale kilobytes to bytes */
(*shapingPolicy)->burstSize->value = bandwidth->in->burst * 1024; (*shapingPolicy)->burstSize->value = bandwidth->in->burst * 1024;
...@@ -301,9 +293,8 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth, ...@@ -301,9 +293,8 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth,
result = 0; result = 0;
cleanup: cleanup:
if (result < 0) { if (result < 0)
esxVI_HostNetworkTrafficShapingPolicy_Free(shapingPolicy); esxVI_HostNetworkTrafficShapingPolicy_Free(shapingPolicy);
}
return result; return result;
} }
...@@ -328,16 +319,14 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) ...@@ -328,16 +319,14 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
unsigned char md5[MD5_DIGEST_SIZE]; /* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */ 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; return NULL;
}
/* Parse network XML */ /* Parse network XML */
def = virNetworkDefParseString(xml); def = virNetworkDefParseString(xml);
if (!def) { if (!def)
return NULL; return NULL;
}
/* Check if an existing HostVirtualSwitch should be edited */ /* Check if an existing HostVirtualSwitch should be edited */
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, def->name, if (esxVI_LookupHostVirtualSwitchByName(priv->primary, def->name,
...@@ -372,9 +361,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) ...@@ -372,9 +361,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
/* Verify that specified HostPortGroups don't exist already */ /* Verify that specified HostPortGroups don't exist already */
if (def->nPortGroups > 0) { if (def->nPortGroups > 0) {
if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) { if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0)
goto cleanup; goto cleanup;
}
for (i = 0; i < def->nPortGroups; ++i) { for (i = 0; i < def->nPortGroups; ++i) {
for (hostPortGroup = hostPortGroupList; hostPortGroup; for (hostPortGroup = hostPortGroupList; hostPortGroup;
...@@ -405,9 +393,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) ...@@ -405,9 +393,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
(esxVI_HostVirtualSwitchBridge *)hostVirtualSwitchBondBridge; (esxVI_HostVirtualSwitchBridge *)hostVirtualSwitchBondBridge;
/* Lookup PhysicalNic list and match by name to get key */ /* 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; goto cleanup;
}
for (i = 0; i < def->forward.nifs; ++i) { for (i = 0; i < def->forward.nifs; ++i) {
bool found = false; bool found = false;
...@@ -447,9 +434,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) ...@@ -447,9 +434,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
hostVirtualSwitchSpec->numPorts->value = 128; hostVirtualSwitchSpec->numPorts->value = 128;
if (def->bandwidth) { if (def->bandwidth) {
if (esxVI_HostNetworkPolicy_Alloc(&hostVirtualSwitchSpec->policy) < 0) { if (esxVI_HostNetworkPolicy_Alloc(&hostVirtualSwitchSpec->policy) < 0)
goto cleanup; goto cleanup;
}
if (esxBandwidthToShapingPolicy if (esxBandwidthToShapingPolicy
(def->bandwidth, (def->bandwidth,
...@@ -530,9 +516,8 @@ esxNetworkUndefine(virNetworkPtr network) ...@@ -530,9 +516,8 @@ esxNetworkUndefine(virNetworkPtr network)
esxVI_HostPortGroup *hostPortGroup = NULL; esxVI_HostPortGroup *hostPortGroup = NULL;
esxVI_HostPortGroupPort *hostPortGroupPort = NULL; esxVI_HostPortGroupPort *hostPortGroupPort = NULL;
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
/* Lookup HostVirtualSwitch and HostPortGroup list*/ /* Lookup HostVirtualSwitch and HostPortGroup list*/
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network->name, if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network->name,
...@@ -630,9 +615,8 @@ esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shapingPolicy ...@@ -630,9 +615,8 @@ esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shapingPolicy
return -1; return -1;
} }
if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True) { if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True)
return 0; return 0;
}
if (VIR_ALLOC(*bandwidth) < 0 || if (VIR_ALLOC(*bandwidth) < 0 ||
VIR_ALLOC((*bandwidth)->in) < 0 || VIR_ALLOC((*bandwidth)->in) < 0 ||
...@@ -682,9 +666,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) ...@@ -682,9 +666,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
esxVI_String *networkName = NULL; esxVI_String *networkName = NULL;
virNetworkDefPtr def; virNetworkDefPtr def;
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
if (VIR_ALLOC(def) < 0) if (VIR_ALLOC(def) < 0)
goto cleanup; goto cleanup;
...@@ -718,9 +701,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) ...@@ -718,9 +701,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
goto cleanup; goto cleanup;
/* Find PhysicalNic by key */ /* Find PhysicalNic by key */
if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) { if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
goto cleanup; goto cleanup;
}
for (physicalNicKey = hostVirtualSwitch->pnic; for (physicalNicKey = hostVirtualSwitch->pnic;
physicalNicKey; physicalNicKey = physicalNicKey->_next) { physicalNicKey; physicalNicKey = physicalNicKey->_next) {
...@@ -781,9 +763,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) ...@@ -781,9 +763,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
} }
/* Find HostPortGroup by key */ /* Find HostPortGroup by key */
if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) { if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0)
goto cleanup; goto cleanup;
}
for (hostPortGroupKey = hostVirtualSwitch->portgroup; for (hostPortGroupKey = hostVirtualSwitch->portgroup;
hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next) { hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next) {
......
...@@ -43,9 +43,8 @@ esxNWFilterOpen(virConnectPtr conn, ...@@ -43,9 +43,8 @@ esxNWFilterOpen(virConnectPtr conn,
{ {
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); 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; return VIR_DRV_OPEN_DECLINED;
}
return VIR_DRV_OPEN_SUCCESS; return VIR_DRV_OPEN_SUCCESS;
} }
......
...@@ -41,9 +41,8 @@ esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, ...@@ -41,9 +41,8 @@ esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED,
{ {
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); 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; return VIR_DRV_OPEN_DECLINED;
}
return VIR_DRV_OPEN_SUCCESS; return VIR_DRV_OPEN_SUCCESS;
} }
......
...@@ -104,9 +104,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, ...@@ -104,9 +104,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
esxVI_HostInternetScsiHbaStaticTarget *target; esxVI_HostInternetScsiHbaStaticTarget *target;
size_t i; size_t i;
if (maxnames == 0) { if (maxnames == 0)
return 0; return 0;
}
if (esxVI_LookupHostInternetScsiHba(priv->primary, if (esxVI_LookupHostInternetScsiHba(priv->primary,
&hostInternetScsiHba) < 0) { &hostInternetScsiHba) < 0) {
...@@ -140,9 +139,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, ...@@ -140,9 +139,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
cleanup: cleanup:
if (! success) { if (! success) {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
}
} }
esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba); esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba);
...@@ -222,9 +220,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, ...@@ -222,9 +220,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
target; target = target->_next) { target; target = target->_next) {
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5); 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; break;
}
} }
if (!target) { if (!target) {
...@@ -304,15 +301,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) ...@@ -304,15 +301,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
memset(&def, 0, sizeof(def)); memset(&def, 0, sizeof(def));
if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba)) { if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba))
goto cleanup; goto cleanup;
}
for (target = hostInternetScsiHba->configuredStaticTarget; for (target = hostInternetScsiHba->configuredStaticTarget;
target; target = target->_next) { target; target = target->_next) {
if (STREQ(target->iScsiName, pool->name)) { if (STREQ(target->iScsiName, pool->name))
break; break;
}
} }
if (!target) { if (!target) {
...@@ -338,9 +333,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) ...@@ -338,9 +333,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
def.source.hosts[0].name = target->address; def.source.hosts[0].name = target->address;
if (target->port) { if (target->port)
def.source.hosts[0].port = target->port->value; def.source.hosts[0].port = target->port->value;
}
/* TODO: add CHAP authentication params */ /* TODO: add CHAP authentication params */
xml = virStoragePoolDefFormat(&def); xml = virStoragePoolDefFormat(&def);
...@@ -403,9 +397,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, ...@@ -403,9 +397,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
return 0; return 0;
} }
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup; goto cleanup;
}
for (scsiLun = scsiLunList; scsiLun && count < maxnames; for (scsiLun = scsiLunList; scsiLun && count < maxnames;
scsiLun = scsiLun->_next) { scsiLun = scsiLun->_next) {
...@@ -425,9 +418,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, ...@@ -425,9 +418,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
cleanup: cleanup:
if (! success) { if (! success) {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
}
count = -1; count = -1;
} }
...@@ -452,9 +444,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, ...@@ -452,9 +444,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
unsigned char md5[MD5_DIGEST_SIZE]; unsigned char md5[MD5_DIGEST_SIZE];
char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup; goto cleanup;
}
for (scsiLun = scsiLunList; scsiLun; for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) { scsiLun = scsiLun->_next) {
...@@ -500,9 +491,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path) ...@@ -500,9 +491,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
unsigned char md5[MD5_DIGEST_SIZE]; unsigned char md5[MD5_DIGEST_SIZE];
char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup; goto cleanup;
}
for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) { for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) {
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun); hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
...@@ -548,13 +538,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) ...@@ -548,13 +538,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
/* key may be LUN device path */ /* key may be LUN device path */
if (STRPREFIX(key, "/")) { if (STRPREFIX(key, "/"))
return esxStorageVolLookupByPath(conn, key); return esxStorageVolLookupByPath(conn, key);
}
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup; goto cleanup;
}
for (scsiLun = scsiLunList; scsiLun; for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) { scsiLun = scsiLun->_next) {
...@@ -631,9 +619,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume, ...@@ -631,9 +619,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume,
esxVI_ScsiLun *scsiLun; esxVI_ScsiLun *scsiLun;
esxVI_HostScsiDisk *hostScsiDisk = NULL; esxVI_HostScsiDisk *hostScsiDisk = NULL;
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup; goto cleanup;
}
for (scsiLun = scsiLunList; scsiLun; for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) { scsiLun = scsiLun->_next) {
...@@ -687,9 +674,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, ...@@ -687,9 +674,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
memset(&pool, 0, sizeof(pool)); memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def)); memset(&def, 0, sizeof(def));
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
goto cleanup; goto cleanup;
}
for (scsiLun = scsiLunList; scsiLun; for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) { scsiLun = scsiLun->_next) {
...@@ -715,9 +701,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, ...@@ -715,9 +701,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
virUUIDFormat(md5, uuid_string); virUUIDFormat(md5, uuid_string);
if (VIR_STRDUP(def.key, uuid_string) < 0) { if (VIR_STRDUP(def.key, uuid_string) < 0)
goto cleanup; goto cleanup;
}
/* iSCSI LUN exposes a block device */ /* iSCSI LUN exposes a block device */
def.type = VIR_STORAGE_VOL_BLOCK; def.type = VIR_STORAGE_VOL_BLOCK;
......
...@@ -120,9 +120,8 @@ esxConnectNumOfStoragePools(virConnectPtr conn) ...@@ -120,9 +120,8 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
esxVI_ObjectContent *datastoreList = NULL; esxVI_ObjectContent *datastoreList = NULL;
esxVI_ObjectContent *datastore = NULL; esxVI_ObjectContent *datastore = NULL;
if (esxVI_LookupDatastoreList(priv->primary, NULL, &datastoreList) < 0) { if (esxVI_LookupDatastoreList(priv->primary, NULL, &datastoreList) < 0)
return -1; return -1;
}
for (datastore = datastoreList; datastore; for (datastore = datastoreList; datastore;
datastore = datastore->_next) { datastore = datastore->_next) {
...@@ -149,9 +148,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, ...@@ -149,9 +148,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
int count = 0; int count = 0;
size_t i; size_t i;
if (maxnames == 0) { if (maxnames == 0)
return 0; return 0;
}
if (esxVI_String_AppendValueToList(&propertyNameList, if (esxVI_String_AppendValueToList(&propertyNameList,
"summary.name") < 0 || "summary.name") < 0 ||
...@@ -185,9 +183,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, ...@@ -185,9 +183,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
cleanup: cleanup:
if (! success) { if (! success) {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
}
count = -1; count = -1;
} }
...@@ -295,9 +292,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, ...@@ -295,9 +292,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
md5_buffer(hostMount->mountInfo->path, md5_buffer(hostMount->mountInfo->path,
strlen(hostMount->mountInfo->path), md5); strlen(hostMount->mountInfo->path), md5);
if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) { if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break; break;
}
} }
if (!datastore) { if (!datastore) {
...@@ -580,9 +576,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, ...@@ -580,9 +576,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
return -1; return -1;
} }
if (maxnames == 0) { if (maxnames == 0)
return 0; return 0;
}
if (esxVI_LookupDatastoreContentByDatastoreName(priv->primary, pool->name, if (esxVI_LookupDatastoreContentByDatastoreName(priv->primary, pool->name,
&searchResultsList) < 0) { &searchResultsList) < 0) {
...@@ -626,9 +621,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, ...@@ -626,9 +621,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
cleanup: cleanup:
if (! success) { if (! success) {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
}
count = -1; count = -1;
} }
...@@ -807,9 +801,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) ...@@ -807,9 +801,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
goto cleanup; goto cleanup;
} }
if (esxUtil_ReformatUuid(uuid_string, key_candidate) < 0) { if (esxUtil_ReformatUuid(uuid_string, key_candidate) < 0)
goto cleanup; goto cleanup;
}
if (STREQ(key, key_candidate)) { if (STREQ(key, key_candidate)) {
/* Found matching UUID */ /* Found matching UUID */
...@@ -873,9 +866,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -873,9 +866,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
/* Parse config */ /* Parse config */
def = virStorageVolDefParseString(&poolDef, xmldesc); def = virStorageVolDefParseString(&poolDef, xmldesc);
if (!def) { if (!def)
goto cleanup; goto cleanup;
}
if (def->type != VIR_STORAGE_VOL_FILE) { if (def->type != VIR_STORAGE_VOL_FILE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -914,16 +906,14 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -914,16 +906,14 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName); directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
if (!directoryName) { if (!directoryName)
goto cleanup; goto cleanup;
}
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName + fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
strlen(unescapedDirectoryName) + 1); strlen(unescapedDirectoryName) + 1);
if (!fileName) { if (!fileName)
goto cleanup; goto cleanup;
}
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name, if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name,
directoryName) < 0) directoryName) < 0)
...@@ -1012,14 +1002,12 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -1012,14 +1002,12 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
goto cleanup; goto cleanup;
} }
if (esxUtil_ReformatUuid(uuid_string, key) < 0) { if (esxUtil_ReformatUuid(uuid_string, key) < 0)
goto cleanup; goto cleanup;
}
} else { } else {
/* Fall back to the path as key */ /* Fall back to the path as key */
if (VIR_STRDUP(key, datastorePath) < 0) { if (VIR_STRDUP(key, datastorePath) < 0)
goto cleanup; goto cleanup;
}
} }
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -1099,9 +1087,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, ...@@ -1099,9 +1087,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
/* Parse config */ /* Parse config */
def = virStorageVolDefParseString(&poolDef, xmldesc); def = virStorageVolDefParseString(&poolDef, xmldesc);
if (!def) { if (!def)
goto cleanup; goto cleanup;
}
if (def->type != VIR_STORAGE_VOL_FILE) { if (def->type != VIR_STORAGE_VOL_FILE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -1140,16 +1127,14 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, ...@@ -1140,16 +1127,14 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName); directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
if (!directoryName) { if (!directoryName)
goto cleanup; goto cleanup;
}
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName + fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
strlen(unescapedDirectoryName) + 1); strlen(unescapedDirectoryName) + 1);
if (!fileName) { if (!fileName)
goto cleanup; goto cleanup;
}
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name, if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name,
directoryName) < 0) directoryName) < 0)
...@@ -1204,14 +1189,12 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, ...@@ -1204,14 +1189,12 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup; goto cleanup;
} }
if (esxUtil_ReformatUuid(uuid_string, key) < 0) { if (esxUtil_ReformatUuid(uuid_string, key) < 0)
goto cleanup; goto cleanup;
}
} else { } else {
/* Fall back to the path as key */ /* Fall back to the path as key */
if (VIR_STRDUP(key, datastorePath) < 0) { if (VIR_STRDUP(key, datastorePath) < 0)
goto cleanup; goto cleanup;
}
} }
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
......
...@@ -60,9 +60,8 @@ esxStorageOpen(virConnectPtr conn, ...@@ -60,9 +60,8 @@ esxStorageOpen(virConnectPtr conn,
{ {
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); 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; return VIR_DRV_OPEN_DECLINED;
}
return VIR_DRV_OPEN_SUCCESS; return VIR_DRV_OPEN_SUCCESS;
} }
...@@ -85,16 +84,14 @@ esxConnectNumOfStoragePools(virConnectPtr conn) ...@@ -85,16 +84,14 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
size_t i; size_t i;
int tmp; int tmp;
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
for (i = 0; i < LAST_BACKEND; ++i) { for (i = 0; i < LAST_BACKEND; ++i) {
tmp = backends[i]->connectNumOfStoragePools(conn); tmp = backends[i]->connectNumOfStoragePools(conn);
if (tmp < 0) { if (tmp < 0)
return -1; return -1;
}
count += tmp; count += tmp;
} }
...@@ -113,20 +110,17 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames) ...@@ -113,20 +110,17 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames)
size_t i; size_t i;
int tmp; int tmp;
if (maxnames == 0) { if (maxnames == 0)
return 0; return 0;
}
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
for (i = 0; i < LAST_BACKEND; ++i) { for (i = 0; i < LAST_BACKEND; ++i) {
tmp = backends[i]->connectListStoragePools(conn, &names[count], maxnames - count); tmp = backends[i]->connectListStoragePools(conn, &names[count], maxnames - count);
if (tmp < 0) { if (tmp < 0)
goto cleanup; goto cleanup;
}
count += tmp; count += tmp;
} }
...@@ -135,9 +129,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames) ...@@ -135,9 +129,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames)
cleanup: cleanup:
if (! success) { if (! success) {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
}
count = -1; count = -1;
} }
...@@ -176,16 +169,14 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name) ...@@ -176,16 +169,14 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
virCheckNonNullArgReturn(name, NULL); virCheckNonNullArgReturn(name, NULL);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
for (i = 0; i < LAST_BACKEND; ++i) { for (i = 0; i < LAST_BACKEND; ++i) {
pool = backends[i]->storagePoolLookupByName(conn, name); pool = backends[i]->storagePoolLookupByName(conn, name);
if (pool) { if (pool)
return pool; return pool;
}
} }
virReportError(VIR_ERR_NO_STORAGE_POOL, virReportError(VIR_ERR_NO_STORAGE_POOL,
...@@ -204,17 +195,15 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid) ...@@ -204,17 +195,15 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virStoragePoolPtr pool; virStoragePoolPtr pool;
char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
/* invoke backend drive method to search all known pools */ /* invoke backend drive method to search all known pools */
for (i = 0; i < LAST_BACKEND; ++i) { for (i = 0; i < LAST_BACKEND; ++i) {
pool = backends[i]->storagePoolLookupByUUID(conn, uuid); pool = backends[i]->storagePoolLookupByUUID(conn, uuid);
if (pool) { if (pool)
return pool; return pool;
}
} }
virUUIDFormat(uuid, uuid_string); virUUIDFormat(uuid, uuid_string);
...@@ -243,9 +232,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags) ...@@ -243,9 +232,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags)
virCheckNonNullArgReturn(pool->privateData, -1); virCheckNonNullArgReturn(pool->privateData, -1);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
return backend->storagePoolRefresh(pool, flags); return backend->storagePoolRefresh(pool, flags);
} }
...@@ -262,9 +250,8 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info) ...@@ -262,9 +250,8 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info)
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
return backend->storagePoolGetInfo(pool, info); return backend->storagePoolGetInfo(pool, info);
} }
...@@ -279,9 +266,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) ...@@ -279,9 +266,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
virCheckNonNullArgReturn(pool->privateData, NULL); virCheckNonNullArgReturn(pool->privateData, NULL);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
return backend->storagePoolGetXMLDesc(pool, flags); return backend->storagePoolGetXMLDesc(pool, flags);
} }
...@@ -326,9 +312,8 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool) ...@@ -326,9 +312,8 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
virCheckNonNullArgReturn(pool->privateData, -1); virCheckNonNullArgReturn(pool->privateData, -1);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
return backend->storagePoolNumOfVolumes(pool); return backend->storagePoolNumOfVolumes(pool);
} }
...@@ -344,9 +329,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, ...@@ -344,9 +329,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
virCheckNonNullArgReturn(pool->privateData, -1); virCheckNonNullArgReturn(pool->privateData, -1);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
return backend->storagePoolListVolumes(pool, names, maxnames); return backend->storagePoolListVolumes(pool, names, maxnames);
} }
...@@ -361,9 +345,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) ...@@ -361,9 +345,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, const char *name)
virCheckNonNullArgReturn(pool->privateData, NULL); virCheckNonNullArgReturn(pool->privateData, NULL);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
return backend->storageVolLookupByName(pool, name); return backend->storageVolLookupByName(pool, name);
} }
...@@ -375,9 +358,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path) ...@@ -375,9 +358,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
{ {
esxPrivate *priv = conn->privateData; esxPrivate *priv = conn->privateData;
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
/* /*
* FIXME: calling backends blindly may set unwanted error codes * FIXME: calling backends blindly may set unwanted error codes
...@@ -408,16 +390,14 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) ...@@ -408,16 +390,14 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
esxPrivate *priv = conn->privateData; esxPrivate *priv = conn->privateData;
size_t i; size_t i;
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
for (i = 0; i < LAST_BACKEND; ++i) { for (i = 0; i < LAST_BACKEND; ++i) {
volume = backends[i]->storageVolLookupByKey(conn, key); volume = backends[i]->storageVolLookupByKey(conn, key);
if (volume) { if (volume)
return volume; return volume;
}
} }
virReportError(VIR_ERR_NO_STORAGE_VOL, virReportError(VIR_ERR_NO_STORAGE_VOL,
...@@ -438,9 +418,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc, ...@@ -438,9 +418,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc,
virCheckNonNullArgReturn(pool->privateData, NULL); virCheckNonNullArgReturn(pool->privateData, NULL);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
return backend->storageVolCreateXML(pool, xmldesc, flags); return backend->storageVolCreateXML(pool, xmldesc, flags);
} }
...@@ -456,9 +435,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc, ...@@ -456,9 +435,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
virCheckNonNullArgReturn(pool->privateData, NULL); virCheckNonNullArgReturn(pool->privateData, NULL);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
return backend->storageVolCreateXMLFrom(pool, xmldesc, sourceVolume, flags); return backend->storageVolCreateXMLFrom(pool, xmldesc, sourceVolume, flags);
} }
...@@ -473,9 +451,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags) ...@@ -473,9 +451,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn(volume->privateData, -1); virCheckNonNullArgReturn(volume->privateData, -1);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
return backend->storageVolDelete(volume, flags); return backend->storageVolDelete(volume, flags);
} }
...@@ -490,9 +467,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags) ...@@ -490,9 +467,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn(volume->privateData, -1); virCheckNonNullArgReturn(volume->privateData, -1);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
return backend->storageVolWipe(volume, flags); return backend->storageVolWipe(volume, flags);
} }
...@@ -507,9 +483,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr info) ...@@ -507,9 +483,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr info)
virCheckNonNullArgReturn(volume->privateData, -1); virCheckNonNullArgReturn(volume->privateData, -1);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return -1; return -1;
}
return backend->storageVolGetInfo(volume, info); return backend->storageVolGetInfo(volume, info);
} }
...@@ -524,9 +499,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, unsigned int flags) ...@@ -524,9 +499,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn(volume->privateData, NULL); virCheckNonNullArgReturn(volume->privateData, NULL);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
return backend->storageVolGetXMLDesc(volume, flags); return backend->storageVolGetXMLDesc(volume, flags);
} }
...@@ -541,9 +515,8 @@ esxStorageVolGetPath(virStorageVolPtr volume) ...@@ -541,9 +515,8 @@ esxStorageVolGetPath(virStorageVolPtr volume)
virCheckNonNullArgReturn(volume->privateData, NULL); virCheckNonNullArgReturn(volume->privateData, NULL);
if (esxVI_EnsureSession(priv->primary) < 0) { if (esxVI_EnsureSession(priv->primary) < 0)
return NULL; return NULL;
}
return backend->storageVolGetPath(volume); return backend->storageVolGetPath(volume);
} }
......
...@@ -166,9 +166,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri) ...@@ -166,9 +166,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
result = 0; result = 0;
cleanup: cleanup:
if (result < 0) { if (result < 0)
esxUtil_FreeParsedUri(parsedUri); esxUtil_FreeParsedUri(parsedUri);
}
return result; return result;
} }
...@@ -179,9 +178,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri) ...@@ -179,9 +178,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
void void
esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri) esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri)
{ {
if (!parsedUri || !(*parsedUri)) { if (!parsedUri || !(*parsedUri))
return; return;
}
VIR_FREE((*parsedUri)->transport); VIR_FREE((*parsedUri)->transport);
VIR_FREE((*parsedUri)->vCenter); VIR_FREE((*parsedUri)->vCenter);
...@@ -197,18 +195,16 @@ int ...@@ -197,18 +195,16 @@ int
esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id) esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id)
{ {
/* Try to parse an integer from the complete string. */ /* 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; return 0;
}
/* /*
* If that fails try to parse an integer from the string tail * If that fails try to parse an integer from the string tail
* assuming the naming scheme Virtual Center seems to use. * assuming the naming scheme Virtual Center seems to use.
*/ */
if (STRPREFIX(id_string, "vm-")) { 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 0;
}
} }
return -1; return -1;
...@@ -234,9 +230,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName, ...@@ -234,9 +230,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
return -1; return -1;
} }
if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0) { if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0)
goto cleanup; goto cleanup;
}
/* Expected format: '[<datastore>] <path>' where <path> is optional */ /* Expected format: '[<datastore>] <path>' where <path> is optional */
if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' || if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' ||
...@@ -270,30 +265,25 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName, ...@@ -270,30 +265,25 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
/* Split <path> into <directory>/<file> and remove /<file> */ /* Split <path> into <directory>/<file> and remove /<file> */
tmp = strrchr(preliminaryDirectoryAndFileName, '/'); tmp = strrchr(preliminaryDirectoryAndFileName, '/');
if (tmp) { if (tmp)
*tmp = '\0'; *tmp = '\0';
}
if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0) { if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0)
goto cleanup; goto cleanup;
}
} }
result = 0; result = 0;
cleanup: cleanup:
if (result < 0) { if (result < 0) {
if (datastoreName) { if (datastoreName)
VIR_FREE(*datastoreName); VIR_FREE(*datastoreName);
}
if (directoryName) { if (directoryName)
VIR_FREE(*directoryName); VIR_FREE(*directoryName);
}
if (directoryAndFileName) { if (directoryAndFileName)
VIR_FREE(*directoryAndFileName); VIR_FREE(*directoryAndFileName);
}
} }
VIR_FREE(copyOfDatastorePath); VIR_FREE(copyOfDatastorePath);
...@@ -408,20 +398,17 @@ esxUtil_EscapeBase64(const char *string) ...@@ -408,20 +398,17 @@ esxUtil_EscapeBase64(const char *string)
virBufferAddChar(&buffer, base64[(c1 >> 2) & 0x3f]); virBufferAddChar(&buffer, base64[(c1 >> 2) & 0x3f]);
virBufferAddChar(&buffer, base64[((c1 << 4) + (c2 >> 4)) & 0x3f]); virBufferAddChar(&buffer, base64[((c1 << 4) + (c2 >> 4)) & 0x3f]);
if (length > 1) { if (length > 1)
virBufferAddChar(&buffer, base64[((c2 << 2) + (c3 >> 6)) & 0x3f]); virBufferAddChar(&buffer, base64[((c2 << 2) + (c3 >> 6)) & 0x3f]);
}
if (length > 2) { if (length > 2)
virBufferAddChar(&buffer, base64[c3 & 0x3f]); virBufferAddChar(&buffer, base64[c3 & 0x3f]);
}
length -= length > 3 ? 3 : length; length -= length > 3 ? 3 : length;
} }
if (*tmp1 != '\0') { if (*tmp1 != '\0')
virBufferAddChar(&buffer, '-'); virBufferAddChar(&buffer, '-');
}
} }
} }
...@@ -450,9 +437,8 @@ esxUtil_ReplaceSpecialWindowsPathChars(char *string) ...@@ -450,9 +437,8 @@ esxUtil_ReplaceSpecialWindowsPathChars(char *string)
--length; --length;
} }
if (*tmp != '\0') { if (*tmp != '\0')
++tmp; ++tmp;
}
} }
} }
...@@ -472,9 +458,8 @@ esxUtil_EscapeDatastoreItem(const char *string) ...@@ -472,9 +458,8 @@ esxUtil_EscapeDatastoreItem(const char *string)
escaped1 = virVMXEscapeHexPercent(replaced); escaped1 = virVMXEscapeHexPercent(replaced);
if (!escaped1) { if (!escaped1)
goto cleanup; goto cleanup;
}
escaped2 = esxUtil_EscapeBase64(escaped1); escaped2 = esxUtil_EscapeBase64(escaped1);
......
此差异已折叠。
...@@ -944,13 +944,11 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src) ...@@ -944,13 +944,11 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
return -1; return -1;
} }
if (!src) { if (!src)
return 0; return 0;
}
if (esxVI_AnyType_Alloc(dest) < 0) { if (esxVI_AnyType_Alloc(dest) < 0)
goto failure; goto failure;
}
(*dest)->_type = src->_type; (*dest)->_type = src->_type;
(*dest)->node = xmlCopyNode(src->node, 1); (*dest)->node = xmlCopyNode(src->node, 1);
...@@ -1015,9 +1013,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) ...@@ -1015,9 +1013,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
return -1; return -1;
} }
if (esxVI_AnyType_Alloc(anyType) < 0) { if (esxVI_AnyType_Alloc(anyType) < 0)
return -1; return -1;
}
(*anyType)->node = xmlCopyNode(node, 1); (*anyType)->node = xmlCopyNode(node, 1);
...@@ -1151,9 +1148,8 @@ esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value) ...@@ -1151,9 +1148,8 @@ esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value)
esxVI_String *string; esxVI_String *string;
for (string = stringList; string; string = string->_next) { for (string = stringList; string; string = string->_next) {
if (STREQ(string->value, value)) { if (STREQ(string->value, value))
return true; return true;
}
} }
return false; return false;
...@@ -1167,16 +1163,14 @@ esxVI_String_AppendValueToList(esxVI_String **stringList, const char *value) ...@@ -1167,16 +1163,14 @@ esxVI_String_AppendValueToList(esxVI_String **stringList, const char *value)
{ {
esxVI_String *string = NULL; esxVI_String *string = NULL;
if (esxVI_String_Alloc(&string) < 0) { if (esxVI_String_Alloc(&string) < 0)
return -1; return -1;
}
if (VIR_STRDUP(string->value, value) < 0) if (VIR_STRDUP(string->value, value) < 0)
goto failure; goto failure;
if (esxVI_String_AppendToList(stringList, string) < 0) { if (esxVI_String_AppendToList(stringList, string) < 0)
goto failure; goto failure;
}
return 0; return 0;
...@@ -1194,16 +1188,14 @@ esxVI_String_AppendValueListToList(esxVI_String **stringList, ...@@ -1194,16 +1188,14 @@ esxVI_String_AppendValueListToList(esxVI_String **stringList,
const char *value = valueList; const char *value = valueList;
while (value && *value != '\0') { while (value && *value != '\0') {
if (esxVI_String_AppendValueToList(&stringListToAppend, value) < 0) { if (esxVI_String_AppendValueToList(&stringListToAppend, value) < 0)
goto failure; goto failure;
}
value += strlen(value) + 1; value += strlen(value) + 1;
} }
if (esxVI_String_AppendToList(stringList, stringListToAppend) < 0) { if (esxVI_String_AppendToList(stringList, stringListToAppend) < 0)
goto failure; goto failure;
}
return 0; return 0;
...@@ -1230,9 +1222,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *src) ...@@ -1230,9 +1222,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
return -1; return -1;
} }
if (!src) { if (!src)
return 0; return 0;
}
return VIR_STRDUP(*dest, src); return VIR_STRDUP(*dest, src);
} }
...@@ -1263,9 +1254,8 @@ esxVI_String_SerializeValue(const char *value, const char *element, ...@@ -1263,9 +1254,8 @@ esxVI_String_SerializeValue(const char *value, const char *element,
return -1; return -1;
} }
if (!value) { if (!value)
return 0; return 0;
}
ESV_VI__XML_TAG__OPEN(output, element, "xsd:string"); ESV_VI__XML_TAG__OPEN(output, element, "xsd:string");
...@@ -1483,9 +1473,8 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime) ...@@ -1483,9 +1473,8 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
return -1; return -1;
} }
if (esxVI_DateTime_Alloc(dateTime) < 0) { if (esxVI_DateTime_Alloc(dateTime) < 0)
return -1; return -1;
}
(*dateTime)->value = (*dateTime)->value =
(char *)xmlNodeListGetString(node->doc, node->children, 1); (char *)xmlNodeListGetString(node->doc, node->children, 1);
...@@ -1577,9 +1566,8 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime, ...@@ -1577,9 +1566,8 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
tz_offset = tz_hours * 60 * 60 + tz_minutes * 60; tz_offset = tz_hours * 60 * 60 + tz_minutes * 60;
if (sign == '-') { if (sign == '-')
tz_offset = -tz_offset; tz_offset = -tz_offset;
}
} else if (STREQ(tmp, "Z")) { } else if (STREQ(tmp, "Z")) {
/* Z refers to UTC. tz_offset is already initialized to zero */ /* Z refers to UTC. tz_offset is already initialized to zero */
} else { } else {
...@@ -1657,9 +1645,8 @@ esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault) ...@@ -1657,9 +1645,8 @@ esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault)
return -1; return -1;
} }
if (esxVI_MethodFault_Alloc(methodFault) < 0) { if (esxVI_MethodFault_Alloc(methodFault) < 0)
return -1; return -1;
}
(*methodFault)->_actualType = (*methodFault)->_actualType =
(char *)xmlGetNsProp(node, BAD_CAST "type", (char *)xmlGetNsProp(node, BAD_CAST "type",
...@@ -1723,9 +1710,8 @@ esxVI_ManagedObjectReference_Serialize ...@@ -1723,9 +1710,8 @@ esxVI_ManagedObjectReference_Serialize
return -1; return -1;
} }
if (!managedObjectReference) { if (!managedObjectReference)
return 0; return 0;
}
virBufferAddLit(output, "<"); virBufferAddLit(output, "<");
virBufferAdd(output, element, -1); virBufferAdd(output, element, -1);
...@@ -1753,9 +1739,8 @@ esxVI_ManagedObjectReference_Deserialize ...@@ -1753,9 +1739,8 @@ esxVI_ManagedObjectReference_Deserialize
return -1; return -1;
} }
if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0) { if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0)
return -1; return -1;
}
(*managedObjectReference)->type = (*managedObjectReference)->type =
(char *)xmlGetNoNsProp(node, BAD_CAST "type"); (char *)xmlGetNoNsProp(node, BAD_CAST "type");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册