]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
esx: reject unknown flags
authorEric Blake <eblake@redhat.com>
Wed, 6 Jul 2011 22:14:33 +0000 (16:14 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 15 Jul 2011 22:30:22 +0000 (16:30 -0600)
Silently ignored flags get in the way of new features that
use those flags.

Regarding ESX migration flags - right now, ESX silently enforces
VIR_MIGRATE_PERSIST_DEST, VIR_MIGRATE_UNDEFINE_SOURCE, and
VIR_MIGRATE_LIVE, even if those flags were not supplied; it ignored
other flags.  This patch does not change the implied bits (it permits
but does not require them), but enforces only the supported bits.
If further cleanup is needed to be more particular about migration
flags, that should be a separate patch.

* 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
src/esx/esx_driver.c
src/esx/esx_interface_driver.c
src/esx/esx_network_driver.c
src/esx/esx_nwfilter_driver.c
src/esx/esx_secret_driver.c
src/esx/esx_storage_driver.c

index 51b241386af846b094a8191f20d6778ba726789a..2eba2b087764b99af5b72100aa653b1272a3749e 100644 (file)
 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;
     }
index 4643a3276aadb44e9e2d7d9519d8b9b37af922b1..9b0a541d6d5a830d3f35dbd4681626f929626045 100644 (file)
@@ -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;
     }
@@ -2701,6 +2705,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     virDomainDefPtr def = NULL;
     char *xml = NULL;
 
+    /* Flags checked by virDomainDefFormat */
+
     memset(&data, 0, sizeof (data));
 
     if (esxVI_EnsureSession(priv->primary) < 0) {
@@ -2798,7 +2804,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;
@@ -2806,6 +2812,8 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
     virDomainDefPtr def = NULL;
     char *xml = NULL;
 
+    virCheckFlags(0, NULL);
+
     memset(&data, 0, sizeof (data));
 
     if (STRNEQ(nativeFormat, "vmware-vmx")) {
@@ -2838,7 +2846,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;
@@ -2847,6 +2855,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
     virDomainDefPtr def = NULL;
     char *vmx = NULL;
 
+    virCheckFlags(0, NULL);
+
     memset(&data, 0, sizeof (data));
 
     if (STRNEQ(nativeFormat, "vmware-vmx")) {
@@ -3831,6 +3841,12 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
     return esxDomainSetSchedulerParametersFlags(domain, params, nparams, 0);
 }
 
+/* The subset of migration flags we are able to support.  */
+#define ESX_MIGRATION_FLAGS                     \
+    (VIR_MIGRATE_PERSIST_DEST |                 \
+     VIR_MIGRATE_UNDEFINE_SOURCE |              \
+     VIR_MIGRATE_LIVE |                         \
+     VIR_MIGRATE_PAUSED)
 
 static int
 esxDomainMigratePrepare(virConnectPtr dconn,
@@ -3838,12 +3854,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(ESX_MIGRATION_FLAGS, -1);
+
     if (uri_in == NULL) {
         if (virAsprintf(uri_out, "vpxmigr://%s/%s/%s",
                         priv->vCenter->ipAddress,
@@ -3864,7 +3882,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)
 {
@@ -3882,6 +3900,8 @@ esxDomainMigratePerform(virDomainPtr domain,
     esxVI_TaskInfoState taskInfoState;
     char *taskInfoErrorMessage = NULL;
 
+    virCheckFlags(ESX_MIGRATION_FLAGS, -1);
+
     if (priv->vCenter == NULL) {
         ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
                   _("Migration not possible without a vCenter"));
@@ -4010,8 +4030,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(ESX_MIGRATION_FLAGS, NULL);
+
     return esxDomainLookupByName(dconn, dname);
 }
 
index 3d23d0f63b9af468b115fc763a068451234ac7b8..5713137007e525132ae43923d7a4fc4325794957 100644 (file)
 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;
     }
index f8a3ede81f6d3489c2b5d1b56c13244ba75ee694..224c76453ceac7d6f9f888f121c186098d3c8124 100644 (file)
 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;
     }
index d7fa15aedd0134ccb04646cff77594304e5376a2..6056d6d26e8992452294d3a6961716663b804b26 100644 (file)
 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;
     }
index 820f4b1d48108c7c73fe47e4a47a4b547eb5f03a..c37b62d9e68994520c50917abcd0da120e8cbdc0 100644 (file)
 
 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;
     }
index 528159a5d4b253d62a962131bc7a90b7c8c761c7..a56536d578dc862581adcf8b36dc4435c1c5e17e 100644 (file)
@@ -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;
     }