static void
esxFreePrivate(esxPrivate **priv)
{
- if (!priv || !(*priv)) {
+ if (!priv || !(*priv))
return;
- }
esxVI_Context_Free(&(*priv)->host);
esxVI_Context_Free(&(*priv)->vCenter);
tmp = (char *)STRSKIP(fileName, hostMount->mountInfo->path);
- if (!tmp) {
+ if (!tmp)
continue;
- }
/* Found a match. Strip leading separators */
- while (*tmp == '/' || *tmp == '\\') {
+ while (*tmp == '/' || *tmp == '\\')
++tmp;
- }
- if (VIR_STRDUP(strippedFileName, tmp) < 0) {
+ if (VIR_STRDUP(strippedFileName, tmp) < 0)
goto cleanup;
- }
tmp = strippedFileName;
/* Convert \ to / */
while (*tmp != '\0') {
- if (*tmp == '\\') {
+ if (*tmp == '\\')
*tmp = '/';
- }
++tmp;
}
/* Fallback to direct datastore name match */
if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) {
- if (VIR_STRDUP(copyOfFileName, fileName) < 0) {
+ if (VIR_STRDUP(copyOfFileName, fileName) < 0)
goto cleanup;
- }
/* Expected format: '/vmfs/volumes/<datastore>/<path>' */
if (!(tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) ||
/* If it's an absolute path outside of a datastore just use it as is */
if (!result && *fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
- if (VIR_STRDUP(result, fileName) < 0) {
+ if (VIR_STRDUP(result, fileName) < 0)
goto cleanup;
- }
}
if (!result) {
}
/* Detect separator type */
- if (strchr(hostMount->mountInfo->path, '\\')) {
+ if (strchr(hostMount->mountInfo->path, '\\'))
separator = '\\';
- }
/* Strip trailing separators */
length = strlen(hostMount->mountInfo->path);
- while (length > 0 && hostMount->mountInfo->path[length - 1] == separator) {
+ while (length > 0 && hostMount->mountInfo->path[length - 1] == separator)
--length;
- }
/* Format as <mount>[/<directory>]/<file>, convert / to \ when necessary */
virBufferAdd(&buffer, hostMount->mountInfo->path, length);
tmp = directoryAndFileName;
while (*tmp != '\0') {
- if (*tmp == '/') {
+ if (*tmp == '/')
*tmp = separator;
- }
++tmp;
}
result = virBufferContentAndReset(&buffer);
} else if (*fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
- if (VIR_STRDUP(result, fileName) < 0) {
+ if (VIR_STRDUP(result, fileName) < 0)
goto cleanup;
- }
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not handle file name '%s'"), fileName);
esxVI_ParsedHostCpuIdInfo parsedHostCpuIdInfo;
char edxLongModeBit = '?';
- if (priv->supportsLongMode != esxVI_Boolean_Undefined) {
+ if (priv->supportsLongMode != esxVI_Boolean_Undefined)
return priv->supportsLongMode;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return esxVI_Boolean_Undefined;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"hardware.cpuFeature") < 0 ||
esxVI_ObjectContent *hostSystem = NULL;
char *uuid_string = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"hardware.systemInfo.uuid") < 0 ||
virCapsPtr caps = NULL;
virCapsGuestPtr guest = NULL;
- if (supportsLongMode == esxVI_Boolean_Undefined) {
+ if (supportsLongMode == esxVI_Boolean_Undefined)
return NULL;
- }
if (supportsLongMode == esxVI_Boolean_True) {
caps = virCapabilitiesNew(VIR_ARCH_X86_64, true, true);
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
- if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) {
+ if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0)
goto failure;
- }
/* i686 */
guest = virCapabilitiesAddGuest(caps, "hvm",
NULL, NULL, 0,
NULL);
- if (!guest) {
+ if (!guest)
goto failure;
- }
- if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) {
+ if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL))
goto failure;
- }
/* x86_64 */
if (supportsLongMode == esxVI_Boolean_True) {
NULL, NULL,
0, NULL);
- if (!guest) {
+ if (!guest)
goto failure;
- }
- if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) {
+ if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL))
goto failure;
- }
}
return caps;
return -1;
}
- if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0) {
+ if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0)
return -1;
- }
if (conn->uri->user) {
if (VIR_STRDUP(username, conn->uri->user) < 0)
password = esxUtil_EscapeForXml(unescapedPassword);
- if (!password) {
+ if (!password)
goto cleanup;
- }
if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
conn->uri->server, conn->uri->port) < 0)
}
/* Warn if host is in maintenance mode */
- if (inMaintenanceMode == esxVI_Boolean_True) {
+ if (inMaintenanceMode == esxVI_Boolean_True)
VIR_WARN("The server is in maintenance mode");
- }
if (VIR_STRDUP(*vCenterIpAddress, *vCenterIpAddress) < 0)
goto cleanup;
return -1;
}
- if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) {
+ if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0)
return -1;
- }
if (conn->uri->user) {
- if (VIR_STRDUP(username, conn->uri->user) < 0) {
+ if (VIR_STRDUP(username, conn->uri->user) < 0)
goto cleanup;
- }
} else {
username = virAuthGetUsername(conn, auth, "esx", "administrator", hostname);
password = esxUtil_EscapeForXml(unescapedPassword);
- if (!password) {
+ if (!password)
goto cleanup;
- }
if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
hostname, conn->uri->port) < 0)
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Decline if the URI is NULL or the scheme is NULL */
- if (!conn->uri || !conn->uri->scheme) {
+ if (!conn->uri || !conn->uri->scheme)
return VIR_DRV_OPEN_DECLINED;
- }
/* Decline if the scheme is not one of {vpx|esx|gsx} */
plus = strchr(conn->uri->scheme, '+');
if (VIR_ALLOC(priv) < 0)
goto cleanup;
- if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) {
+ if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0)
goto cleanup;
- }
priv->maxVcpus = -1;
priv->supportsVMotion = esxVI_Boolean_Undefined;
/* Setup capabilities */
priv->caps = esxCapsInit(priv);
- if (!priv->caps) {
+ if (!priv->caps)
goto cleanup;
- }
if (!(priv->xmlopt = virVMXDomainXMLConfInit()))
goto cleanup;
esxVI_String *propertyNameList = NULL;
esxVI_ObjectContent *hostSystem = NULL;
- if (priv->supportsVMotion != esxVI_Boolean_Undefined) {
+ if (priv->supportsVMotion != esxVI_Boolean_Undefined)
return priv->supportsVMotion;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return esxVI_Boolean_Undefined;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"capability.vmotionSupported") < 0 ||
case VIR_DRV_FEATURE_MIGRATION_V1:
supportsVMotion = esxSupportsVMotion(priv);
- if (supportsVMotion == esxVI_Boolean_Undefined) {
+ if (supportsVMotion == esxVI_Boolean_Undefined)
return -1;
- }
/* Migration is only possible via a vCenter and if VMotion is enabled */
return priv->vCenter &&
const char *domainName = NULL;
char *complete = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList
(&propertyNameList,
memset(nodeinfo, 0, sizeof(*nodeinfo));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"hardware.cpuInfo.hz\0"
esxVI_VirtualMachinePowerState powerState;
int count = 0;
- if (maxids == 0) {
+ if (maxids == 0)
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
goto cleanup;
}
- if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) {
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOn)
continue;
- }
if (esxUtil_ParseVirtualMachineIDString(virtualMachine->obj->value,
&ids[count]) < 0 ||
count++;
- if (count >= maxids) {
+ if (count >= maxids)
break;
- }
}
success = true;
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return esxVI_LookupNumberOfDomainsByPowerState
(priv->primary, esxVI_VirtualMachinePowerState_PoweredOn, false);
unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"configStatus\0"
}
/* Only running/suspended domains have an ID != -1 */
- if (powerState == esxVI_VirtualMachinePowerState_PoweredOff) {
+ if (powerState == esxVI_VirtualMachinePowerState_PoweredOff)
continue;
- }
VIR_FREE(name_candidate);
goto cleanup;
}
- if (id != id_candidate) {
+ if (id != id_candidate)
continue;
- }
domain = virGetDomain(conn, name_candidate, uuid_candidate);
- if (!domain) {
+ if (!domain)
goto cleanup;
- }
domain->id = id;
break;
}
- if (!domain) {
+ if (!domain)
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
- }
cleanup:
esxVI_String_Free(&propertyNameList);
char *name = NULL;
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
domain = virGetDomain(conn, name, uuid);
- if (!domain) {
+ if (!domain)
goto cleanup;
- }
/* Only running/suspended virtual machines have an ID != -1 */
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
unsigned char uuid[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"configStatus\0"
domain = virGetDomain(conn, name, uuid);
- if (!domain) {
+ if (!domain)
goto cleanup;
- }
/* Only running/suspended virtual machines have an ID != -1 */
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
goto cleanup;
}
- if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0) {
+ if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0)
goto cleanup;
- }
result = 0;
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
goto cleanup;
}
- if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0) {
+ if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0)
goto cleanup;
- }
result = 0;
ctx = priv->host;
}
- if (esxVI_EnsureSession(ctx) < 0) {
+ if (esxVI_EnsureSession(ctx) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_DynamicProperty *dynamicProperty = NULL;
unsigned long memoryMB = 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return 0;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.hardware.memoryMB") < 0 ||
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
memset(info, 0, sizeof(*info));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"runtime.powerState\0"
memory_limit = dynamicProperty->val->int64;
- if (memory_limit > 0) {
+ if (memory_limit > 0)
memory_limit *= 1024; /* Scale from megabyte to kilobyte */
- }
} else {
VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
}
/* FIXME: Currently no host for a vpx:// connection */
if (priv->host) {
if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
- if (esxVI_Int_Alloc(&counterId) < 0) {
+ if (esxVI_Int_Alloc(&counterId) < 0)
goto cleanup;
- }
counterId->value = priv->usedCpuTimeCounterId;
- if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0)
goto cleanup;
- }
if (esxVI_QueryPerfCounter(priv->host, counterIdList,
&perfCounterInfo) < 0) {
}
}
- if (priv->usedCpuTimeCounterId < 0) {
+ if (priv->usedCpuTimeCounterId < 0)
VIR_WARN("Could not find 'used CPU time' performance counter");
- }
}
/*
querySpec->entity = NULL;
querySpec->format = NULL;
- if (querySpec->metricId) {
+ if (querySpec->metricId)
querySpec->metricId->instance = NULL;
- }
}
#endif
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
return -1;
}
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
maxVcpus = esxDomainGetMaxVcpus(domain);
- if (maxVcpus < 0) {
+ if (maxVcpus < 0)
return -1;
- }
if (nvcpus > maxVcpus) {
virReportError(VIR_ERR_INVALID_ARG,
return -1;
}
- if (priv->maxVcpus > 0) {
+ if (priv->maxVcpus > 0)
return priv->maxVcpus;
- }
priv->maxVcpus = -1;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"capability.maxSupportedVcpus") < 0 ||
memset(&data, 0, sizeof(data));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"config.files.vmPathName\0"
url = virBufferContentAndReset(&buffer);
- if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0) {
+ if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0)
goto cleanup;
- }
data.ctx = priv->primary;
def = virVMXParseConfig(&ctx, priv->xmlopt, vmx);
if (def) {
- if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
def->id = id;
- }
xml = virDomainDefFormat(def, flags);
}
cleanup:
- if (!url) {
+ if (!url)
virBufferFreeAndReset(&buffer);
- }
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachine);
def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig);
- if (def) {
+ if (def)
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
- }
virDomainDefFree(def);
virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion
(priv->primary->productLine, priv->primary->productVersion);
- if (virtualHW_version < 0) {
+ if (virtualHW_version < 0)
return NULL;
- }
def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt,
1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE);
- if (!def) {
+ if (!def)
return NULL;
- }
data.ctx = priv->primary;
data.datastorePathWithoutFileName = NULL;
int count = 0;
size_t i;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
goto cleanup;
}
- if (powerState == esxVI_VirtualMachinePowerState_PoweredOn) {
+ if (powerState == esxVI_VirtualMachinePowerState_PoweredOn)
continue;
- }
names[count] = NULL;
++count;
- if (count >= maxnames) {
+ if (count >= maxnames)
break;
- }
}
success = true;
cleanup:
if (! success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
return esxVI_LookupNumberOfDomainsByPowerState
(priv->primary, esxVI_VirtualMachinePowerState_PoweredOn, true);
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
memset(&data, 0, sizeof(data));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
/* Parse domain XML */
def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE);
- if (!def) {
+ if (!def)
return NULL;
- }
/* Check if an existing domain should be edited */
if (esxVI_LookupVirtualMachineByUuid(priv->primary, def->uuid, NULL,
virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion
(priv->primary->productLine, priv->primary->productVersion);
- if (virtualHW_version < 0) {
+ if (virtualHW_version < 0)
goto cleanup;
- }
data.ctx = priv->primary;
data.datastorePathWithoutFileName = NULL;
vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version);
- if (!vmx) {
+ if (!vmx)
goto cleanup;
- }
/*
* Build VMX datastore URL. Use the source of the first file-based harddisk
escapedName = esxUtil_EscapeDatastoreItem(def->name);
- if (!escapedName) {
+ if (!escapedName)
goto cleanup;
- }
virBufferURIEncodeString(&buffer, escapedName);
virBufferAddLit(&buffer, ".vmx?dcPath=");
/* Upload VMX file */
VIR_DEBUG("Uploading .vmx config, url='%s' vmx='%s'", url, vmx);
- if (esxVI_CURL_Upload(priv->primary->curl, url, vmx) < 0) {
+ if (esxVI_CURL_Upload(priv->primary->curl, url, vmx) < 0)
goto cleanup;
- }
/* Register the domain */
if (directoryName) {
domain = virGetDomain(conn, def->name, def->uuid);
- if (domain) {
+ if (domain)
domain->id = -1;
- }
/* FIXME: Add proper rollback in case of an error */
cleanup:
- if (!url) {
+ if (!url)
virBufferFreeAndReset(&buffer);
- }
virDomainDefFree(def);
VIR_FREE(vmx);
ctx = priv->host;
}
- if (esxVI_EnsureSession(ctx) < 0) {
+ if (esxVI_EnsureSession(ctx) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
goto cleanup;
}
- if (esxVI_UnregisterVM(ctx, virtualMachine->obj) < 0) {
+ if (esxVI_UnregisterVM(ctx, virtualMachine->obj) < 0)
goto cleanup;
- }
result = 0;
*autostart = 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* Check general autostart config */
- if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) {
+ if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0)
goto cleanup;
- }
if (defaults->enabled != esxVI_Boolean_True) {
/* Autostart is disabled in general, exit early here */
}
/* Check specific autostart config */
- if (esxVI_LookupAutoStartPowerInfoList(priv->primary, &powerInfoList) < 0) {
+ if (esxVI_LookupAutoStartPowerInfoList(priv->primary, &powerInfoList) < 0)
goto cleanup;
- }
if (!powerInfoList) {
/* powerInfo list is empty, exit early here */
for (powerInfo = powerInfoList; powerInfo;
powerInfo = powerInfo->_next) {
if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) {
- if (STRCASEEQ(powerInfo->startAction, "powerOn")) {
+ if (STRCASEEQ(powerInfo->startAction, "powerOn"))
*autostart = 1;
- }
break;
}
esxVI_AutoStartPowerInfo *powerInfo = NULL;
esxVI_AutoStartPowerInfo *newPowerInfo = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
NULL, &virtualMachine,
* autostart. If it's enabled then the autostart behavior depends on
* the per-domain autostart config.
*/
- if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) {
+ if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0)
goto cleanup;
- }
if (defaults->enabled != esxVI_Boolean_True) {
/*
}
/* Enable autostart in general */
- if (esxVI_AutoStartDefaults_Alloc(&spec->defaults) < 0) {
+ if (esxVI_AutoStartDefaults_Alloc(&spec->defaults) < 0)
goto cleanup;
- }
spec->defaults->enabled = esxVI_Boolean_True;
}
if (VIR_STRDUP(type, "allocation") < 0)
return NULL;
- if (nparams) {
+ if (nparams)
*nparams = 3; /* reservation, limit, shares */
- }
return type;
}
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueListToList(&propertyNameList,
"config.cpuAllocation.reservation\0"
NULL) < 0)
return -1;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
for (i = 0; i < nparams; ++i) {
if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_RESERVATION)) {
- if (esxVI_Long_Alloc(&spec->cpuAllocation->reservation) < 0) {
+ if (esxVI_Long_Alloc(&spec->cpuAllocation->reservation) < 0)
goto cleanup;
- }
if (params[i].value.l < 0) {
virReportError(VIR_ERR_INVALID_ARG,
spec->cpuAllocation->reservation->value = params[i].value.l;
} else if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_LIMIT)) {
- if (esxVI_Long_Alloc(&spec->cpuAllocation->limit) < 0) {
+ if (esxVI_Long_Alloc(&spec->cpuAllocation->limit) < 0)
goto cleanup;
- }
if (params[i].value.l < -1) {
virReportError(VIR_ERR_INVALID_ARG,
return -1;
}
- if (esxVI_EnsureSession(priv->vCenter) < 0) {
+ if (esxVI_EnsureSession(priv->vCenter) < 0)
return -1;
- }
/* Parse migration URI */
if (!(parsedUri = virURIParse(uri)))
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage = NULL;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return 0;
- }
/* Get memory usage of resource pool */
if (esxVI_String_AppendValueToList(&propertyNameList,
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE |
VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
def = virDomainSnapshotDefParseString(xmlDesc, priv->caps,
priv->xmlopt, 0, 0);
- if (!def) {
+ if (!def)
return NULL;
- }
if (def->ndisks) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
memset(&def, 0, sizeof(def));
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* ESX snapshots do not require libvirt to maintain any metadata. */
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA)
return -1;
}
- if (nameslen == 0 || (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA)) {
+ if (nameslen == 0 || (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA))
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0) {
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) != 0;
leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotTreeList) < 0 ||
return -1;
}
- if (nameslen == 0) {
+ if (nameslen == 0)
return 0;
- }
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotTreeList) < 0 ||
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0 ||
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- }
if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* Check that snapshot exists. */
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
/* Check that snapshot exists. If so, there is no metadata. */
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1);
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
- if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) {
+ if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)
removeChildren = esxVI_Boolean_True;
- }
if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
NULL) < 0)
return -1;
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
for (i = 0; i < nparams; ++i) {
if (STREQ(params[i].field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) {
- if (esxVI_Long_Alloc(&spec->memoryAllocation->reservation) < 0) {
+ if (esxVI_Long_Alloc(&spec->memoryAllocation->reservation) < 0)
goto cleanup;
- }
spec->memoryAllocation->reservation->value =
VIR_DIV_UP(params[i].value.ul, 1024); /* Scale from kilobytes to megabytes */
return 0;
}
- if (esxVI_EnsureSession(priv->primary) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- }
if (esxVI_String_AppendValueToList
(&propertyNameList, "config.memoryAllocation.reservation") < 0 ||
cleanup:
if (doms) {
- for (id = 0; id < count; id++) {
+ for (id = 0; id < count; id++)
virDomainFree(doms[id]);
- }
VIR_FREE(doms);
}