提交 a9e96b1e 编写于 作者: M Matthias Bolte 提交者: Daniel Veillard

Cleanup structure name naming

* src/esx/esx_driver.c src/esx/esx_util.[ch] src/esx/esx_vi.[ch]:
  just a name change
上级 5f48643e
...@@ -56,11 +56,11 @@ static int esxDomainGetMaxVcpus(virDomainPtr domain); ...@@ -56,11 +56,11 @@ static int esxDomainGetMaxVcpus(virDomainPtr domain);
typedef struct _esxPrivate { typedef struct _esxPrivate {
esxVI_Context *host; esxVI_Context *host;
esxVI_Context *vcenter; esxVI_Context *vCenter;
int phantom; // boolean int phantom; // boolean
char *transport; char *transport;
int32_t nvcpus_max; int32_t maxVcpus;
esxVI_Boolean supports_vmotion; esxVI_Boolean supportsVMotion;
int32_t usedCpuTimeCounterId; int32_t usedCpuTimeCounterId;
} esxPrivate; } esxPrivate;
...@@ -94,9 +94,9 @@ static virDrvOpenStatus ...@@ -94,9 +94,9 @@ static virDrvOpenStatus
esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
{ {
esxPrivate *priv = NULL; esxPrivate *priv = NULL;
char dummy_string[NI_MAXHOST] = ""; char ipAddress[NI_MAXHOST] = "";
char *url = NULL; char *url = NULL;
char *vcenter = NULL; char *vCenter = NULL;
int noVerify = 0; // boolean int noVerify = 0; // boolean
char *username = NULL; char *username = NULL;
char *password = NULL; char *password = NULL;
...@@ -133,24 +133,24 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) ...@@ -133,24 +133,24 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
} }
priv->phantom = phantom; priv->phantom = phantom;
priv->nvcpus_max = -1; priv->maxVcpus = -1;
priv->supports_vmotion = esxVI_Boolean_Undefined; priv->supportsVMotion = esxVI_Boolean_Undefined;
priv->usedCpuTimeCounterId = -1; priv->usedCpuTimeCounterId = -1;
/* Request credentials and login to non-phantom host/vCenter */ /* Request credentials and login to non-phantom host/vCenter */
if (! phantom) { if (! phantom) {
if (esxUtil_ParseQuery(conn, &priv->transport, &vcenter, if (esxUtil_ParseQuery(conn, &priv->transport, &vCenter,
&noVerify) < 0) { &noVerify) < 0) {
goto failure; goto failure;
} }
if (esxUtil_ResolveHostname(conn, conn->uri->server, dummy_string, if (esxUtil_ResolveHostname(conn, conn->uri->server, ipAddress,
NI_MAXHOST) < 0) { NI_MAXHOST) < 0) {
goto failure; goto failure;
} }
if (vcenter != NULL && if (vCenter != NULL &&
esxUtil_ResolveHostname(conn, vcenter, dummy_string, esxUtil_ResolveHostname(conn, vCenter, ipAddress,
NI_MAXHOST) < 0) { NI_MAXHOST) < 0) {
goto failure; goto failure;
} }
...@@ -235,18 +235,18 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) ...@@ -235,18 +235,18 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
VIR_FREE(password); VIR_FREE(password);
VIR_FREE(username); VIR_FREE(username);
if (vcenter != NULL) { if (vCenter != NULL) {
if (virAsprintf(&url, "%s://%s/sdk", priv->transport, if (virAsprintf(&url, "%s://%s/sdk", priv->transport,
vcenter) < 0) { vCenter) < 0) {
virReportOOMError(conn); virReportOOMError(conn);
goto failure; goto failure;
} }
if (esxVI_Context_Alloc(conn, &priv->vcenter) < 0) { if (esxVI_Context_Alloc(conn, &priv->vCenter) < 0) {
goto failure; goto failure;
} }
username = esxUtil_RequestUsername(auth, "administrator", vcenter); username = esxUtil_RequestUsername(auth, "administrator", vCenter);
if (username == NULL) { if (username == NULL) {
ESX_ERROR(conn, VIR_ERR_AUTH_FAILED, ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
...@@ -254,7 +254,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) ...@@ -254,7 +254,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto failure; goto failure;
} }
password = esxUtil_RequestPassword(auth, username, vcenter); password = esxUtil_RequestPassword(auth, username, vCenter);
if (password == NULL) { if (password == NULL) {
ESX_ERROR(conn, VIR_ERR_AUTH_FAILED, ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
...@@ -262,13 +262,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) ...@@ -262,13 +262,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto failure; goto failure;
} }
if (esxVI_Context_Connect(conn, priv->vcenter, url, username, if (esxVI_Context_Connect(conn, priv->vCenter, url, username,
password, noVerify) < 0) { password, noVerify) < 0) {
goto failure; goto failure;
} }
if (priv->vcenter->productVersion != esxVI_ProductVersion_VPX25 && if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
priv->vcenter->productVersion != esxVI_ProductVersion_VPX40) { priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"%s is neither a vCenter 2.5 server nor a vCenter " "%s is neither a vCenter 2.5 server nor a vCenter "
"4.0 server", "4.0 server",
...@@ -281,7 +281,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) ...@@ -281,7 +281,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
VIR_FREE(username); VIR_FREE(username);
} }
VIR_FREE(vcenter); VIR_FREE(vCenter);
} }
conn->privateData = priv; conn->privateData = priv;
...@@ -290,13 +290,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) ...@@ -290,13 +290,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
failure: failure:
VIR_FREE(url); VIR_FREE(url);
VIR_FREE(vcenter); VIR_FREE(vCenter);
VIR_FREE(password); VIR_FREE(password);
VIR_FREE(username); VIR_FREE(username);
if (priv != NULL) { if (priv != NULL) {
esxVI_Context_Free(&priv->host); esxVI_Context_Free(&priv->host);
esxVI_Context_Free(&priv->vcenter); esxVI_Context_Free(&priv->vCenter);
VIR_FREE(priv->transport); VIR_FREE(priv->transport);
VIR_FREE(priv); VIR_FREE(priv);
...@@ -318,11 +318,11 @@ esxClose(virConnectPtr conn) ...@@ -318,11 +318,11 @@ esxClose(virConnectPtr conn)
esxVI_Logout(conn, priv->host); esxVI_Logout(conn, priv->host);
esxVI_Context_Free(&priv->host); esxVI_Context_Free(&priv->host);
if (priv->vcenter != NULL) { if (priv->vCenter != NULL) {
esxVI_EnsureSession(conn, priv->vcenter); esxVI_EnsureSession(conn, priv->vCenter);
esxVI_Logout(conn, priv->vcenter); esxVI_Logout(conn, priv->vCenter);
esxVI_Context_Free(&priv->vcenter); esxVI_Context_Free(&priv->vCenter);
} }
} }
...@@ -350,8 +350,8 @@ esxSupportsVMotion(virConnectPtr conn) ...@@ -350,8 +350,8 @@ esxSupportsVMotion(virConnectPtr conn)
goto failure; goto failure;
} }
if (priv->supports_vmotion != esxVI_Boolean_Undefined) { if (priv->supportsVMotion != esxVI_Boolean_Undefined) {
return priv->supports_vmotion; return priv->supportsVMotion;
} }
if (esxVI_EnsureSession(conn, priv->host) < 0) { if (esxVI_EnsureSession(conn, priv->host) < 0) {
...@@ -380,7 +380,7 @@ esxSupportsVMotion(virConnectPtr conn) ...@@ -380,7 +380,7 @@ esxSupportsVMotion(virConnectPtr conn)
goto failure; goto failure;
} }
priv->supports_vmotion = dynamicProperty->val->boolean; priv->supportsVMotion = dynamicProperty->val->boolean;
break; break;
} else { } else {
VIR_WARN("Unexpected '%s' property", dynamicProperty->name); VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
...@@ -391,10 +391,10 @@ esxSupportsVMotion(virConnectPtr conn) ...@@ -391,10 +391,10 @@ esxSupportsVMotion(virConnectPtr conn)
esxVI_String_Free(&propertyNameList); esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&hostSystem); esxVI_ObjectContent_Free(&hostSystem);
return priv->supports_vmotion; return priv->supportsVMotion;
failure: failure:
priv->supports_vmotion = esxVI_Boolean_Undefined; priv->supportsVMotion = esxVI_Boolean_Undefined;
goto cleanup; goto cleanup;
} }
...@@ -405,7 +405,7 @@ static int ...@@ -405,7 +405,7 @@ static int
esxSupportsFeature(virConnectPtr conn, int feature) esxSupportsFeature(virConnectPtr conn, int feature)
{ {
esxPrivate *priv = (esxPrivate *)conn->privateData; esxPrivate *priv = (esxPrivate *)conn->privateData;
esxVI_Boolean supports_vmotion = esxVI_Boolean_Undefined; esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined;
if (priv->phantom) { if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID, ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
...@@ -415,18 +415,15 @@ esxSupportsFeature(virConnectPtr conn, int feature) ...@@ -415,18 +415,15 @@ esxSupportsFeature(virConnectPtr conn, int feature)
switch (feature) { switch (feature) {
case VIR_DRV_FEATURE_MIGRATION_V1: case VIR_DRV_FEATURE_MIGRATION_V1:
supports_vmotion = esxSupportsVMotion(conn); supportsVMotion = esxSupportsVMotion(conn);
if (supports_vmotion == esxVI_Boolean_Undefined) { if (supportsVMotion == esxVI_Boolean_Undefined) {
return -1; return -1;
} }
/* /* Migration is only possible via a vCenter and if VMotion is enabled */
* Migration is only possible via a Virtual Center and if VMotion is return priv->vCenter != NULL &&
* enabled supportsVMotion == esxVI_Boolean_True ? 1 : 0;
*/
return priv->vcenter != NULL &&
supports_vmotion == esxVI_Boolean_True ? 1 : 0;
default: default:
return 0; return 0;
...@@ -838,9 +835,9 @@ esxDomainLookupByID(virConnectPtr conn, int id) ...@@ -838,9 +835,9 @@ esxDomainLookupByID(virConnectPtr conn, int id)
esxVI_ObjectContent *virtualMachineList = NULL; esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *virtualMachine = NULL; esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState; esxVI_VirtualMachinePowerState powerState;
int id_ = -1; int id_candidate = -1;
char *name_ = NULL; char *name_candidate = NULL;
unsigned char uuid_[VIR_UUID_BUFLEN]; unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL; virDomainPtr domain = NULL;
if (priv->phantom) { if (priv->phantom) {
...@@ -875,18 +872,19 @@ esxDomainLookupByID(virConnectPtr conn, int id) ...@@ -875,18 +872,19 @@ esxDomainLookupByID(virConnectPtr conn, int id)
continue; continue;
} }
VIR_FREE(name_); VIR_FREE(name_candidate);
if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine, &id_, if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine,
&name_, uuid_) < 0) { &id_candidate, &name_candidate,
uuid_candidate) < 0) {
goto failure; goto failure;
} }
if (id_ != id) { if (id != id_candidate) {
continue; continue;
} }
domain = virGetDomain(conn, name_, uuid_); domain = virGetDomain(conn, name_candidate, uuid_candidate);
if (domain == NULL) { if (domain == NULL) {
goto failure; goto failure;
...@@ -904,7 +902,7 @@ esxDomainLookupByID(virConnectPtr conn, int id) ...@@ -904,7 +902,7 @@ esxDomainLookupByID(virConnectPtr conn, int id)
cleanup: cleanup:
esxVI_String_Free(&propertyNameList); esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList); esxVI_ObjectContent_Free(&virtualMachineList);
VIR_FREE(name_); VIR_FREE(name_candidate);
return domain; return domain;
...@@ -924,9 +922,9 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) ...@@ -924,9 +922,9 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
esxVI_ObjectContent *virtualMachineList = NULL; esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *virtualMachine = NULL; esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState; esxVI_VirtualMachinePowerState powerState;
int id_ = -1; int id_candidate = -1;
char *name_ = NULL; char *name_candidate = NULL;
unsigned char uuid_[VIR_UUID_BUFLEN]; unsigned char uuid_candidate[VIR_UUID_BUFLEN];
char uuid_string[VIR_UUID_STRING_BUFLEN]; char uuid_string[VIR_UUID_STRING_BUFLEN];
virDomainPtr domain = NULL; virDomainPtr domain = NULL;
...@@ -952,19 +950,20 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) ...@@ -952,19 +950,20 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
for (virtualMachine = virtualMachineList; virtualMachine != NULL; for (virtualMachine = virtualMachineList; virtualMachine != NULL;
virtualMachine = virtualMachine->_next) { virtualMachine = virtualMachine->_next) {
VIR_FREE(name_); VIR_FREE(name_candidate);
if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine, &id_, if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine,
&name_, uuid_) < 0) { &id_candidate, &name_candidate,
uuid_candidate) < 0) {
goto failure; goto failure;
} }
if (memcmp(uuid, uuid_, if (memcmp(uuid, uuid_candidate,
VIR_UUID_BUFLEN * sizeof (unsigned char)) != 0) { VIR_UUID_BUFLEN * sizeof (unsigned char)) != 0) {
continue; continue;
} }
domain = virGetDomain(conn, name_, uuid); domain = virGetDomain(conn, name_candidate, uuid_candidate);
if (domain == NULL) { if (domain == NULL) {
goto failure; goto failure;
...@@ -977,7 +976,7 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) ...@@ -977,7 +976,7 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
/* Only running/suspended virtual machines have an ID != -1 */ /* Only running/suspended virtual machines have an ID != -1 */
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
domain->id = id_; domain->id = id_candidate;
} else { } else {
domain->id = -1; domain->id = -1;
} }
...@@ -995,7 +994,7 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) ...@@ -995,7 +994,7 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
cleanup: cleanup:
esxVI_String_Free(&propertyNameList); esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList); esxVI_ObjectContent_Free(&virtualMachineList);
VIR_FREE(name_); VIR_FREE(name_candidate);
return domain; return domain;
...@@ -1015,9 +1014,9 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) ...@@ -1015,9 +1014,9 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
esxVI_ObjectContent *virtualMachineList = NULL; esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *virtualMachine = NULL; esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState; esxVI_VirtualMachinePowerState powerState;
int id_ = -1; int id_candidate = -1;
char *name_ = NULL; char *name_candidate = NULL;
unsigned char uuid_[VIR_UUID_BUFLEN]; unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL; virDomainPtr domain = NULL;
if (priv->phantom) { if (priv->phantom) {
...@@ -1042,18 +1041,19 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) ...@@ -1042,18 +1041,19 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
for (virtualMachine = virtualMachineList; virtualMachine != NULL; for (virtualMachine = virtualMachineList; virtualMachine != NULL;
virtualMachine = virtualMachine->_next) { virtualMachine = virtualMachine->_next) {
VIR_FREE(name_); VIR_FREE(name_candidate);
if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine, &id_, if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine,
&name_, uuid_) < 0) { &id_candidate, &name_candidate,
uuid_candidate) < 0) {
goto failure; goto failure;
} }
if (STRNEQ(name_, name)) { if (STRNEQ(name, name_candidate)) {
continue; continue;
} }
domain = virGetDomain(conn, name, uuid_); domain = virGetDomain(conn, name_candidate, uuid_candidate);
if (domain == NULL) { if (domain == NULL) {
goto failure; goto failure;
...@@ -1066,7 +1066,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) ...@@ -1066,7 +1066,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
/* Only running/suspended virtual machines have an ID != -1 */ /* Only running/suspended virtual machines have an ID != -1 */
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
domain->id = id_; domain->id = id_candidate;
} else { } else {
domain->id = -1; domain->id = -1;
} }
...@@ -1081,7 +1081,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) ...@@ -1081,7 +1081,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
cleanup: cleanup:
esxVI_String_Free(&propertyNameList); esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList); esxVI_ObjectContent_Free(&virtualMachineList);
VIR_FREE(name_); VIR_FREE(name_candidate);
return domain; return domain;
...@@ -1865,7 +1865,7 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) ...@@ -1865,7 +1865,7 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{ {
int result = 0; int result = 0;
esxPrivate *priv = (esxPrivate *)domain->conn->privateData; esxPrivate *priv = (esxPrivate *)domain->conn->privateData;
int nvcpus_max; int maxVcpus;
esxVI_ObjectContent *virtualMachine = NULL; esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachineConfigSpec *spec = NULL; esxVI_VirtualMachineConfigSpec *spec = NULL;
esxVI_ManagedObjectReference *task = NULL; esxVI_ManagedObjectReference *task = NULL;
...@@ -1887,17 +1887,17 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) ...@@ -1887,17 +1887,17 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
goto failure; goto failure;
} }
nvcpus_max = esxDomainGetMaxVcpus(domain); maxVcpus = esxDomainGetMaxVcpus(domain);
if (nvcpus_max < 0) { if (maxVcpus < 0) {
goto failure; goto failure;
} }
if (nvcpus > nvcpus_max) { if (nvcpus > maxVcpus) {
ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG, ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG,
"Requested number of virtual CPUs is greater than max " "Requested number of virtual CPUs is greater than max "
"allowable number of virtual CPUs for the domain: %d > %d", "allowable number of virtual CPUs for the domain: %d > %d",
nvcpus, nvcpus_max); nvcpus, maxVcpus);
goto failure; goto failure;
} }
...@@ -1953,8 +1953,8 @@ esxDomainGetMaxVcpus(virDomainPtr domain) ...@@ -1953,8 +1953,8 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
goto failure; goto failure;
} }
if (priv->nvcpus_max > 0) { if (priv->maxVcpus > 0) {
return priv->nvcpus_max; return priv->maxVcpus;
} }
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) { if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
...@@ -1984,7 +1984,7 @@ esxDomainGetMaxVcpus(virDomainPtr domain) ...@@ -1984,7 +1984,7 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
goto failure; goto failure;
} }
priv->nvcpus_max = dynamicProperty->val->int32; priv->maxVcpus = dynamicProperty->val->int32;
break; break;
} else { } else {
VIR_WARN("Unexpected '%s' property", dynamicProperty->name); VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
...@@ -1995,10 +1995,10 @@ esxDomainGetMaxVcpus(virDomainPtr domain) ...@@ -1995,10 +1995,10 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
esxVI_String_Free(&propertyNameList); esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&hostSystem); esxVI_ObjectContent_Free(&hostSystem);
return priv->nvcpus_max; return priv->maxVcpus;
failure: failure:
priv->nvcpus_max = -1; priv->maxVcpus = -1;
goto cleanup; goto cleanup;
} }
...@@ -2676,7 +2676,7 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2676,7 +2676,7 @@ esxDomainMigratePerform(virDomainPtr domain,
int result = 0; int result = 0;
esxPrivate *priv = (esxPrivate *)domain->conn->privateData; esxPrivate *priv = (esxPrivate *)domain->conn->privateData;
xmlURIPtr xmlUri = NULL; xmlURIPtr xmlUri = NULL;
char host_ip_string[NI_MAXHOST] = ""; char hostIpAddress[NI_MAXHOST] = "";
esxVI_ObjectContent *virtualMachine = NULL; esxVI_ObjectContent *virtualMachine = NULL;
esxVI_String *propertyNameList = NULL; esxVI_String *propertyNameList = NULL;
esxVI_ObjectContent *hostSystem = NULL; esxVI_ObjectContent *hostSystem = NULL;
...@@ -2694,9 +2694,9 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2694,9 +2694,9 @@ esxDomainMigratePerform(virDomainPtr domain,
goto failure; goto failure;
} }
if (priv->vcenter == NULL) { if (priv->vCenter == NULL) {
ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG, ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG,
"Migration not possible without a Virtual Center"); "Migration not possible without a vCenter");
goto failure; goto failure;
} }
...@@ -2706,7 +2706,7 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2706,7 +2706,7 @@ esxDomainMigratePerform(virDomainPtr domain,
goto failure; goto failure;
} }
if (esxVI_EnsureSession(domain->conn, priv->vcenter) < 0) { if (esxVI_EnsureSession(domain->conn, priv->vCenter) < 0) {
goto failure; goto failure;
} }
...@@ -2718,13 +2718,13 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2718,13 +2718,13 @@ esxDomainMigratePerform(virDomainPtr domain,
goto failure; goto failure;
} }
if (esxUtil_ResolveHostname(domain->conn, xmlUri->server, host_ip_string, if (esxUtil_ResolveHostname(domain->conn, xmlUri->server, hostIpAddress,
NI_MAXHOST) < 0) { NI_MAXHOST) < 0) {
goto failure; goto failure;
} }
/* Lookup VirtualMachine, HostSystem and ResourcePool */ /* Lookup VirtualMachine, HostSystem and ResourcePool */
if (esxVI_LookupVirtualMachineByUuid(domain->conn, priv->vcenter, if (esxVI_LookupVirtualMachineByUuid(domain->conn, priv->vCenter,
domain->uuid, NULL, domain->uuid, NULL,
&virtualMachine) < 0) { &virtualMachine) < 0) {
goto failure; goto failure;
...@@ -2732,8 +2732,8 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2732,8 +2732,8 @@ esxDomainMigratePerform(virDomainPtr domain,
if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList, if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList,
"parent") < 0 || "parent") < 0 ||
esxVI_LookupHostSystemByIp(domain->conn, priv->vcenter, esxVI_LookupHostSystemByIp(domain->conn, priv->vCenter,
host_ip_string, propertyNameList, hostIpAddress, propertyNameList,
&hostSystem) < 0) { &hostSystem) < 0) {
goto failure; goto failure;
} }
...@@ -2763,7 +2763,7 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2763,7 +2763,7 @@ esxDomainMigratePerform(virDomainPtr domain,
if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList, if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList,
"resourcePool") < 0 || "resourcePool") < 0 ||
esxVI_GetObjectContent(domain->conn, priv->vcenter, esxVI_GetObjectContent(domain->conn, priv->vCenter,
managedObjectReference, "ComputeResource", managedObjectReference, "ComputeResource",
propertyNameList, esxVI_Boolean_False, propertyNameList, esxVI_Boolean_False,
&computeResource) < 0) { &computeResource) < 0) {
...@@ -2799,7 +2799,7 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2799,7 +2799,7 @@ esxDomainMigratePerform(virDomainPtr domain,
} }
/* Validate the purposed migration */ /* Validate the purposed migration */
if (esxVI_ValidateMigration(domain->conn, priv->vcenter, if (esxVI_ValidateMigration(domain->conn, priv->vCenter,
virtualMachine->obj, virtualMachine->obj,
esxVI_VirtualMachinePowerState_Undefined, esxVI_VirtualMachinePowerState_Undefined,
NULL, resourcePool, hostSystem->obj, NULL, resourcePool, hostSystem->obj,
...@@ -2826,9 +2826,9 @@ esxDomainMigratePerform(virDomainPtr domain, ...@@ -2826,9 +2826,9 @@ esxDomainMigratePerform(virDomainPtr domain,
} }
/* Perform the purposed migration */ /* Perform the purposed migration */
if (esxVI_MigrateVM_Task(domain->conn, priv->vcenter, virtualMachine->obj, if (esxVI_MigrateVM_Task(domain->conn, priv->vCenter, virtualMachine->obj,
resourcePool, hostSystem->obj, &task) < 0 || resourcePool, hostSystem->obj, &task) < 0 ||
esxVI_WaitForTaskCompletion(domain->conn, priv->vcenter, task, esxVI_WaitForTaskCompletion(domain->conn, priv->vCenter, task,
&taskInfoState) < 0) { &taskInfoState) < 0) {
goto failure; goto failure;
} }
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
char * char *
esxUtil_RequestUsername(virConnectAuthPtr auth, const char *default_username, esxUtil_RequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
const char *server) const char *server)
{ {
unsigned int ncred; unsigned int ncred;
...@@ -58,7 +58,7 @@ esxUtil_RequestUsername(virConnectAuthPtr auth, const char *default_username, ...@@ -58,7 +58,7 @@ esxUtil_RequestUsername(virConnectAuthPtr auth, const char *default_username,
memset(&cred, 0, sizeof(virConnectCredential)); memset(&cred, 0, sizeof(virConnectCredential));
if (virAsprintf(&prompt, "Enter username for %s [%s]", server, if (virAsprintf(&prompt, "Enter username for %s [%s]", server,
default_username) < 0) { defaultUsername) < 0) {
return NULL; return NULL;
} }
...@@ -70,7 +70,7 @@ esxUtil_RequestUsername(virConnectAuthPtr auth, const char *default_username, ...@@ -70,7 +70,7 @@ esxUtil_RequestUsername(virConnectAuthPtr auth, const char *default_username,
cred.type = VIR_CRED_AUTHNAME; cred.type = VIR_CRED_AUTHNAME;
cred.prompt = prompt; cred.prompt = prompt;
cred.challenge = NULL; cred.challenge = NULL;
cred.defresult = default_username; cred.defresult = defaultUsername;
cred.result = NULL; cred.result = NULL;
cred.resultlen = 0; cred.resultlen = 0;
...@@ -131,7 +131,7 @@ esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username, ...@@ -131,7 +131,7 @@ esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
int int
esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter, esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vCenter,
int *noVerify) int *noVerify)
{ {
int result = 0; int result = 0;
...@@ -143,8 +143,8 @@ esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter, ...@@ -143,8 +143,8 @@ esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter,
*transport = NULL; *transport = NULL;
} }
if (vcenter != NULL) { if (vCenter != NULL) {
*vcenter = NULL; *vCenter = NULL;
} }
#ifdef HAVE_XMLURI_QUERY_RAW #ifdef HAVE_XMLURI_QUERY_RAW
...@@ -174,10 +174,10 @@ esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter, ...@@ -174,10 +174,10 @@ esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter,
"'%s' (should be http|https)", *transport); "'%s' (should be http|https)", *transport);
goto failure; goto failure;
} }
} else if (STRCASEEQ(queryParam->name, "vcenter") && vcenter != NULL) { } else if (STRCASEEQ(queryParam->name, "vcenter") && vCenter != NULL) {
*vcenter = strdup(queryParam->value); *vCenter = strdup(queryParam->value);
if (*vcenter == NULL) { if (*vCenter == NULL) {
virReportOOMError(conn); virReportOOMError(conn);
goto failure; goto failure;
} }
...@@ -217,8 +217,8 @@ esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter, ...@@ -217,8 +217,8 @@ esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter,
VIR_FREE(*transport); VIR_FREE(*transport);
} }
if (vcenter != NULL) { if (vCenter != NULL) {
VIR_FREE(*vcenter); VIR_FREE(*vCenter);
} }
result = -1; result = -1;
...@@ -253,7 +253,7 @@ esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id) ...@@ -253,7 +253,7 @@ esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id)
int int
esxUtil_ResolveHostname(virConnectPtr conn, const char *hostname, esxUtil_ResolveHostname(virConnectPtr conn, const char *hostname,
char *ip_address, size_t ip_address_length) char *ipAddress, size_t ipAddress_length)
{ {
struct addrinfo hints; struct addrinfo hints;
struct addrinfo *result = NULL; struct addrinfo *result = NULL;
...@@ -282,8 +282,8 @@ esxUtil_ResolveHostname(virConnectPtr conn, const char *hostname, ...@@ -282,8 +282,8 @@ esxUtil_ResolveHostname(virConnectPtr conn, const char *hostname,
return -1; return -1;
} }
errcode = getnameinfo(result->ai_addr, result->ai_addrlen, ip_address, errcode = getnameinfo(result->ai_addr, result->ai_addrlen, ipAddress,
ip_address_length, NULL, 0, NI_NUMERICHOST); ipAddress_length, NULL, 0, NI_NUMERICHOST);
if (errcode != 0) { if (errcode != 0) {
ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
......
...@@ -29,19 +29,19 @@ ...@@ -29,19 +29,19 @@
#include "conf.h" #include "conf.h"
char *esxUtil_RequestUsername(virConnectAuthPtr auth, char *esxUtil_RequestUsername(virConnectAuthPtr auth,
const char *default_username, const char *defaultUsername,
const char *server); const char *server);
char *esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username, char *esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
const char *server); const char *server);
int esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vcenter, int esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vCenter,
int *noVerify); int *noVerify);
int esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id); int esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id);
int esxUtil_ResolveHostname(virConnectPtr conn, const char *hostname, int esxUtil_ResolveHostname(virConnectPtr conn, const char *hostname,
char *ip_address, size_t ip_address_length); char *ipAddress, size_t ipAddress_length);
int esxUtil_GetConfigString(virConnectPtr conn, virConfPtr conf, int esxUtil_GetConfigString(virConnectPtr conn, virConfPtr conf,
const char *name, char **string, int optional); const char *name, char **string, int optional);
......
...@@ -377,7 +377,7 @@ esxVI_Context_Connect(virConnectPtr conn, esxVI_Context *ctx, const char *url, ...@@ -377,7 +377,7 @@ esxVI_Context_Connect(virConnectPtr conn, esxVI_Context *ctx, const char *url,
if (ctx->vmFolder == NULL || ctx->hostFolder == NULL) { if (ctx->vmFolder == NULL || ctx->hostFolder == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"The 'datacenter' object is missing the " "The 'datacenter' object is missing the "
"'vmFolder'/'hostFolder' propoerty"); "'vmFolder'/'hostFolder' property");
goto failure; goto failure;
} }
...@@ -398,8 +398,8 @@ esxVI_Context_Download(virConnectPtr conn, esxVI_Context *ctx, const char *url, ...@@ -398,8 +398,8 @@ esxVI_Context_Download(virConnectPtr conn, esxVI_Context *ctx, const char *url,
char **content) char **content)
{ {
virBuffer buffer = VIR_BUFFER_INITIALIZER; virBuffer buffer = VIR_BUFFER_INITIALIZER;
CURLcode error_code; CURLcode errorCode;
long response_code; long responseCode;
if (content == NULL || *content != NULL) { if (content == NULL || *content != NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument"); ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
...@@ -412,22 +412,22 @@ esxVI_Context_Download(virConnectPtr conn, esxVI_Context *ctx, const char *url, ...@@ -412,22 +412,22 @@ esxVI_Context_Download(virConnectPtr conn, esxVI_Context *ctx, const char *url,
curl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(ctx->curl_handle, CURLOPT_HTTPGET, 1); curl_easy_setopt(ctx->curl_handle, CURLOPT_HTTPGET, 1);
error_code = curl_easy_perform(ctx->curl_handle); errorCode = curl_easy_perform(ctx->curl_handle);
if (error_code != CURLE_OK) { if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_perform() returned an error: %s (%d)", "curl_easy_perform() returned an error: %s (%d)",
curl_easy_strerror(error_code), error_code); curl_easy_strerror(errorCode), errorCode);
goto unlock; goto unlock;
} }
error_code = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE, errorCode = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE,
&response_code); &responseCode);
if (error_code != CURLE_OK) { if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_getinfo() returned an error: %s (%d)", "curl_easy_getinfo() returned an error: %s (%d)",
curl_easy_strerror(error_code), error_code); curl_easy_strerror(errorCode), errorCode);
goto unlock; goto unlock;
} }
...@@ -440,9 +440,9 @@ esxVI_Context_Download(virConnectPtr conn, esxVI_Context *ctx, const char *url, ...@@ -440,9 +440,9 @@ esxVI_Context_Download(virConnectPtr conn, esxVI_Context *ctx, const char *url,
*content = virBufferContentAndReset(&buffer); *content = virBufferContentAndReset(&buffer);
if (response_code != 200) { if (responseCode != 200) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d", (int)response_code); "HTTP response code %d", (int)responseCode);
goto failure; goto failure;
} }
...@@ -482,7 +482,7 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx, ...@@ -482,7 +482,7 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
{ {
virBuffer buffer = VIR_BUFFER_INITIALIZER; virBuffer buffer = VIR_BUFFER_INITIALIZER;
esxVI_Fault *fault = NULL; esxVI_Fault *fault = NULL;
CURLcode error_code; CURLcode errorCode;
if (remoteRequest == NULL || remoteRequest->request == NULL || if (remoteRequest == NULL || remoteRequest->request == NULL ||
remoteResponse == NULL || *remoteResponse != NULL) { remoteResponse == NULL || *remoteResponse != NULL) {
...@@ -503,22 +503,22 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx, ...@@ -503,22 +503,22 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
curl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDSIZE, curl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDSIZE,
strlen(remoteRequest->request)); strlen(remoteRequest->request));
error_code = curl_easy_perform(ctx->curl_handle); errorCode = curl_easy_perform(ctx->curl_handle);
if (error_code != CURLE_OK) { if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_perform() returned an error: %s (%d)", "curl_easy_perform() returned an error: %s (%d)",
curl_easy_strerror(error_code), error_code); curl_easy_strerror(errorCode), errorCode);
goto unlock; goto unlock;
} }
error_code = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE, errorCode = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE,
&(*remoteResponse)->response_code); &(*remoteResponse)->responseCode);
if (error_code != CURLE_OK) { if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_getinfo() returned an error: %s (%d)", "curl_easy_getinfo() returned an error: %s (%d)",
curl_easy_strerror(error_code), error_code); curl_easy_strerror(errorCode), errorCode);
goto unlock; goto unlock;
} }
...@@ -531,9 +531,9 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx, ...@@ -531,9 +531,9 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
(*remoteResponse)->response = virBufferContentAndReset(&buffer); (*remoteResponse)->response = virBufferContentAndReset(&buffer);
if ((*remoteResponse)->response_code == 500 || if ((*remoteResponse)->responseCode == 500 ||
(remoteRequest->xpathExpression != NULL && (remoteRequest->xpathExpression != NULL &&
(*remoteResponse)->response_code == 200)) { (*remoteResponse)->responseCode == 200)) {
(*remoteResponse)->document = (*remoteResponse)->document =
xmlReadDoc(BAD_CAST(*remoteResponse)->response, "", NULL, xmlReadDoc(BAD_CAST(*remoteResponse)->response, "", NULL,
XML_PARSE_NONET); XML_PARSE_NONET);
...@@ -564,7 +564,7 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx, ...@@ -564,7 +564,7 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
xmlXPathRegisterNs((*remoteResponse)->xpathContext, BAD_CAST "vim", xmlXPathRegisterNs((*remoteResponse)->xpathContext, BAD_CAST "vim",
BAD_CAST "urn:vim25"); BAD_CAST "urn:vim25");
if ((*remoteResponse)->response_code == 500) { if ((*remoteResponse)->responseCode == 500) {
(*remoteResponse)->xpathObject = (*remoteResponse)->xpathObject =
xmlXPathEval(BAD_CAST xmlXPathEval(BAD_CAST
"/soapenv:Envelope/soapenv:Body/soapenv:Fault", "/soapenv:Envelope/soapenv:Body/soapenv:Fault",
...@@ -580,7 +580,7 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx, ...@@ -580,7 +580,7 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d. VI Fault: %s - %s", "HTTP response code %d. VI Fault: %s - %s",
(int)(*remoteResponse)->response_code, (int)(*remoteResponse)->responseCode,
fault->faultcode, fault->faultstring); fault->faultcode, fault->faultstring);
goto failure; goto failure;
...@@ -589,10 +589,10 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx, ...@@ -589,10 +589,10 @@ esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
xmlXPathEval(BAD_CAST remoteRequest->xpathExpression, xmlXPathEval(BAD_CAST remoteRequest->xpathExpression,
(*remoteResponse)->xpathContext); (*remoteResponse)->xpathContext);
} }
} else if ((*remoteResponse)->response_code != 200) { } else if ((*remoteResponse)->responseCode != 200) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d", "HTTP response code %d",
(int)(*remoteResponse)->response_code); (int)(*remoteResponse)->responseCode);
goto failure; goto failure;
} }
......
...@@ -114,7 +114,7 @@ int esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx, ...@@ -114,7 +114,7 @@ int esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
*/ */
struct _esxVI_RemoteResponse { struct _esxVI_RemoteResponse {
long response_code; /* required */ long responseCode; /* required */
char *response; /* required */ char *response; /* required */
xmlDocPtr document; /* optional */ xmlDocPtr document; /* optional */
xmlXPathContextPtr xpathContext; /* optional */ xmlXPathContextPtr xpathContext; /* optional */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册