[PATCH] esx: Convert autoAnswer from esxVI_Boolean to a simple bool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just true/false is good enough for it. Also use it directly from the
parsed URI instead of caching it in esxPrivate.
---
 src/esx/esx_driver.c         |   52 ++++++++++++++++++++---------------------
 src/esx/esx_private.h        |    1 -
 src/esx/esx_storage_driver.c |   12 ++++++---
 src/esx/esx_vi.c             |   15 +++++------
 src/esx/esx_vi.h             |    8 +++---
 5 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 1f8f90b..89240dc 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -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;
     }
@@ -2468,7 +2466,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;
@@ -2480,7 +2478,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;
     }
@@ -2896,7 +2894,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;
@@ -2912,7 +2910,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;
     }
@@ -3134,7 +3132,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;
     }
@@ -3599,7 +3597,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;
@@ -3685,7 +3683,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;
     }
@@ -3819,7 +3817,7 @@ esxDomainMigratePerform(virDomainPtr domain,
     /* Lookup VirtualMachine */
     if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
           (priv->vCenter, domain->uuid, NULL, &virtualMachine,
-           priv->autoAnswer) < 0) {
+           priv->parsedUri->autoAnswer) < 0) {
         goto cleanup;
     }
 
@@ -3856,7 +3854,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;
     }
@@ -4063,7 +4061,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,
@@ -4084,7 +4082,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;
     }
@@ -4345,7 +4343,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;
     }
@@ -4404,7 +4402,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;
     }
@@ -4449,7 +4447,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;
@@ -4475,7 +4473,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;
     }
diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h
index 7ce237e..3fcc001 100644
--- a/src/esx/esx_private.h
+++ b/src/esx/esx_private.h
@@ -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;
 
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index 9e4dd9e..d45b13f 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -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;
     }
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 73413c5..7f0b0a8 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -2482,7 +2482,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;
@@ -2884,7 +2884,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;
@@ -3204,7 +3204,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;
     }
@@ -3349,7 +3349,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;
     }
@@ -3554,7 +3554,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;
@@ -3597,7 +3597,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, "
@@ -3662,8 +3662,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;
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index e3d096e..9e37d86 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -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);
 
-- 
1.7.0.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]