Re: [libvirt] [PATCHv3 3/6] esx: reject unknown flags

2011-07-15 Thread Matthias Bolte
2011/7/15 Eric Blake ebl...@redhat.com:
 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.
 ---

 v3: address concerns in v2 about migration flags

  src/esx/esx_device_monitor.c   |    4 +++-
  src/esx/esx_driver.c           |   35 ---
  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, 46 insertions(+), 13 deletions(-)

ACK.

-- 
Matthias Bolte
http://photron.blogspot.com

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

[libvirt] [PATCHv3 3/6] esx: reject unknown flags

2011-07-14 Thread Eric Blake
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.
---

v3: address concerns in v2 about migration flags

 src/esx/esx_device_monitor.c   |4 +++-
 src/esx/esx_driver.c   |   35 ---
 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, 46 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 4643a32..80d687b 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;
 }
@@ -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