return priv->supportsLongMode;
}
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ return esxVI_Boolean_False;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return esxVI_Boolean_Undefined;
}
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ return 0;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return -1;
}
+static int
+esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
+ const char *hostname, int port,
+ const char *predefinedUsername,
+ esxUtil_ParsedQuery *parsedQuery,
+ esxVI_ProductVersion expectedProductVersion,
+ char **vCenterIpAddress)
+{
+ int result = -1;
+ char ipAddress[NI_MAXHOST] = "";
+ char *username = NULL;
+ char *password = NULL;
+ char *url = NULL;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *hostSystem = NULL;
+ esxVI_Boolean inMaintenanceMode = esxVI_Boolean_Undefined;
+
+ if (vCenterIpAddress == NULL || *vCenterIpAddress != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+ if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) {
+ return -1;
+ }
+
+ if (predefinedUsername != NULL) {
+ username = strdup(predefinedUsername);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else {
+ username = virRequestUsername(auth, "root", hostname);
+
+ if (username == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
+ goto cleanup;
+ }
+ }
+
+ password = virRequestPassword(auth, username, hostname);
+
+ if (password == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
+ goto cleanup;
+ }
+
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
+ port) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (esxVI_Context_Alloc(&priv->host) < 0 ||
+ esxVI_Context_Connect(priv->host, url, ipAddress, username, password,
+ parsedQuery) < 0) {
+ goto cleanup;
+ }
+
+ if (expectedProductVersion == esxVI_ProductVersion_ESX) {
+ if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
+ priv->host->productVersion != esxVI_ProductVersion_ESX40) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("%s is neither an ESX 3.5 host nor an ESX 4.0 host"),
+ hostname);
+ goto cleanup;
+ }
+ } else { /* GSX */
+ if (priv->host->productVersion != esxVI_ProductVersion_GSX20) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("%s isn't a GSX 2.0 host"), hostname);
+ goto cleanup;
+ }
+ }
+
+ /* Query the host for maintenance mode and vCenter IP address */
+ if (esxVI_String_AppendValueListToList(&propertyNameList,
+ "runtime.inMaintenanceMode\0"
+ "summary.managementServerIp\0") < 0 ||
+ esxVI_LookupHostSystemByIp(priv->host, ipAddress, propertyNameList,
+ &hostSystem) < 0 ||
+ esxVI_GetBoolean(hostSystem, "runtime.inMaintenanceMode",
+ &inMaintenanceMode,
+ esxVI_Occurrence_RequiredItem) < 0 ||
+ esxVI_GetStringValue(hostSystem, "summary.managementServerIp",
+ vCenterIpAddress,
+ esxVI_Occurrence_OptionalItem) < 0) {
+ goto cleanup;
+ }
+
+ /* Warn if host is in maintenance mode */
+ if (inMaintenanceMode == esxVI_Boolean_True) {
+ VIR_WARN0("The server is in maintenance mode");
+ }
+
+ if (*vCenterIpAddress != NULL) {
+ *vCenterIpAddress = strdup(*vCenterIpAddress);
+
+ if (*vCenterIpAddress == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+
+ result = 0;
+
+ cleanup:
+ VIR_FREE(password);
+ VIR_FREE(username);
+ VIR_FREE(url);
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&hostSystem);
+
+ return result;
+}
+
+
+
+static int
+esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
+ const char *hostname, int port,
+ const char *predefinedUsername,
+ esxUtil_ParsedQuery *parsedQuery)
+{
+ int result = -1;
+ char ipAddress[NI_MAXHOST] = "";
+ char *username = NULL;
+ char *password = NULL;
+ char *url = NULL;
+
+ if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) {
+ return -1;
+ }
+
+ if (predefinedUsername != NULL) {
+ username = strdup(predefinedUsername);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else {
+ username = virRequestUsername(auth, "administrator", hostname);
+
+ if (username == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
+ goto cleanup;
+ }
+ }
+
+ password = virRequestPassword(auth, username, hostname);
+
+ if (password == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
+ goto cleanup;
+ }
+
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
+ port) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
+ esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
+ password, parsedQuery) < 0) {
+ goto cleanup;
+ }
+
+ if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
+ priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("%s is neither a vCenter 2.5 server nor a vCenter "
+ "4.0 server"), hostname);
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ VIR_FREE(password);
+ VIR_FREE(username);
+ VIR_FREE(url);
+
+ return result;
+}
+
+
+
/*
- * URI format: {esx|gsx}://[<username>@]<hostname>[:<port>]/[<query parameter> ...]
+ * URI format: {vpx|esx|gsx}://[<username>@]<hostname>[:<port>]/[<query parameter> ...]
*
* If no port is specified the default port is set dependent on the scheme and
* transport parameter:
+ * - vpx+http 80
+ * - vpx+https 443
* - esx+http 80
* - esx+https 443
* - gsx+http 8222
*
* Optional query parameters:
* - transport={http|https}
- * - vcenter={<vcenter>|*}
+ * - vcenter={<vcenter>|*} only useful for an esx:// connection
* - no_verify={0|1}
* - auto_answer={0|1}
* - proxy=[{http|socks|socks4|socks4a|socks5}://]<hostname>[:<port>]
virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
esxPrivate *priv = NULL;
esxUtil_ParsedQuery *parsedQuery = NULL;
- char hostIpAddress[NI_MAXHOST] = "";
+ char *potentialVCenterIpAddress = NULL;
char vCenterIpAddress[NI_MAXHOST] = "";
- char *url = NULL;
- char *vCenter = NULL;
- char *username = NULL;
- char *password = NULL;
- esxVI_String *propertyNameList = NULL;
- esxVI_ObjectContent *hostSystem = NULL;
- esxVI_DynamicProperty *dynamicProperty = NULL;
- /* Decline if the URI is NULL or the scheme is neither 'esx' nor 'gsx' */
+ /* Decline if the URI is NULL or the scheme is not one of {vpx|esx|gsx} */
if (conn->uri == NULL || conn->uri->scheme == NULL ||
- (STRCASENEQ(conn->uri->scheme, "esx") &&
+ (STRCASENEQ(conn->uri->scheme, "vpx") &&
+ STRCASENEQ(conn->uri->scheme, "esx") &&
STRCASENEQ(conn->uri->scheme, "gsx"))) {
return VIR_DRV_OPEN_DECLINED;
}
* distinguish between the situations port == 0 and port != 0
*/
if (conn->uri->port == 0) {
- if (STRCASEEQ(conn->uri->scheme, "esx")) {
+ if (STRCASEEQ(conn->uri->scheme, "vpx") ||
+ STRCASEEQ(conn->uri->scheme, "esx")) {
if (STRCASEEQ(priv->transport, "https")) {
conn->uri->port = 443;
} else {
}
}
- /* Login to host */
- if (esxUtil_ResolveHostname(conn->uri->server, hostIpAddress,
- NI_MAXHOST) < 0) {
- goto cleanup;
- }
-
- if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport,
- conn->uri->server, conn->uri->port) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-
- if (conn->uri->user != NULL) {
- username = strdup(conn->uri->user);
-
- if (username == NULL) {
- virReportOOMError();
- goto cleanup;
- }
- } else {
- username = virRequestUsername(auth, "root", conn->uri->server);
-
- if (username == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
- goto cleanup;
- }
- }
-
- password = virRequestPassword(auth, username, conn->uri->server);
-
- if (password == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
- goto cleanup;
- }
-
- if (esxVI_Context_Alloc(&priv->host) < 0 ||
- esxVI_Context_Connect(priv->host, url, hostIpAddress, username,
- password, parsedQuery) < 0) {
- goto cleanup;
- }
-
- if (STRCASEEQ(conn->uri->scheme, "esx")) {
- if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
- priv->host->productVersion != esxVI_ProductVersion_ESX40) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("%s is neither an ESX 3.5 host nor an ESX 4.0 host"),
- conn->uri->server);
+ if (STRCASEEQ(conn->uri->scheme, "esx") ||
+ STRCASEEQ(conn->uri->scheme, "gsx")) {
+ /* Connect to host */
+ if (esxConnectToHost(priv, auth, conn->uri->server, conn->uri->port,
+ conn->uri->user, parsedQuery,
+ STRCASEEQ(conn->uri->scheme, "esx")
+ ? esxVI_ProductVersion_ESX
+ : esxVI_ProductVersion_GSX,
+ &potentialVCenterIpAddress) < 0) {
goto cleanup;
}
- } else { /* GSX */
- if (priv->host->productVersion != esxVI_ProductVersion_GSX20) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("%s isn't a GSX 2.0 host"), conn->uri->server);
- goto cleanup;
- }
- }
-
- /* Query the host for maintenance mode and vCenter IP address */
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "runtime.inMaintenanceMode\0"
- "summary.managementServerIp\0") < 0 ||
- esxVI_LookupHostSystemByIp(priv->host, hostIpAddress, propertyNameList,
- &hostSystem) < 0) {
- goto cleanup;
- }
- /* Warn if host is in maintenance mode */
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "runtime.inMaintenanceMode")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Boolean) < 0) {
- goto cleanup;
- }
-
- if (dynamicProperty->val->boolean == esxVI_Boolean_True) {
- VIR_WARN0("The server is in maintenance mode");
- }
-
- break;
- }
- }
-
- /* Login to vCenter */
- if (parsedQuery->vCenter != NULL) {
- VIR_FREE(url);
- VIR_FREE(password);
- VIR_FREE(username);
-
- vCenter = strdup(parsedQuery->vCenter);
-
- if (vCenter == NULL) {
- virReportOOMError();
- goto cleanup;
- }
-
- /* If a vCenter is specified resolve the hostname */
- if (STRNEQ(vCenter, "*") &&
- esxUtil_ResolveHostname(vCenter, vCenterIpAddress,
- NI_MAXHOST) < 0) {
- goto cleanup;
- }
-
- /* Lookup the vCenter from the ESX host */
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "summary.managementServerIp")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ /* Connect to vCenter */
+ if (parsedQuery->vCenter != NULL) {
+ if (STREQ(parsedQuery->vCenter, "*")) {
+ if (potentialVCenterIpAddress == NULL) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("This host is not managed by a vCenter"));
goto cleanup;
}
- /* Get the vCenter IP address or verify the specified one */
- if (STREQ(vCenter, "*")) {
- VIR_FREE(vCenter);
-
- vCenter = strdup(dynamicProperty->val->string);
-
- if (vCenter == NULL) {
- virReportOOMError();
- goto cleanup;
- }
+ if (virStrcpyStatic(vCenterIpAddress,
+ potentialVCenterIpAddress) == NULL) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("vCenter IP address %s too big for destination"),
+ potentialVCenterIpAddress);
+ goto cleanup;
+ }
+ } else {
+ if (esxUtil_ResolveHostname(parsedQuery->vCenter,
+ vCenterIpAddress, NI_MAXHOST) < 0) {
+ goto cleanup;
+ }
- if (virStrcpyStatic(vCenterIpAddress,
- dynamicProperty->val->string) == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("vCenter IP address %s too big for "
- "destination"),
- dynamicProperty->val->string);
- goto cleanup;
- }
- } else if (STRNEQ(vCenterIpAddress,
- dynamicProperty->val->string)) {
+ if (potentialVCenterIpAddress != NULL &&
+ STRNEQ(vCenterIpAddress, potentialVCenterIpAddress)) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("This host is managed by a vCenter with IP "
"address %s, but a mismachting vCenter '%s' "
"(%s) has been specified"),
- dynamicProperty->val->string, vCenter,
+ potentialVCenterIpAddress, parsedQuery->vCenter,
vCenterIpAddress);
goto cleanup;
}
-
- break;
}
- }
-
- if (STREQ(vCenter, "*")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("This host is not managed by a vCenter"));
- goto cleanup;
- }
-
- if (virAsprintf(&url, "%s://%s/sdk", priv->transport,
- vCenter) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-
- if (esxVI_Context_Alloc(&priv->vCenter) < 0) {
- goto cleanup;
- }
- username = virRequestUsername(auth, "administrator", vCenter);
-
- if (username == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
- goto cleanup;
- }
-
- password = virRequestPassword(auth, username, vCenter);
-
- if (password == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
- goto cleanup;
+ if (esxConnectToVCenter(priv, auth, vCenterIpAddress,
+ conn->uri->port, NULL, parsedQuery) < 0) {
+ goto cleanup;
+ }
}
- if (esxVI_Context_Connect(priv->vCenter, url, vCenterIpAddress,
- username, password, parsedQuery) < 0) {
+ priv->primary = priv->host;
+ } else { /* VPX */
+ /* Connect to vCenter */
+ if (esxConnectToVCenter(priv, auth, conn->uri->server, conn->uri->port,
+ conn->uri->user, parsedQuery) < 0) {
goto cleanup;
}
- if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
- priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("%s is neither a vCenter 2.5 server nor a vCenter "
- "4.0 server"), conn->uri->server);
- goto cleanup;
- }
+ priv->primary = priv->vCenter;
}
conn->privateData = priv;
}
esxUtil_FreeParsedQuery(&parsedQuery);
- VIR_FREE(url);
- VIR_FREE(vCenter);
- VIR_FREE(password);
- VIR_FREE(username);
- esxVI_String_Free(&propertyNameList);
- esxVI_ObjectContent_Free(&hostSystem);
+ VIR_FREE(potentialVCenterIpAddress);
return result;
}
esxPrivate *priv = conn->privateData;
int result = 0;
- if (esxVI_EnsureSession(priv->host) < 0 ||
- esxVI_Logout(priv->host) < 0) {
- result = -1;
- }
+ if (priv->host != NULL) {
+ if (esxVI_EnsureSession(priv->host) < 0 ||
+ esxVI_Logout(priv->host) < 0) {
+ result = -1;
+ }
- esxVI_Context_Free(&priv->host);
+ esxVI_Context_Free(&priv->host);
+ }
if (priv->vCenter != NULL) {
if (esxVI_EnsureSession(priv->vCenter) < 0 ||
return priv->supportsVMotion;
}
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ return esxVI_Boolean_False;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return esxVI_Boolean_Undefined;
}
{
esxPrivate *priv = conn->privateData;
- if (virParseVersionString(priv->host->service->about->version,
+ if (virParseVersionString(priv->primary->service->about->version,
version) < 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not parse version number from '%s'"),
- priv->host->service->about->version);
+ priv->primary->service->about->version);
return -1;
}
const char *domainName = NULL;
char *complete = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve the hostname for a vpx:// connection"));
+ return NULL;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return NULL;
}
memset(nodeinfo, 0, sizeof (*nodeinfo));
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Nodeinfo is not available for a vpx:// connection"));
+ return -1;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return -1;
}
return 0;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupObjectContentByType(priv->host, priv->host->vmFolder,
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True,
&virtualMachineList) < 0) {
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
return esxVI_LookupNumberOfDomainsByPowerState
- (priv->host, esxVI_VirtualMachinePowerState_PoweredOn,
+ (priv->primary, esxVI_VirtualMachinePowerState_PoweredOn,
esxVI_Boolean_False);
}
unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
"name\0"
"runtime.powerState\0"
"config.uuid\0") < 0 ||
- esxVI_LookupObjectContentByType(priv->host, priv->host->vmFolder,
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True,
&virtualMachineList) < 0) {
char *name = NULL;
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
"runtime.powerState\0") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, uuid, propertyNameList,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, uuid, propertyNameList,
&virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachineIdentity(virtualMachine, &id, &name, NULL) < 0 ||
unsigned char uuid[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
"configStatus\0"
"runtime.powerState\0"
"config.uuid\0") < 0 ||
- esxVI_LookupVirtualMachineByName(priv->host, name, propertyNameList,
+ esxVI_LookupVirtualMachineByName(priv->primary, name, propertyNameList,
&virtualMachine,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, propertyNameList, &virtualMachine,
+ (priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
goto cleanup;
}
- if (esxVI_SuspendVM_Task(priv->host, virtualMachine->obj, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ if (esxVI_SuspendVM_Task(priv->primary, virtualMachine->obj, &task) < 0 ||
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, propertyNameList, &virtualMachine,
+ (priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
goto cleanup;
}
- if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, NULL,
+ if (esxVI_PowerOnVM_Task(priv->primary, virtualMachine->obj, NULL,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
}
- if (esxVI_ShutdownGuest(priv->host, virtualMachine->obj) < 0) {
+ if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0) {
goto cleanup;
}
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
}
- if (esxVI_RebootGuest(priv->host, virtualMachine->obj) < 0) {
+ if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0) {
goto cleanup;
}
esxVI_DynamicProperty *dynamicProperty = NULL;
unsigned long memoryMB = 0;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return 0;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.hardware.memoryMB") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_Long_Alloc(&spec->memoryMB) < 0) {
spec->memoryMB->value =
memory / 1024; /* Scale from kilobytes to megabytes */
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0 ||
spec->memoryAllocation->limit->value =
memory / 1024; /* Scale from kilobytes to megabytes */
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
memset(info, 0, sizeof (*info));
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
"config.hardware.memoryMB\0"
"config.hardware.numCPU\0"
"config.memoryAllocation.limit\0") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
info->memory = memory_limit < 0 ? info->maxMem : memory_limit;
/* Verify the cached 'used CPU time' performance counter ID */
- if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
- if (esxVI_Int_Alloc(&counterId) < 0) {
- goto cleanup;
- }
+ /* FIXME: Currently no host for a vpx:// connection */
+ if (priv->host != NULL) {
+ if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
+ if (esxVI_Int_Alloc(&counterId) < 0) {
+ goto cleanup;
+ }
- counterId->value = priv->usedCpuTimeCounterId;
+ counterId->value = priv->usedCpuTimeCounterId;
- if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
- goto cleanup;
- }
+ if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ goto cleanup;
+ }
- if (esxVI_QueryPerfCounter(priv->host, counterIdList,
- &perfCounterInfo) < 0) {
- goto cleanup;
- }
+ if (esxVI_QueryPerfCounter(priv->host, counterIdList,
+ &perfCounterInfo) < 0) {
+ goto cleanup;
+ }
- if (STRNEQ(perfCounterInfo->groupInfo->key, "cpu") ||
- STRNEQ(perfCounterInfo->nameInfo->key, "used") ||
- STRNEQ(perfCounterInfo->unitInfo->key, "millisecond")) {
- VIR_DEBUG("Cached usedCpuTimeCounterId %d is invalid",
- priv->usedCpuTimeCounterId);
+ if (STRNEQ(perfCounterInfo->groupInfo->key, "cpu") ||
+ STRNEQ(perfCounterInfo->nameInfo->key, "used") ||
+ STRNEQ(perfCounterInfo->unitInfo->key, "millisecond")) {
+ VIR_DEBUG("Cached usedCpuTimeCounterId %d is invalid",
+ priv->usedCpuTimeCounterId);
- priv->usedCpuTimeCounterId = -1;
+ priv->usedCpuTimeCounterId = -1;
+ }
+
+ esxVI_Int_Free(&counterIdList);
+ esxVI_PerfCounterInfo_Free(&perfCounterInfo);
}
- esxVI_Int_Free(&counterIdList);
- esxVI_PerfCounterInfo_Free(&perfCounterInfo);
- }
+ /*
+ * Query the PerformanceManager for the 'used CPU time' performance
+ * counter ID and cache it, if it's not already cached.
+ */
+ if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId < 0) {
+ if (esxVI_QueryAvailablePerfMetric(priv->host, virtualMachine->obj,
+ NULL, NULL, NULL,
+ &perfMetricIdList) < 0) {
+ goto cleanup;
+ }
- /*
- * Query the PerformanceManager for the 'used CPU time' performance
- * counter ID and cache it, if it's not already cached.
- */
- if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId < 0) {
- if (esxVI_QueryAvailablePerfMetric(priv->host, virtualMachine->obj,
- NULL, NULL, NULL,
- &perfMetricIdList) < 0) {
- goto cleanup;
- }
+ for (perfMetricId = perfMetricIdList; perfMetricId != NULL;
+ perfMetricId = perfMetricId->_next) {
+ VIR_DEBUG("perfMetricId counterId %d, instance '%s'",
+ perfMetricId->counterId->value, perfMetricId->instance);
- for (perfMetricId = perfMetricIdList; perfMetricId != NULL;
- perfMetricId = perfMetricId->_next) {
- VIR_DEBUG("perfMetricId counterId %d, instance '%s'",
- perfMetricId->counterId->value, perfMetricId->instance);
+ counterId = NULL;
- counterId = NULL;
+ if (esxVI_Int_DeepCopy(&counterId, perfMetricId->counterId) < 0 ||
+ esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ goto cleanup;
+ }
+ }
- if (esxVI_Int_DeepCopy(&counterId, perfMetricId->counterId) < 0 ||
- esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ if (esxVI_QueryPerfCounter(priv->host, counterIdList,
+ &perfCounterInfoList) < 0) {
goto cleanup;
}
- }
- if (esxVI_QueryPerfCounter(priv->host, counterIdList,
- &perfCounterInfoList) < 0) {
- goto cleanup;
- }
-
- for (perfCounterInfo = perfCounterInfoList; perfCounterInfo != NULL;
- perfCounterInfo = perfCounterInfo->_next) {
- VIR_DEBUG("perfCounterInfo key %d, nameInfo '%s', groupInfo '%s', "
- "unitInfo '%s', rollupType %d, statsType %d",
- perfCounterInfo->key->value,
- perfCounterInfo->nameInfo->key,
- perfCounterInfo->groupInfo->key,
- perfCounterInfo->unitInfo->key,
- perfCounterInfo->rollupType,
- perfCounterInfo->statsType);
-
- if (STREQ(perfCounterInfo->groupInfo->key, "cpu") &&
- STREQ(perfCounterInfo->nameInfo->key, "used") &&
- STREQ(perfCounterInfo->unitInfo->key, "millisecond")) {
- priv->usedCpuTimeCounterId = perfCounterInfo->key->value;
- break;
+ for (perfCounterInfo = perfCounterInfoList; perfCounterInfo != NULL;
+ perfCounterInfo = perfCounterInfo->_next) {
+ VIR_DEBUG("perfCounterInfo key %d, nameInfo '%s', groupInfo '%s', "
+ "unitInfo '%s', rollupType %d, statsType %d",
+ perfCounterInfo->key->value,
+ perfCounterInfo->nameInfo->key,
+ perfCounterInfo->groupInfo->key,
+ perfCounterInfo->unitInfo->key,
+ perfCounterInfo->rollupType,
+ perfCounterInfo->statsType);
+
+ if (STREQ(perfCounterInfo->groupInfo->key, "cpu") &&
+ STREQ(perfCounterInfo->nameInfo->key, "used") &&
+ STREQ(perfCounterInfo->unitInfo->key, "millisecond")) {
+ priv->usedCpuTimeCounterId = perfCounterInfo->key->value;
+ break;
+ }
}
- }
- if (priv->usedCpuTimeCounterId < 0) {
- VIR_WARN0("Could not find 'used CPU time' performance counter");
+ if (priv->usedCpuTimeCounterId < 0) {
+ VIR_WARN0("Could not find 'used CPU time' performance counter");
+ }
}
- }
-
- /*
- * Query the PerformanceManager for the 'used CPU time' performance
- * counter value.
- */
- if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
- VIR_DEBUG("usedCpuTimeCounterId %d BEGIN", priv->usedCpuTimeCounterId);
- if (esxVI_PerfQuerySpec_Alloc(&querySpec) < 0 ||
- esxVI_Int_Alloc(&querySpec->maxSample) < 0 ||
- esxVI_PerfMetricId_Alloc(&querySpec->metricId) < 0 ||
- esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0) {
- goto cleanup;
- }
+ /*
+ * Query the PerformanceManager for the 'used CPU time' performance
+ * counter value.
+ */
+ if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
+ VIR_DEBUG("usedCpuTimeCounterId %d BEGIN", priv->usedCpuTimeCounterId);
- querySpec->entity = virtualMachine->obj;
- querySpec->maxSample->value = 1;
- querySpec->metricId->counterId->value = priv->usedCpuTimeCounterId;
- querySpec->metricId->instance = (char *)"";
- querySpec->format = (char *)"normal";
+ if (esxVI_PerfQuerySpec_Alloc(&querySpec) < 0 ||
+ esxVI_Int_Alloc(&querySpec->maxSample) < 0 ||
+ esxVI_PerfMetricId_Alloc(&querySpec->metricId) < 0 ||
+ esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0) {
+ goto cleanup;
+ }
- if (esxVI_QueryPerf(priv->host, querySpec,
- &perfEntityMetricBaseList) < 0) {
- querySpec->entity = NULL;
- querySpec->metricId->instance = NULL;
- querySpec->format = NULL;
- goto cleanup;
- }
+ querySpec->entity = virtualMachine->obj;
+ querySpec->maxSample->value = 1;
+ querySpec->metricId->counterId->value = priv->usedCpuTimeCounterId;
+ querySpec->metricId->instance = (char *)"";
+ querySpec->format = (char *)"normal";
+
+ if (esxVI_QueryPerf(priv->host, querySpec,
+ &perfEntityMetricBaseList) < 0) {
+ querySpec->entity = NULL;
+ querySpec->metricId->instance = NULL;
+ querySpec->format = NULL;
+ goto cleanup;
+ }
- for (perfEntityMetricBase = perfEntityMetricBaseList;
- perfEntityMetricBase != NULL;
- perfEntityMetricBase = perfEntityMetricBase->_next) {
- VIR_DEBUG0("perfEntityMetric ...");
+ for (perfEntityMetricBase = perfEntityMetricBaseList;
+ perfEntityMetricBase != NULL;
+ perfEntityMetricBase = perfEntityMetricBase->_next) {
+ VIR_DEBUG0("perfEntityMetric ...");
- perfEntityMetric =
- esxVI_PerfEntityMetric_DynamicCast(perfEntityMetricBase);
+ perfEntityMetric =
+ esxVI_PerfEntityMetric_DynamicCast(perfEntityMetricBase);
- if (perfMetricIntSeries == NULL) {
- VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
- }
+ if (perfMetricIntSeries == NULL) {
+ VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
+ }
- perfMetricIntSeries =
- esxVI_PerfMetricIntSeries_DynamicCast(perfEntityMetric->value);
+ perfMetricIntSeries =
+ esxVI_PerfMetricIntSeries_DynamicCast(perfEntityMetric->value);
- if (perfMetricIntSeries == NULL) {
- VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
- }
+ if (perfMetricIntSeries == NULL) {
+ VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
+ }
- for (; perfMetricIntSeries != NULL;
- perfMetricIntSeries = perfMetricIntSeries->_next) {
- VIR_DEBUG0("perfMetricIntSeries ...");
+ for (; perfMetricIntSeries != NULL;
+ perfMetricIntSeries = perfMetricIntSeries->_next) {
+ VIR_DEBUG0("perfMetricIntSeries ...");
- for (value = perfMetricIntSeries->value;
- value != NULL;
- value = value->_next) {
- VIR_DEBUG("value %lld", (long long int)value->value);
+ for (value = perfMetricIntSeries->value;
+ value != NULL;
+ value = value->_next) {
+ VIR_DEBUG("value %lld", (long long int)value->value);
+ }
}
}
- }
- querySpec->entity = NULL;
- querySpec->metricId->instance = NULL;
- querySpec->format = NULL;
+ querySpec->entity = NULL;
+ querySpec->metricId->instance = NULL;
+ querySpec->format = NULL;
- VIR_DEBUG("usedCpuTimeCounterId %d END", priv->usedCpuTimeCounterId);
+ VIR_DEBUG("usedCpuTimeCounterId %d END", priv->usedCpuTimeCounterId);
- /*
- * FIXME: Cannot map between realtive used-cpu-time and absolute
- * info->cpuTime
- */
+ /*
+ * FIXME: Cannot map between realtive used-cpu-time and absolute
+ * info->cpuTime
+ */
+ }
}
result = 0;
return -1;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_Int_Alloc(&spec->numCPUs) < 0) {
spec->numCPUs->value = nvcpus;
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
priv->maxVcpus = -1;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("MaxVCPUs value is not available for a vpx:// connection"));
+ return -1;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return -1;
}
{
esxPrivate *priv = domain->conn->privateData;
esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *datacenter = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
const char *vmPathName = NULL;
+ char *datacenterName = NULL;
char *datastoreName = NULL;
char *directoryName = NULL;
char *fileName = NULL;
virDomainDefPtr def = NULL;
char *xml = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
+ if (esxVI_String_AppendValueToList(&propertyNameList, "name") < 0 ||
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->datacenter,
+ "Datacenter", propertyNameList,
+ esxVI_Boolean_False, &datacenter) < 0 ||
+ esxVI_GetStringValue(datacenter, "name", &datacenterName,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
+
+ esxVI_String_Free(&propertyNameList);
+
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.files.vmPathName") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
virBufferURIEncodeString(&buffer, fileName);
virBufferAddLit(&buffer, "?dcPath=");
- virBufferURIEncodeString(&buffer, priv->host->datacenter->value);
+ virBufferURIEncodeString(&buffer, datacenterName);
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
url = virBufferContentAndReset(&buffer);
- if (esxVI_Context_DownloadFile(priv->host, url, &vmx) < 0) {
+ if (esxVI_Context_DownloadFile(priv->primary, url, &vmx) < 0) {
goto cleanup;
}
- def = esxVMX_ParseConfig(priv->host, priv->caps, vmx, datastoreName,
- directoryName, priv->host->productVersion);
+ def = esxVMX_ParseConfig(priv->primary, priv->caps, vmx, datastoreName,
+ directoryName, priv->primary->productVersion);
if (def != NULL) {
xml = virDomainDefFormat(def, flags);
}
esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&datacenter);
esxVI_ObjectContent_Free(&virtualMachine);
VIR_FREE(datastoreName);
VIR_FREE(directoryName);
return NULL;
}
- def = esxVMX_ParseConfig(priv->host, priv->caps, nativeConfig, "?", "?",
- priv->host->productVersion);
+ def = esxVMX_ParseConfig(priv->primary, priv->caps, nativeConfig, "?", "?",
+ priv->primary->productVersion);
if (def != NULL) {
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
return NULL;
}
- vmx = esxVMX_FormatConfig(priv->host, priv->caps, def,
- priv->host->productVersion);
+ vmx = esxVMX_FormatConfig(priv->primary, priv->caps, def,
+ priv->primary->productVersion);
virDomainDefFree(def);
return 0;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
"runtime.powerState\0") < 0 ||
- esxVI_LookupObjectContentByType(priv->host, priv->host->vmFolder,
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True,
&virtualMachineList) < 0) {
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
return esxVI_LookupNumberOfDomainsByPowerState
- (priv->host, esxVI_VirtualMachinePowerState_PoweredOn,
+ (priv->primary, esxVI_VirtualMachinePowerState_PoweredOn,
esxVI_Boolean_True);
}
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, propertyNameList, &virtualMachine,
+ (priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine,
&powerState) < 0) {
goto cleanup;
}
- if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, NULL,
+ if (esxVI_PowerOnVM_Task(priv->primary, virtualMachine->obj, NULL,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_TaskInfoState taskInfoState;
virDomainPtr domain = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not define domain with a vpx:// connection"));
+ return NULL;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return NULL;
}
return -1;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
"config.cpuAllocation.reservation\0"
"config.cpuAllocation.limit\0"
"config.cpuAllocation.shares\0") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
esxVI_TaskInfoState taskInfoState;
int i;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->cpuAllocation) < 0) {
}
}
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve free memory for a vpx:// connection"));
+ return 0;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return 0;
}
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
- esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,
&snapshotTree, &snapshotTreeParent,
goto cleanup;
}
- if (esxVI_CreateSnapshot_Task(priv->host, virtualMachine->obj,
+ if (esxVI_CreateSnapshot_Task(priv->primary, virtualMachine->obj,
def->name, def->description,
esxVI_Boolean_True,
esxVI_Boolean_False, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
memset(&def, 0, sizeof (def));
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0) {
return -1;
}
return 0;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0) {
return -1;
}
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, name, &snapshotTree,
&snapshotTreeParent,
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupCurrentSnapshotTree(priv->host, domain->uuid,
+ if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
esxVI_Occurrence_OptionalItem) < 0) {
return -1;
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
- if (esxVI_LookupCurrentSnapshotTree(priv->host, domain->uuid,
+ if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
esxVI_Occurrence_RequiredItem) < 0) {
return NULL;
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
goto cleanup;
}
- if (esxVI_RevertToSnapshot_Task(priv->host, snapshotTree->snapshot, NULL,
+ if (esxVI_RevertToSnapshot_Task(priv->primary, snapshotTree->snapshot, NULL,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, snapshot->domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
removeChildren = esxVI_Boolean_True;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
goto cleanup;
}
- if (esxVI_RemoveSnapshot_Task(priv->host, snapshotTree->snapshot,
+ if (esxVI_RemoveSnapshot_Task(priv->primary, snapshotTree->snapshot,
removeChildren, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, snapshot->domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}