mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Remove unnecessary curly brackets in rest of src/esx/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
090cb1e63c
commit
247ad91541
@ -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,
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
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,
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
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,
|
|||||||
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,
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
/* 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)
|
|||||||
(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)
|
|||||||
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)
|
|||||||
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
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 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,
|
|||||||
{
|
{
|
||||||
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,
|
|||||||
{
|
{
|
||||||
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,
|
|||||||
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,
|
|||||||
|
|
||||||
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,
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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,
|
|||||||
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,
|
|||||||
|
|
||||||
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,
|
|||||||
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)
|
|||||||
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)
|
|||||||
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,
|
|||||||
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,
|
|||||||
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,
|
|||||||
|
|
||||||
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)
|
|||||||
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,
|
|||||||
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,
|
|||||||
|
|
||||||
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,
|
|||||||
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,
|
|||||||
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,
|
|||||||
|
|
||||||
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)
|
|||||||
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,
|
|||||||
/* 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,
|
|||||||
|
|
||||||
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,
|
|||||||
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,
|
|||||||
/* 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,
|
|||||||
|
|
||||||
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,
|
|||||||
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,
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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,
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
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,
|
|||||||
|
|
||||||
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,
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
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)
|
|||||||
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
|
|||||||
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,
|
|||||||
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,
|
|||||||
/* 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)
|
|||||||
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)
|
|||||||
--length;
|
--length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*tmp != '\0') {
|
if (*tmp != '\0')
|
||||||
++tmp;
|
++tmp;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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);
|
||||||
|
|
||||||
|
249
src/esx/esx_vi.c
249
src/esx/esx_vi.c
@ -98,26 +98,22 @@ ESX_VI__TEMPLATE__FREE(CURL,
|
|||||||
if (shared) {
|
if (shared) {
|
||||||
esxVI_SharedCURL_Remove(shared, item);
|
esxVI_SharedCURL_Remove(shared, item);
|
||||||
|
|
||||||
if (shared->count == 0) {
|
if (shared->count == 0)
|
||||||
esxVI_SharedCURL_Free(&shared);
|
esxVI_SharedCURL_Free(&shared);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multi) {
|
if (multi) {
|
||||||
esxVI_MultiCURL_Remove(multi, item);
|
esxVI_MultiCURL_Remove(multi, item);
|
||||||
|
|
||||||
if (multi->count == 0) {
|
if (multi->count == 0)
|
||||||
esxVI_MultiCURL_Free(&multi);
|
esxVI_MultiCURL_Free(&multi);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->handle) {
|
if (item->handle)
|
||||||
curl_easy_cleanup(item->handle);
|
curl_easy_cleanup(item->handle);
|
||||||
}
|
|
||||||
|
|
||||||
if (item->headers) {
|
if (item->headers)
|
||||||
curl_slist_free_all(item->headers);
|
curl_slist_free_all(item->headers);
|
||||||
}
|
|
||||||
|
|
||||||
virMutexDestroy(&item->lock);
|
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 available = 0;
|
||||||
size_t requested = size * nmemb;
|
size_t requested = size * nmemb;
|
||||||
|
|
||||||
if (!content) {
|
if (!content)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
available = strlen(content);
|
available = strlen(content);
|
||||||
|
|
||||||
if (available == 0) {
|
if (available == 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (requested > available) {
|
if (requested > available)
|
||||||
requested = available;
|
requested = available;
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(data, content, requested);
|
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
|
* are meant to download small things such as VMX files, VMDK metadata
|
||||||
* files and SOAP responses.
|
* files and SOAP responses.
|
||||||
*/
|
*/
|
||||||
if (size * nmemb > INT32_MAX / 2 - virBufferUse(buffer)) {
|
if (size * nmemb > INT32_MAX / 2 - virBufferUse(buffer))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdd(buffer, data, size * nmemb);
|
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
|
* 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.
|
* 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;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (!virStrncpy(buffer, info, size, size + 1)) {
|
if (!virStrncpy(buffer, info, size, size + 1)) {
|
||||||
VIR_FREE(buffer);
|
VIR_FREE(buffer);
|
||||||
@ -204,9 +195,8 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CURLINFO_TEXT:
|
case CURLINFO_TEXT:
|
||||||
if (size > 0 && buffer[size - 1] == '\n') {
|
if (size > 0 && buffer[size - 1] == '\n')
|
||||||
buffer[size - 1] = '\0';
|
buffer[size - 1] = '\0';
|
||||||
}
|
|
||||||
|
|
||||||
VIR_DEBUG("CURLINFO_TEXT [[[[%s]]]]", buffer);
|
VIR_DEBUG("CURLINFO_TEXT [[[[%s]]]]", buffer);
|
||||||
break;
|
break;
|
||||||
@ -430,9 +420,8 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
|
|||||||
if (virBufferCheckError(&buffer) < 0)
|
if (virBufferCheckError(&buffer) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (length) {
|
if (length)
|
||||||
*length = virBufferUse(&buffer);
|
*length = virBufferUse(&buffer);
|
||||||
}
|
|
||||||
|
|
||||||
*content = virBufferContentAndReset(&buffer);
|
*content = virBufferContentAndReset(&buffer);
|
||||||
|
|
||||||
@ -557,13 +546,11 @@ ESX_VI__TEMPLATE__FREE(SharedCURL,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->handle) {
|
if (item->handle)
|
||||||
curl_share_cleanup(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]);
|
virMutexDestroy(&item->locks[i]);
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -735,9 +722,8 @@ ESX_VI__TEMPLATE__FREE(MultiCURL,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->handle) {
|
if (item->handle)
|
||||||
curl_multi_cleanup(item->handle);
|
curl_multi_cleanup(item->handle);
|
||||||
}
|
|
||||||
|
|
||||||
#if ESX_EMULATE_CURL_MULTI_WAIT
|
#if ESX_EMULATE_CURL_MULTI_WAIT
|
||||||
VIR_FREE(item->pollfds);
|
VIR_FREE(item->pollfds);
|
||||||
@ -856,9 +842,8 @@ esxVI_MultiCURL_Wait(esxVI_MultiCURL *multi, int *runningHandles)
|
|||||||
|
|
||||||
curl_multi_timeout(multi->handle, &timeout);
|
curl_multi_timeout(multi->handle, &timeout);
|
||||||
|
|
||||||
if (timeout < 0) {
|
if (timeout < 0)
|
||||||
timeout = 1000; /* default to 1 sec timeout */
|
timeout = 1000; /* default to 1 sec timeout */
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
rc = poll(multi->pollfds, multi->npollfds, timeout);
|
rc = poll(multi->pollfds, multi->npollfds, timeout);
|
||||||
@ -980,9 +965,8 @@ ESX_VI__TEMPLATE__ALLOC(Context)
|
|||||||
/* esxVI_Context_Free */
|
/* esxVI_Context_Free */
|
||||||
ESX_VI__TEMPLATE__FREE(Context,
|
ESX_VI__TEMPLATE__FREE(Context,
|
||||||
{
|
{
|
||||||
if (item->sessionLock) {
|
if (item->sessionLock)
|
||||||
virMutexDestroy(item->sessionLock);
|
virMutexDestroy(item->sessionLock);
|
||||||
}
|
|
||||||
|
|
||||||
esxVI_CURL_Free(&item->curl);
|
esxVI_CURL_Free(&item->curl);
|
||||||
VIR_FREE(item->url);
|
VIR_FREE(item->url);
|
||||||
@ -1036,9 +1020,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0) {
|
if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (STRNEQ(ctx->service->about->apiType, "HostAgent") &&
|
if (STRNEQ(ctx->service->about->apiType, "HostAgent") &&
|
||||||
STRNEQ(ctx->service->about->apiType, "VirtualCenter")) {
|
STRNEQ(ctx->service->about->apiType, "VirtualCenter")) {
|
||||||
@ -1121,9 +1104,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
|
|||||||
ctx->hasQueryVirtualDiskUuid = true;
|
ctx->hasQueryVirtualDiskUuid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->productLine == esxVI_ProductLine_VPX) {
|
if (ctx->productLine == esxVI_ProductLine_VPX)
|
||||||
ctx->hasSessionIsActive = true;
|
ctx->hasSessionIsActive = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (esxVI_Login(ctx, username, password, NULL, &ctx->session) < 0 ||
|
if (esxVI_Login(ctx, username, password, NULL, &ctx->session) < 0 ||
|
||||||
esxVI_BuildSelectSetCollection(ctx) < 0) {
|
esxVI_BuildSelectSetCollection(ctx) < 0) {
|
||||||
@ -1212,9 +1194,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
/* It's a folder, use it as new lookup root */
|
/* It's a folder, use it as new lookup root */
|
||||||
if (root != ctx->service->rootFolder) {
|
if (root != ctx->service->rootFolder)
|
||||||
esxVI_ManagedObjectReference_Free(&root);
|
esxVI_ManagedObjectReference_Free(&root);
|
||||||
}
|
|
||||||
|
|
||||||
root = folder->_reference;
|
root = folder->_reference;
|
||||||
folder->_reference = NULL;
|
folder->_reference = NULL;
|
||||||
@ -1227,9 +1208,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build datacenter path */
|
/* Build datacenter path */
|
||||||
if (virBufferUse(&buffer) > 0) {
|
if (virBufferUse(&buffer) > 0)
|
||||||
virBufferAddChar(&buffer, '/');
|
virBufferAddChar(&buffer, '/');
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdd(&buffer, item, -1);
|
virBufferAdd(&buffer, item, -1);
|
||||||
|
|
||||||
@ -1255,9 +1235,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root != ctx->service->rootFolder) {
|
if (root != ctx->service->rootFolder)
|
||||||
esxVI_ManagedObjectReference_Free(&root);
|
esxVI_ManagedObjectReference_Free(&root);
|
||||||
}
|
|
||||||
|
|
||||||
root = ctx->datacenter->hostFolder;
|
root = ctx->datacenter->hostFolder;
|
||||||
|
|
||||||
@ -1272,9 +1251,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
/* It's a folder, use it as new lookup root */
|
/* It's a folder, use it as new lookup root */
|
||||||
if (root != ctx->datacenter->hostFolder) {
|
if (root != ctx->datacenter->hostFolder)
|
||||||
esxVI_ManagedObjectReference_Free(&root);
|
esxVI_ManagedObjectReference_Free(&root);
|
||||||
}
|
|
||||||
|
|
||||||
root = folder->_reference;
|
root = folder->_reference;
|
||||||
folder->_reference = NULL;
|
folder->_reference = NULL;
|
||||||
@ -1288,9 +1266,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build compute resource path */
|
/* Build compute resource path */
|
||||||
if (virBufferUse(&buffer) > 0) {
|
if (virBufferUse(&buffer) > 0)
|
||||||
virBufferAddChar(&buffer, '/');
|
virBufferAddChar(&buffer, '/');
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdd(&buffer, item, -1);
|
virBufferAdd(&buffer, item, -1);
|
||||||
|
|
||||||
@ -1355,9 +1332,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
virBufferFreeAndReset(&buffer);
|
virBufferFreeAndReset(&buffer);
|
||||||
}
|
|
||||||
|
|
||||||
if (root != ctx->service->rootFolder &&
|
if (root != ctx->service->rootFolder &&
|
||||||
(!ctx->datacenter || root != ctx->datacenter->hostFolder)) {
|
(!ctx->datacenter || root != ctx->datacenter->hostFolder)) {
|
||||||
@ -1431,9 +1407,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_Response_Alloc(response) < 0) {
|
if (esxVI_Response_Alloc(response) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
virMutexLock(&ctx->curl->lock);
|
virMutexLock(&ctx->curl->lock);
|
||||||
|
|
||||||
@ -1448,9 +1423,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
|
|||||||
|
|
||||||
virMutexUnlock(&ctx->curl->lock);
|
virMutexUnlock(&ctx->curl->lock);
|
||||||
|
|
||||||
if ((*response)->responseCode < 0) {
|
if ((*response)->responseCode < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virBufferCheckError(&buffer) < 0)
|
if (virBufferCheckError(&buffer) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1462,9 +1436,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
|
|||||||
_("(esx execute response)"),
|
_("(esx execute response)"),
|
||||||
&xpathContext);
|
&xpathContext);
|
||||||
|
|
||||||
if (!(*response)->document) {
|
if (!(*response)->document)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
xmlXPathRegisterNs(xpathContext, BAD_CAST "soapenv",
|
xmlXPathRegisterNs(xpathContext, BAD_CAST "soapenv",
|
||||||
BAD_CAST "http://schemas.xmlsoap.org/soap/envelope/");
|
BAD_CAST "http://schemas.xmlsoap.org/soap/envelope/");
|
||||||
@ -1710,9 +1683,8 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration,
|
|||||||
|
|
||||||
*value = 0; /* undefined */
|
*value = 0; /* undefined */
|
||||||
|
|
||||||
if (esxVI_String_DeserializeValue(node, &name) < 0) {
|
if (esxVI_String_DeserializeValue(node, &name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; enumeration->values[i].name; ++i) {
|
for (i = 0; enumeration->values[i].name; ++i) {
|
||||||
if (STREQ(name, enumeration->values[i].name)) {
|
if (STREQ(name, enumeration->values[i].name)) {
|
||||||
@ -1755,9 +1727,8 @@ esxVI_List_Append(esxVI_List **list, esxVI_List *item)
|
|||||||
|
|
||||||
next = *list;
|
next = *list;
|
||||||
|
|
||||||
while (next->_next) {
|
while (next->_next)
|
||||||
next = next->_next;
|
next = next->_next;
|
||||||
}
|
|
||||||
|
|
||||||
next->_next = item;
|
next->_next = item;
|
||||||
|
|
||||||
@ -1810,9 +1781,8 @@ esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List **list,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!anyType) {
|
if (!anyType)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (! STRPREFIX(anyType->other, "ArrayOf")) {
|
if (! STRPREFIX(anyType->other, "ArrayOf")) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1865,14 +1835,12 @@ esxVI_List_Serialize(esxVI_List *list, const char *element,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!list) {
|
if (!list)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
for (item = list; item; item = item->_next) {
|
for (item = list; item; item = item->_next) {
|
||||||
if (serializeFunc(item, element, output) < 0) {
|
if (serializeFunc(item, element, output) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1890,9 +1858,8 @@ esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node) {
|
if (!node)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
for (; node; node = node->next) {
|
for (; node; node = node->next) {
|
||||||
if (node->type != XML_ELEMENT_NODE) {
|
if (node->type != XML_ELEMENT_NODE) {
|
||||||
@ -2193,9 +2160,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) {
|
if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
objectSpec->obj = root;
|
objectSpec->obj = root;
|
||||||
objectSpec->skip = esxVI_Boolean_False;
|
objectSpec->skip = esxVI_Boolean_False;
|
||||||
@ -2254,9 +2220,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) {
|
if (esxVI_PropertySpec_Alloc(&propertySpec) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
propertySpec->type = (char *)type;
|
propertySpec->type = (char *)type;
|
||||||
propertySpec->pathSet = propertyNameList;
|
propertySpec->pathSet = propertyNameList;
|
||||||
@ -2325,13 +2290,11 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
|
|||||||
propertySpec->pathSet = NULL;
|
propertySpec->pathSet = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!objectSpec_isAppended) {
|
if (!objectSpec_isAppended)
|
||||||
esxVI_ObjectSpec_Free(&objectSpec);
|
esxVI_ObjectSpec_Free(&objectSpec);
|
||||||
}
|
|
||||||
|
|
||||||
if (!propertySpec_isAppended) {
|
if (!propertySpec_isAppended)
|
||||||
esxVI_PropertySpec_Free(&propertySpec);
|
esxVI_PropertySpec_Free(&propertySpec);
|
||||||
}
|
|
||||||
|
|
||||||
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
|
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
|
||||||
|
|
||||||
@ -2463,9 +2426,8 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
|
|||||||
for (dynamicProperty = objectContent->propSet; dynamicProperty;
|
for (dynamicProperty = objectContent->propSet; dynamicProperty;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, propertyName)) {
|
if (STREQ(dynamicProperty->name, propertyName)) {
|
||||||
if (esxVI_Long_CastFromAnyType(dynamicProperty->val, value) < 0) {
|
if (esxVI_Long_CastFromAnyType(dynamicProperty->val, value) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2709,9 +2671,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
if (name) {
|
if (name)
|
||||||
VIR_FREE(*name);
|
VIR_FREE(*name);
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2760,9 +2721,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count >= nameslen) {
|
if (count >= nameslen)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (recurse) {
|
if (recurse) {
|
||||||
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
|
result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList,
|
||||||
@ -2770,9 +2730,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
|||||||
nameslen - count,
|
nameslen - count,
|
||||||
true, leaves);
|
true, leaves);
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
|
||||||
|
|
||||||
count += result;
|
count += result;
|
||||||
}
|
}
|
||||||
@ -2781,9 +2740,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
|
|||||||
return count;
|
return count;
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i)
|
||||||
VIR_FREE(names[i]);
|
VIR_FREE(names[i]);
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2817,9 +2775,8 @@ esxVI_GetSnapshotTreeByName
|
|||||||
if (esxVI_GetSnapshotTreeByName(candidate->childSnapshotList, name,
|
if (esxVI_GetSnapshotTreeByName(candidate->childSnapshotList, name,
|
||||||
snapshotTree, snapshotTreeParent,
|
snapshotTree, snapshotTreeParent,
|
||||||
occurrence) > 0) {
|
occurrence) > 0) {
|
||||||
if (snapshotTreeParent && !(*snapshotTreeParent)) {
|
if (snapshotTreeParent && !(*snapshotTreeParent))
|
||||||
*snapshotTreeParent = candidate;
|
*snapshotTreeParent = candidate;
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -2987,13 +2944,11 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, const char *name,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ(name, name_candidate)) {
|
if (STRNEQ(name, name_candidate))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (esxVI_ObjectContent_DeepCopy(virtualMachine, candidate) < 0) {
|
if (esxVI_ObjectContent_DeepCopy(virtualMachine, candidate) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3126,9 +3081,8 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ(name_candidate, name)) {
|
if (STREQ(name_candidate, name)) {
|
||||||
if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) {
|
if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* Found datastore with matching name */
|
/* Found datastore with matching name */
|
||||||
result = 0;
|
result = 0;
|
||||||
@ -3199,9 +3153,8 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!datastoreHostMountList) {
|
if (!datastoreHostMountList)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
for (datastoreHostMount = datastoreHostMountList;
|
for (datastoreHostMount = datastoreHostMountList;
|
||||||
datastoreHostMount;
|
datastoreHostMount;
|
||||||
@ -3212,9 +3165,8 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (STRPREFIX(absolutePath, datastoreHostMount->mountInfo->path)) {
|
if (STRPREFIX(absolutePath, datastoreHostMount->mountInfo->path)) {
|
||||||
if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) {
|
if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* Found datastore with matching mount path */
|
/* Found datastore with matching mount path */
|
||||||
result = 0;
|
result = 0;
|
||||||
@ -3284,13 +3236,11 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx,
|
|||||||
|
|
||||||
for (candidate = hostMountList; candidate;
|
for (candidate = hostMountList; candidate;
|
||||||
candidate = candidate->_next) {
|
candidate = candidate->_next) {
|
||||||
if (STRNEQ(ctx->hostSystem->_reference->value, candidate->key->value)) {
|
if (STRNEQ(ctx->hostSystem->_reference->value, candidate->key->value))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (esxVI_DatastoreHostMount_DeepCopy(hostMount, candidate) < 0) {
|
if (esxVI_DatastoreHostMount_DeepCopy(hostMount, candidate) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3392,9 +3342,8 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine
|
|||||||
/* Lookup task info for each task */
|
/* Lookup task info for each task */
|
||||||
for (recentTask = recentTaskList; recentTask;
|
for (recentTask = recentTaskList; recentTask;
|
||||||
recentTask = recentTask->_next) {
|
recentTask = recentTask->_next) {
|
||||||
if (esxVI_LookupTaskInfoByTask(ctx, recentTask, &taskInfo) < 0) {
|
if (esxVI_LookupTaskInfoByTask(ctx, recentTask, &taskInfo) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (taskInfo->state == esxVI_TaskInfoState_Queued ||
|
if (taskInfo->state == esxVI_TaskInfoState_Queued ||
|
||||||
taskInfo->state == esxVI_TaskInfoState_Running) {
|
taskInfo->state == esxVI_TaskInfoState_Running) {
|
||||||
@ -3412,9 +3361,8 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
esxVI_TaskInfo_Free(pendingTaskInfoList);
|
esxVI_TaskInfo_Free(pendingTaskInfoList);
|
||||||
}
|
|
||||||
|
|
||||||
esxVI_String_Free(&propertyNameList);
|
esxVI_String_Free(&propertyNameList);
|
||||||
esxVI_ManagedObjectReference_Free(&recentTaskList);
|
esxVI_ManagedObjectReference_Free(&recentTaskList);
|
||||||
@ -3509,9 +3457,8 @@ esxVI_LookupRootSnapshotTreeList
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
esxVI_VirtualMachineSnapshotTree_Free(rootSnapshotTreeList);
|
esxVI_VirtualMachineSnapshotTree_Free(rootSnapshotTreeList);
|
||||||
}
|
|
||||||
|
|
||||||
esxVI_String_Free(&propertyNameList);
|
esxVI_String_Free(&propertyNameList);
|
||||||
esxVI_ObjectContent_Free(&virtualMachine);
|
esxVI_ObjectContent_Free(&virtualMachine);
|
||||||
@ -3651,9 +3598,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
|
|||||||
datastoreName) < 0)
|
datastoreName) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_STRDUP(fileName, directoryAndFileName) < 0) {
|
if (VIR_STRDUP(fileName, directoryAndFileName) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s",
|
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s",
|
||||||
datastoreName, directoryName) < 0)
|
datastoreName, directoryName) < 0)
|
||||||
@ -3669,9 +3615,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0) {
|
if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lookup HostDatastoreBrowser */
|
/* Lookup HostDatastoreBrowser */
|
||||||
@ -3736,9 +3681,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
|
|||||||
floppyImageFileQuery = NULL;
|
floppyImageFileQuery = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_String_Alloc(&searchSpec->matchPattern) < 0) {
|
if (esxVI_String_Alloc(&searchSpec->matchPattern) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
searchSpec->matchPattern->value = fileName;
|
searchSpec->matchPattern->value = fileName;
|
||||||
|
|
||||||
@ -3786,9 +3730,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
/* Don't double free fileName */
|
/* Don't double free fileName */
|
||||||
if (searchSpec && searchSpec->matchPattern) {
|
if (searchSpec && searchSpec->matchPattern)
|
||||||
searchSpec->matchPattern->value = NULL;
|
searchSpec->matchPattern->value = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(datastoreName);
|
VIR_FREE(datastoreName);
|
||||||
VIR_FREE(directoryName);
|
VIR_FREE(directoryName);
|
||||||
@ -3967,17 +3910,15 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx,
|
|||||||
if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0)
|
if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (esxUtil_ReformatUuid(uuid_string, *key) < 0) {
|
if (esxUtil_ReformatUuid(uuid_string, *key) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*key)) {
|
if (!(*key)) {
|
||||||
/* Other files don't have a UUID, fall back to the path as 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;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
@ -4157,17 +4098,15 @@ esxVI_LookupPhysicalNicByName(esxVI_Context *ctx, const char *name,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) {
|
if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* Search for a matching physical NIC */
|
/* Search for a matching physical NIC */
|
||||||
for (candidate = physicalNicList; candidate;
|
for (candidate = physicalNicList; candidate;
|
||||||
candidate = candidate->_next) {
|
candidate = candidate->_next) {
|
||||||
if (STRCASEEQ(candidate->device, name)) {
|
if (STRCASEEQ(candidate->device, name)) {
|
||||||
if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) {
|
if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* Found physical NIC with matching name */
|
/* Found physical NIC with matching name */
|
||||||
result = 0;
|
result = 0;
|
||||||
@ -4206,17 +4145,15 @@ esxVI_LookupPhysicalNicByMACAddress(esxVI_Context *ctx, const char *mac,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) {
|
if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* Search for a matching physical NIC */
|
/* Search for a matching physical NIC */
|
||||||
for (candidate = physicalNicList; candidate;
|
for (candidate = physicalNicList; candidate;
|
||||||
candidate = candidate->_next) {
|
candidate = candidate->_next) {
|
||||||
if (STRCASEEQ(candidate->mac, mac)) {
|
if (STRCASEEQ(candidate->mac, mac)) {
|
||||||
if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) {
|
if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* Found physical NIC with matching MAC address */
|
/* Found physical NIC with matching MAC address */
|
||||||
result = 0;
|
result = 0;
|
||||||
@ -4299,9 +4236,8 @@ esxVI_LookupHostVirtualSwitchByName(esxVI_Context *ctx, const char *name,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0) {
|
if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* Search for a matching HostVirtualSwitch */
|
/* Search for a matching HostVirtualSwitch */
|
||||||
for (candidate = hostVirtualSwitchList; candidate;
|
for (candidate = hostVirtualSwitchList; candidate;
|
||||||
@ -4421,9 +4357,8 @@ esxVI_HandleVirtualMachineQuestion
|
|||||||
elementDescription = elementDescription->_next) {
|
elementDescription = elementDescription->_next) {
|
||||||
virBufferAsprintf(&buffer, "'%s'", elementDescription->label);
|
virBufferAsprintf(&buffer, "'%s'", elementDescription->label);
|
||||||
|
|
||||||
if (elementDescription->_next) {
|
if (elementDescription->_next)
|
||||||
virBufferAddLit(&buffer, ", ");
|
virBufferAddLit(&buffer, ", ");
|
||||||
}
|
|
||||||
|
|
||||||
if (!answerChoice &&
|
if (!answerChoice &&
|
||||||
questionInfo->choice->defaultIndex &&
|
questionInfo->choice->defaultIndex &&
|
||||||
@ -4489,9 +4424,8 @@ esxVI_HandleVirtualMachineQuestion
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
virBufferFreeAndReset(&buffer);
|
virBufferFreeAndReset(&buffer);
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(possibleAnswers);
|
VIR_FREE(possibleAnswers);
|
||||||
|
|
||||||
@ -4533,16 +4467,14 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
|
|||||||
if (VIR_STRDUP(version, "") < 0)
|
if (VIR_STRDUP(version, "") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) {
|
if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
objectSpec->obj = task;
|
objectSpec->obj = task;
|
||||||
objectSpec->skip = esxVI_Boolean_False;
|
objectSpec->skip = esxVI_Boolean_False;
|
||||||
|
|
||||||
if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) {
|
if (esxVI_PropertySpec_Alloc(&propertySpec) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
propertySpec->type = task->type;
|
propertySpec->type = task->type;
|
||||||
|
|
||||||
@ -4581,9 +4513,8 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
|
|||||||
* esxVI_LookupTaskInfoByTask() and esxVI_CancelTask()
|
* esxVI_LookupTaskInfoByTask() and esxVI_CancelTask()
|
||||||
* don't overwrite the actual error
|
* don't overwrite the actual error
|
||||||
*/
|
*/
|
||||||
if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) {
|
if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (taskInfo->cancelable == esxVI_Boolean_True) {
|
if (taskInfo->cancelable == esxVI_Boolean_True) {
|
||||||
if (esxVI_CancelTask(ctx, task) < 0 && blocked) {
|
if (esxVI_CancelTask(ctx, task) < 0 && blocked) {
|
||||||
@ -4602,17 +4533,15 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_WaitForUpdates(ctx, version, &updateSet) < 0) {
|
if (esxVI_WaitForUpdates(ctx, version, &updateSet) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(version);
|
VIR_FREE(version);
|
||||||
if (VIR_STRDUP(version, updateSet->version) < 0)
|
if (VIR_STRDUP(version, updateSet->version) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!updateSet->filterSet) {
|
if (!updateSet->filterSet)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
for (propertyFilterUpdate = updateSet->filterSet;
|
for (propertyFilterUpdate = updateSet->filterSet;
|
||||||
propertyFilterUpdate;
|
propertyFilterUpdate;
|
||||||
@ -4634,27 +4563,22 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!propertyValue) {
|
if (!propertyValue)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, &state) < 0) {
|
if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, &state) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_DestroyPropertyFilter(ctx, propertyFilter) < 0) {
|
if (esxVI_DestroyPropertyFilter(ctx, propertyFilter) < 0)
|
||||||
VIR_DEBUG("DestroyPropertyFilter failed");
|
VIR_DEBUG("DestroyPropertyFilter failed");
|
||||||
}
|
|
||||||
|
|
||||||
if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, finalState) < 0) {
|
if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, finalState) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (*finalState != esxVI_TaskInfoState_Success) {
|
if (*finalState != esxVI_TaskInfoState_Success) {
|
||||||
if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) {
|
if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (!taskInfo->error) {
|
if (!taskInfo->error) {
|
||||||
if (VIR_STRDUP(*errorMessage, _("Unknown error")) < 0)
|
if (VIR_STRDUP(*errorMessage, _("Unknown error")) < 0)
|
||||||
@ -4677,21 +4601,17 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
|
|||||||
* Remove values given by the caller from the data structures to prevent
|
* Remove values given by the caller from the data structures to prevent
|
||||||
* them from being freed by the call to esxVI_PropertyFilterSpec_Free().
|
* them from being freed by the call to esxVI_PropertyFilterSpec_Free().
|
||||||
*/
|
*/
|
||||||
if (objectSpec) {
|
if (objectSpec)
|
||||||
objectSpec->obj = NULL;
|
objectSpec->obj = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (propertySpec) {
|
if (propertySpec)
|
||||||
propertySpec->type = NULL;
|
propertySpec->type = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (!objectSpec_isAppended) {
|
if (!objectSpec_isAppended)
|
||||||
esxVI_ObjectSpec_Free(&objectSpec);
|
esxVI_ObjectSpec_Free(&objectSpec);
|
||||||
}
|
|
||||||
|
|
||||||
if (!propertySpec_isAppended) {
|
if (!propertySpec_isAppended)
|
||||||
esxVI_PropertySpec_Free(&propertySpec);
|
esxVI_PropertySpec_Free(&propertySpec);
|
||||||
}
|
|
||||||
|
|
||||||
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
|
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
|
||||||
esxVI_ManagedObjectReference_Free(&propertyFilter);
|
esxVI_ManagedObjectReference_Free(&propertyFilter);
|
||||||
@ -4849,9 +4769,8 @@ esxVI_LookupHostInternetScsiHbaStaticTargetByName
|
|||||||
|
|
||||||
for (candidate = hostInternetScsiHba->configuredStaticTarget;
|
for (candidate = hostInternetScsiHba->configuredStaticTarget;
|
||||||
candidate; candidate = candidate->_next) {
|
candidate; candidate = candidate->_next) {
|
||||||
if (STREQ(candidate->iScsiName, name)) {
|
if (STREQ(candidate->iScsiName, name))
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!candidate) {
|
if (!candidate) {
|
||||||
@ -4863,9 +4782,8 @@ esxVI_LookupHostInternetScsiHbaStaticTargetByName
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_HostInternetScsiHbaStaticTarget_DeepCopy(target, candidate) < 0) {
|
if (esxVI_HostInternetScsiHbaStaticTarget_DeepCopy(target, candidate) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
@ -5044,9 +4962,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found || !hostScsiTopologyTarget) {
|
if (!found || !hostScsiTopologyTarget)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (!hostScsiTopologyTarget->lun) {
|
if (!hostScsiTopologyTarget->lun) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@ -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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
{
|
{
|
||||||
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,
|
|||||||
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)
|
|||||||
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,
|
|||||||
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)
|
|||||||
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,
|
|||||||
|
|
||||||
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)
|
|||||||
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
|
|||||||
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
|
|||||||
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");
|
||||||
|
Loading…
Reference in New Issue
Block a user