[PATCHv2 08/27] esx: reject unknown flags

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

 



Silently ignored flags get in the way of new features that
use those flags.

* src/esx/esx_device_monitor.c (esxDeviceOpen): Reject unknown
flags.
* src/esx/esx_driver.c (esxOpen, esxDomainReboot)
(esxDomainXMLFromNative, esxDomainXMLToNative)
(esxDomainMigratePrepare, esxDomainMigratePerform)
(esxDomainMigrateFinish): Likewise.
* src/esx/esx_interface_driver.c (esxInterfaceOpen): Likewise.
* src/esx/esx_network_driver.c (esxNetworkOpen): Likewise.
* src/esx/esx_nwfilter_driver.c (esxNWFilterOpen): Likewise.
* src/esx/esx_secret_driver.c (esxSecretOpen): Likewise.
* src/esx/esx_storage_driver.c (esxStorageOpen): Likewise.
---
 src/esx/esx_device_monitor.c   |    4 +++-
 src/esx/esx_driver.c           |   28 +++++++++++++++++++++-------
 src/esx/esx_interface_driver.c |    4 +++-
 src/esx/esx_network_driver.c   |    4 +++-
 src/esx/esx_nwfilter_driver.c  |    4 +++-
 src/esx/esx_secret_driver.c    |    4 +++-
 src/esx/esx_storage_driver.c   |    4 +++-
 7 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c
index 51b2413..2eba2b0 100644
--- a/src/esx/esx_device_monitor.c
+++ b/src/esx/esx_device_monitor.c
@@ -42,8 +42,10 @@
 static virDrvOpenStatus
 esxDeviceOpen(virConnectPtr conn,
               virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-              unsigned int flags ATTRIBUTE_UNUSED)
+              unsigned int flags)
 {
+    virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
     if (conn->driver->no != VIR_DRV_ESX) {
         return VIR_DRV_OPEN_DECLINED;
     }
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index f68ede0..86dc250 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -935,13 +935,15 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
  */
 static virDrvOpenStatus
 esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
-        unsigned int flags ATTRIBUTE_UNUSED)
+        unsigned int flags)
 {
     virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
     esxPrivate *priv = NULL;
     char *potentialVCenterIpAddress = NULL;
     char vCenterIpAddress[NI_MAXHOST] = "";

+    virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
     /* 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, "vpx") &&
@@ -1890,7 +1892,7 @@ esxDomainShutdown(virDomainPtr domain)


 static int
-esxDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
+esxDomainReboot(virDomainPtr domain, unsigned int flags)
 {
     int result = -1;
     esxPrivate *priv = domain->conn->privateData;
@@ -1898,6 +1900,8 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
     esxVI_String *propertyNameList = NULL;
     esxVI_VirtualMachinePowerState powerState;

+    virCheckFlags(0, -1);
+
     if (esxVI_EnsureSession(priv->primary) < 0) {
         return -1;
     }
@@ -2796,7 +2800,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
 static char *
 esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
                        const char *nativeConfig,
-                       unsigned int flags ATTRIBUTE_UNUSED)
+                       unsigned int flags)
 {
     esxPrivate *priv = conn->privateData;
     virVMXContext ctx;
@@ -2804,6 +2808,8 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
     virDomainDefPtr def = NULL;
     char *xml = NULL;

+    virCheckFlags(0, NULL);
+
     if (STRNEQ(nativeFormat, "vmware-vmx")) {
         ESX_ERROR(VIR_ERR_INVALID_ARG,
                   _("Unsupported config format '%s'"), nativeFormat);
@@ -2834,7 +2840,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
 static char *
 esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
                      const char *domainXml,
-                     unsigned int flags ATTRIBUTE_UNUSED)
+                     unsigned int flags)
 {
     esxPrivate *priv = conn->privateData;
     int virtualHW_version;
@@ -2843,6 +2849,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
     virDomainDefPtr def = NULL;
     char *vmx = NULL;

+    virCheckFlags(0, NULL);
+
     if (STRNEQ(nativeFormat, "vmware-vmx")) {
         ESX_ERROR(VIR_ERR_INVALID_ARG,
                   _("Unsupported config format '%s'"), nativeFormat);
@@ -3829,12 +3837,14 @@ esxDomainMigratePrepare(virConnectPtr dconn,
                         int *cookielen ATTRIBUTE_UNUSED,
                         const char *uri_in ATTRIBUTE_UNUSED,
                         char **uri_out,
-                        unsigned long flags ATTRIBUTE_UNUSED,
+                        unsigned long flags,
                         const char *dname ATTRIBUTE_UNUSED,
                         unsigned long resource ATTRIBUTE_UNUSED)
 {
     esxPrivate *priv = dconn->privateData;

+    virCheckFlags(0, -1);
+
     if (uri_in == NULL) {
         if (virAsprintf(uri_out, "vpxmigr://%s/%s/%s",
                         priv->vCenter->ipAddress,
@@ -3855,7 +3865,7 @@ esxDomainMigratePerform(virDomainPtr domain,
                         const char *cookie ATTRIBUTE_UNUSED,
                         int cookielen ATTRIBUTE_UNUSED,
                         const char *uri,
-                        unsigned long flags ATTRIBUTE_UNUSED,
+                        unsigned long flags,
                         const char *dname,
                         unsigned long bandwidth ATTRIBUTE_UNUSED)
 {
@@ -3873,6 +3883,8 @@ esxDomainMigratePerform(virDomainPtr domain,
     esxVI_TaskInfoState taskInfoState;
     char *taskInfoErrorMessage = NULL;

+    virCheckFlags(0, -1);
+
     if (priv->vCenter == NULL) {
         ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
                   _("Migration not possible without a vCenter"));
@@ -4001,8 +4013,10 @@ esxDomainMigrateFinish(virConnectPtr dconn, const char *dname,
                        const char *cookie ATTRIBUTE_UNUSED,
                        int cookielen ATTRIBUTE_UNUSED,
                        const char *uri ATTRIBUTE_UNUSED,
-                       unsigned long flags ATTRIBUTE_UNUSED)
+                       unsigned long flags)
 {
+    virCheckFlags(0, NULL);
+
     return esxDomainLookupByName(dconn, dname);
 }

diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index 3d23d0f..5713137 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -42,8 +42,10 @@
 static virDrvOpenStatus
 esxInterfaceOpen(virConnectPtr conn,
                  virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-                 unsigned int flags ATTRIBUTE_UNUSED)
+                 unsigned int flags)
 {
+    virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
     if (conn->driver->no != VIR_DRV_ESX) {
         return VIR_DRV_OPEN_DECLINED;
     }
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index f8a3ede..224c764 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -42,8 +42,10 @@
 static virDrvOpenStatus
 esxNetworkOpen(virConnectPtr conn,
                virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-               unsigned int flags ATTRIBUTE_UNUSED)
+               unsigned int flags)
 {
+    virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
     if (conn->driver->no != VIR_DRV_ESX) {
         return VIR_DRV_OPEN_DECLINED;
     }
diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c
index d7fa15a..6056d6d 100644
--- a/src/esx/esx_nwfilter_driver.c
+++ b/src/esx/esx_nwfilter_driver.c
@@ -42,8 +42,10 @@
 static virDrvOpenStatus
 esxNWFilterOpen(virConnectPtr conn,
                 virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-                unsigned int flags ATTRIBUTE_UNUSED)
+                unsigned int flags)
 {
+    virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
     if (conn->driver->no != VIR_DRV_ESX) {
         return VIR_DRV_OPEN_DECLINED;
     }
diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c
index 820f4b1..c37b62d 100644
--- a/src/esx/esx_secret_driver.c
+++ b/src/esx/esx_secret_driver.c
@@ -40,8 +40,10 @@

 static virDrvOpenStatus
 esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-              unsigned int flags ATTRIBUTE_UNUSED)
+              unsigned int flags)
 {
+    virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
     if (conn->driver->no != VIR_DRV_ESX) {
         return VIR_DRV_OPEN_DECLINED;
     }
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index 528159a..a56536d 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -104,8 +104,10 @@ esxStoragePoolLookupType(esxVI_Context *ctx, const char *poolName,
 static virDrvOpenStatus
 esxStorageOpen(virConnectPtr conn,
                virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-               unsigned int flags ATTRIBUTE_UNUSED)
+               unsigned int flags)
 {
+    virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
     if (conn->driver->no != VIR_DRV_ESX) {
         return VIR_DRV_OPEN_DECLINED;
     }
-- 
1.7.4.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]