esx: Convert autoAnswer from esxVI_Boolean to a simple bool

Just true/false is good enough for it. Also use it directly from the
parsed URI instead of caching it in esxPrivate.
This commit is contained in:
Matthias Bolte 2011-05-01 21:57:44 +02:00
parent 6bf31327c6
commit 93f31b073d
5 changed files with 44 additions and 44 deletions

View File

@ -940,8 +940,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
priv->maxVcpus = -1;
priv->supportsVMotion = esxVI_Boolean_Undefined;
priv->supportsLongMode = esxVI_Boolean_Undefined;
priv->autoAnswer = priv->parsedUri->autoAnswer ? esxVI_Boolean_True
: esxVI_Boolean_False;
priv->usedCpuTimeCounterId = -1;
/*
@ -1721,7 +1719,7 @@ esxDomainSuspend(virDomainPtr domain)
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
}
@ -1735,7 +1733,7 @@ esxDomainSuspend(virDomainPtr domain)
if (esxVI_SuspendVM_Task(priv->primary, virtualMachine->obj, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -1779,7 +1777,7 @@ esxDomainResume(virDomainPtr domain)
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
}
@ -1793,7 +1791,7 @@ esxDomainResume(virDomainPtr domain)
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -1930,7 +1928,7 @@ esxDomainDestroy(virDomainPtr domain)
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(ctx, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
}
@ -1944,7 +1942,7 @@ esxDomainDestroy(virDomainPtr domain)
if (esxVI_PowerOffVM_Task(ctx, virtualMachine->obj, &task) < 0 ||
esxVI_WaitForTaskCompletion(ctx, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -2057,7 +2055,7 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
}
@ -2081,7 +2079,7 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -2124,7 +2122,7 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0 ||
esxVI_Long_Alloc(&spec->memoryAllocation->limit) < 0) {
@ -2138,7 +2136,7 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -2538,7 +2536,7 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_Int_Alloc(&spec->numCPUs) < 0) {
goto cleanup;
@ -2550,7 +2548,7 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -2966,7 +2964,7 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0 ||
esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, NULL) < 0) {
goto cleanup;
@ -2982,7 +2980,7 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -3204,7 +3202,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, def->uuid,
esxVI_Occurrence_OptionalItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -3669,7 +3667,7 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->cpuAllocation) < 0) {
goto cleanup;
@ -3755,7 +3753,7 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -3889,7 +3887,7 @@ esxDomainMigratePerform(virDomainPtr domain,
/* Lookup VirtualMachine */
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->vCenter, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0) {
priv->parsedUri->autoAnswer) < 0) {
goto cleanup;
}
@ -3926,7 +3924,7 @@ esxDomainMigratePerform(virDomainPtr domain,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->vCenter, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -4133,7 +4131,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,
@ -4154,7 +4152,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
esxVI_Boolean_False, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -4415,7 +4413,7 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags)
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -4474,7 +4472,7 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
removeChildren, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -4519,7 +4517,7 @@ esxDomainSetMemoryParameters(virDomainPtr domain, virMemoryParameterPtr params,
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
priv->parsedUri->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0) {
goto cleanup;
@ -4545,7 +4543,7 @@ esxDomainSetMemoryParameters(virDomainPtr domain, virMemoryParameterPtr params,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}

View File

@ -41,7 +41,6 @@ typedef struct _esxPrivate {
int32_t maxVcpus;
esxVI_Boolean supportsVMotion;
esxVI_Boolean supportsLongMode; /* aka x86_64 */
esxVI_Boolean autoAnswer;
int32_t usedCpuTimeCounterId;
} esxPrivate;

View File

@ -1114,7 +1114,8 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
esxVI_VirtualDiskSpec_DynamicCast(virtualDiskSpec), &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
esxVI_Occurrence_None,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer,
&taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -1315,7 +1316,8 @@ esxStorageVolumeCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
NULL, esxVI_Boolean_False, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
esxVI_Occurrence_None,
priv->autoAnswer, &taskInfoState,
priv->parsedUri->autoAnswer,
&taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -1402,7 +1404,8 @@ esxStorageVolumeDelete(virStorageVolPtr volume, unsigned int flags)
priv->primary->datacenter->_reference,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
esxVI_Occurrence_None, priv->autoAnswer,
esxVI_Occurrence_None,
priv->parsedUri->autoAnswer,
&taskInfoState, &taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -1450,7 +1453,8 @@ esxStorageVolumeWipe(virStorageVolPtr volume, unsigned int flags)
priv->primary->datacenter->_reference,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, NULL,
esxVI_Occurrence_None, priv->autoAnswer,
esxVI_Occurrence_None,
priv->parsedUri->autoAnswer,
&taskInfoState, &taskInfoErrorMessage) < 0) {
goto cleanup;
}

View File

@ -2472,7 +2472,7 @@ int
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(esxVI_Context *ctx, const unsigned char *uuid,
esxVI_String *propertyNameList, esxVI_ObjectContent **virtualMachine,
esxVI_Boolean autoAnswer)
bool autoAnswer)
{
int result = -1;
esxVI_String *completePropertyNameList = NULL;
@ -2874,7 +2874,7 @@ int
esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx,
const unsigned char *uuid,
esxVI_Occurrence occurrence,
esxVI_Boolean autoAnswer,
bool autoAnswer,
esxVI_Boolean *blocked)
{
int result = -1;
@ -3194,7 +3194,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
datastorePathWithoutFileName, searchSpec,
&task) < 0 ||
esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Occurrence_None,
esxVI_Boolean_False, &taskInfoState,
false, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -3339,7 +3339,7 @@ esxVI_LookupDatastoreContentByDatastoreName
datastorePath, searchSpec,
&task) < 0 ||
esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Occurrence_None,
esxVI_Boolean_False, &taskInfoState,
false, &taskInfoState,
&taskInfoErrorMessage) < 0) {
goto cleanup;
}
@ -3544,7 +3544,7 @@ int
esxVI_HandleVirtualMachineQuestion
(esxVI_Context *ctx, esxVI_ManagedObjectReference *virtualMachine,
esxVI_VirtualMachineQuestionInfo *questionInfo,
esxVI_Boolean autoAnswer, esxVI_Boolean *blocked)
bool autoAnswer, esxVI_Boolean *blocked)
{
int result = -1;
esxVI_ElementDescription *elementDescription = NULL;
@ -3587,7 +3587,7 @@ esxVI_HandleVirtualMachineQuestion
possibleAnswers = virBufferContentAndReset(&buffer);
}
if (autoAnswer == esxVI_Boolean_True) {
if (autoAnswer) {
if (possibleAnswers == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Pending question blocks virtual machine execution, "
@ -3652,8 +3652,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
esxVI_ManagedObjectReference *task,
const unsigned char *virtualMachineUuid,
esxVI_Occurrence virtualMachineOccurrence,
esxVI_Boolean autoAnswer,
esxVI_TaskInfoState *finalState,
bool autoAnswer, esxVI_TaskInfoState *finalState,
char **errorMessage)
{
int result = -1;

View File

@ -396,7 +396,7 @@ int esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, const char *name,
int esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(esxVI_Context *ctx, const unsigned char *uuid,
esxVI_String *propertyNameList, esxVI_ObjectContent **virtualMachine,
esxVI_Boolean autoAnswer);
bool autoAnswer);
int esxVI_LookupDatastoreList(esxVI_Context *ctx, esxVI_String *propertyNameList,
esxVI_ObjectContent **datastoreList);
@ -427,7 +427,7 @@ int esxVI_LookupPendingTaskInfoListByVirtualMachine
int esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx,
const unsigned char *uuid,
esxVI_Occurrence occurrence,
esxVI_Boolean autoAnswer,
bool autoAnswer,
esxVI_Boolean *blocked);
int esxVI_LookupRootSnapshotTreeList
@ -463,13 +463,13 @@ int esxVI_HandleVirtualMachineQuestion
(esxVI_Context *ctx,
esxVI_ManagedObjectReference *virtualMachine,
esxVI_VirtualMachineQuestionInfo *questionInfo,
esxVI_Boolean autoAnswer, esxVI_Boolean *blocked);
bool autoAnswer, esxVI_Boolean *blocked);
int esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
esxVI_ManagedObjectReference *task,
const unsigned char *virtualMachineUuid,
esxVI_Occurrence virtualMachineOccurrence,
esxVI_Boolean autoAnswer,
bool autoAnswer,
esxVI_TaskInfoState *finalState,
char **errorMessage);