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

Re: [libvirt] [PATCH 15/20] test: reject unknown flags



On Wed, Jul 06, 2011 at 05:23:58PM -0600, Eric Blake wrote:
> * src/test/test_driver.c (testOpen, testDomainCoreDump)
> (testOpenNetwork, testNetworkGetXMLDesc, testOpenInterface)
> (testInterfaceChangeBegin, testInterfaceChangeCommit)
> (testInterfaceChangeRollback, testInterfaceGetXMLDesc)
> (testInterfaceDefineXML, testInterfaceCreate)
> (testInterfaceDestroy, testStorageOpen, testStoragePoolStart)
> (testStorageFindPoolSources, testStoragePoolCreate)
> (testStoragePoolDefine, testStoragePoolBuild)
> (testStoragePoolDelete, testStoragePoolRefresh)
> (testStoragePoolGetXMLDesc, testStorageVolumeCreateXML)
> (testStorageVolumeCreateXMLFrom, testStorageVolumeDelete)
> (testStorageVolumeGetXMLDesc, testDevMonOpen)
> (testNodeNumOfDevices, testNodeListDevices)
> (testNodeDeviceGetXMLDesc, testNodeDeviceCreateXML)
> (testSecretOpen, testNWFilterOpen): Reject unknown flags.
> ---
>  src/test/test_driver.c |  144 +++++++++++++++++++++++++++++++++++++-----------
>  1 files changed, 112 insertions(+), 32 deletions(-)
> 
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 98daca8..8dac713 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -1099,11 +1099,13 @@ static int testOpenFromFile(virConnectPtr conn,
> 
>  static virDrvOpenStatus testOpen(virConnectPtr conn,
>                                   virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> -                                 unsigned int flags ATTRIBUTE_UNUSED)
> +                                 unsigned int flags)
>  {
>      int ret;
>      testConnPtr privconn;
> 
> +    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
> +
>      if (!conn->uri)
>          return VIR_DRV_OPEN_DECLINED;
> 
> @@ -1904,7 +1906,7 @@ cleanup:
> 
>  static int testDomainCoreDump(virDomainPtr domain,
>                                const char *to,
> -                              unsigned int flags ATTRIBUTE_UNUSED)
> +                              unsigned int flags)
>  {
>      testConnPtr privconn = domain->conn->privateData;
>      int fd = -1;
> @@ -1912,6 +1914,8 @@ static int testDomainCoreDump(virDomainPtr domain,
>      virDomainEventPtr event = NULL;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privdom = virDomainFindByName(&privconn->domains,
>                                    domain->name);
> @@ -2843,7 +2847,10 @@ error:
> 
>  static virDrvOpenStatus testOpenNetwork(virConnectPtr conn,
>                                          virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> -                                        unsigned int flags ATTRIBUTE_UNUSED) {
> +                                        unsigned int flags)
> +{
> +    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
> +
>      if (STRNEQ(conn->driver->name, "Test"))
>          return VIR_DRV_OPEN_DECLINED;
> 
> @@ -3178,12 +3185,14 @@ cleanup:
>  }
> 
>  static char *testNetworkGetXMLDesc(virNetworkPtr network,
> -                                   unsigned int flags ATTRIBUTE_UNUSED)
> +                                   unsigned int flags)
>  {
>      testConnPtr privconn = network->conn->privateData;
>      virNetworkObjPtr privnet;
>      char *ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      privnet = virNetworkFindByName(&privconn->networks,
>                                     network->name);
> @@ -3292,8 +3301,10 @@ cleanup:
> 
>  static virDrvOpenStatus testOpenInterface(virConnectPtr conn,
>                                            virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> -                                          unsigned int flags ATTRIBUTE_UNUSED)
> +                                          unsigned int flags)
>  {
> +    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
> +
>      if (STRNEQ(conn->driver->name, "Test"))
>          return VIR_DRV_OPEN_DECLINED;
> 
> @@ -3476,11 +3487,13 @@ cleanup:
>  }
> 
>  static int testInterfaceChangeBegin(virConnectPtr conn,
> -                                    unsigned int flags ATTRIBUTE_UNUSED)
> +                                    unsigned int flags)
>  {
>      testConnPtr privconn = conn->privateData;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      if (privconn->transaction_running) {
>          testError(VIR_ERR_OPERATION_INVALID,
> @@ -3501,11 +3514,13 @@ cleanup:
>  }
> 
>  static int testInterfaceChangeCommit(virConnectPtr conn,
> -                                     unsigned int flags ATTRIBUTE_UNUSED)
> +                                     unsigned int flags)
>  {
>      testConnPtr privconn = conn->privateData;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
> 
>      if (!privconn->transaction_running) {
> @@ -3526,11 +3541,13 @@ cleanup:
>  }
> 
>  static int testInterfaceChangeRollback(virConnectPtr conn,
> -                                       unsigned int flags ATTRIBUTE_UNUSED)
> +                                       unsigned int flags)
>  {
>      testConnPtr privconn = conn->privateData;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
> 
>      if (!privconn->transaction_running) {
> @@ -3555,12 +3572,14 @@ cleanup:
>  }
> 
>  static char *testInterfaceGetXMLDesc(virInterfacePtr iface,
> -                                     unsigned int flags ATTRIBUTE_UNUSED)
> +                                     unsigned int flags)
>  {
>      testConnPtr privconn = iface->conn->privateData;
>      virInterfaceObjPtr privinterface;
>      char *ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      privinterface = virInterfaceFindByName(&privconn->ifaces,
>                                             iface->name);
> @@ -3581,13 +3600,15 @@ cleanup:
> 
> 
>  static virInterfacePtr testInterfaceDefineXML(virConnectPtr conn, const char *xmlStr,
> -                                              unsigned int flags ATTRIBUTE_UNUSED)
> +                                              unsigned int flags)
>  {
>      testConnPtr privconn = conn->privateData;
>      virInterfaceDefPtr def;
>      virInterfaceObjPtr iface = NULL;
>      virInterfacePtr ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      if ((def = virInterfaceDefParseString(xmlStr)) == NULL)
>          goto cleanup;
> @@ -3631,12 +3652,14 @@ cleanup:
>  }
> 
>  static int testInterfaceCreate(virInterfacePtr iface,
> -                               unsigned int flags ATTRIBUTE_UNUSED)
> +                               unsigned int flags)
>  {
>      testConnPtr privconn = iface->conn->privateData;
>      virInterfaceObjPtr privinterface;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privinterface = virInterfaceFindByName(&privconn->ifaces,
>                                             iface->name);
> @@ -3662,12 +3685,14 @@ cleanup:
>  }
> 
>  static int testInterfaceDestroy(virInterfacePtr iface,
> -                                unsigned int flags ATTRIBUTE_UNUSED)
> +                                unsigned int flags)
>  {
>      testConnPtr privconn = iface->conn->privateData;
>      virInterfaceObjPtr privinterface;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privinterface = virInterfaceFindByName(&privconn->ifaces,
>                                             iface->name);
> @@ -3716,7 +3741,10 @@ static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) {
> 
>  static virDrvOpenStatus testStorageOpen(virConnectPtr conn,
>                                          virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> -                                        unsigned int flags ATTRIBUTE_UNUSED) {
> +                                        unsigned int flags)
> +{
> +    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
> +
>      if (STRNEQ(conn->driver->name, "Test"))
>          return VIR_DRV_OPEN_DECLINED;
> 
> @@ -3921,11 +3949,14 @@ cleanup:
> 
>  static int
>  testStoragePoolStart(virStoragePoolPtr pool,
> -                     unsigned int flags ATTRIBUTE_UNUSED) {
> +                     unsigned int flags)
> +{
>      testConnPtr privconn = pool->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             pool->name);
> @@ -3955,12 +3986,14 @@ static char *
>  testStorageFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
>                             const char *type,
>                             const char *srcSpec,
> -                           unsigned int flags ATTRIBUTE_UNUSED)
> +                           unsigned int flags)
>  {
>      virStoragePoolSourcePtr source = NULL;
>      int pool_type;
>      char *ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      pool_type = virStoragePoolTypeFromString(type);
>      if (!pool_type) {
>          testError(VIR_ERR_INTERNAL_ERROR,
> @@ -4009,12 +4042,15 @@ cleanup:
>  static virStoragePoolPtr
>  testStoragePoolCreate(virConnectPtr conn,
>                        const char *xml,
> -                      unsigned int flags ATTRIBUTE_UNUSED) {
> +                      unsigned int flags)
> +{
>      testConnPtr privconn = conn->privateData;
>      virStoragePoolDefPtr def;
>      virStoragePoolObjPtr pool = NULL;
>      virStoragePoolPtr ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      if (!(def = virStoragePoolDefParseString(xml)))
>          goto cleanup;
> @@ -4052,12 +4088,15 @@ cleanup:
>  static virStoragePoolPtr
>  testStoragePoolDefine(virConnectPtr conn,
>                        const char *xml,
> -                      unsigned int flags ATTRIBUTE_UNUSED) {
> +                      unsigned int flags)
> +{
>      testConnPtr privconn = conn->privateData;
>      virStoragePoolDefPtr def;
>      virStoragePoolObjPtr pool = NULL;
>      virStoragePoolPtr ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      if (!(def = virStoragePoolDefParseString(xml)))
>          goto cleanup;
> @@ -4119,11 +4158,14 @@ cleanup:
> 
>  static int
>  testStoragePoolBuild(virStoragePoolPtr pool,
> -                     unsigned int flags ATTRIBUTE_UNUSED) {
> +                     unsigned int flags)
> +{
>      testConnPtr privconn = pool->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             pool->name);
> @@ -4187,11 +4229,14 @@ cleanup:
> 
>  static int
>  testStoragePoolDelete(virStoragePoolPtr pool,
> -                      unsigned int flags ATTRIBUTE_UNUSED) {
> +                      unsigned int flags)
> +{
>      testConnPtr privconn = pool->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             pool->name);
> @@ -4219,11 +4264,14 @@ cleanup:
> 
>  static int
>  testStoragePoolRefresh(virStoragePoolPtr pool,
> -                       unsigned int flags ATTRIBUTE_UNUSED) {
> +                       unsigned int flags)
> +{
>      testConnPtr privconn = pool->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             pool->name);
> @@ -4283,11 +4331,14 @@ cleanup:
> 
>  static char *
>  testStoragePoolGetXMLDesc(virStoragePoolPtr pool,
> -                          unsigned int flags ATTRIBUTE_UNUSED) {
> +                          unsigned int flags)
> +{
>      testConnPtr privconn = pool->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      char *ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             pool->name);
> @@ -4562,12 +4613,15 @@ testStorageVolumeLookupByPath(virConnectPtr conn,
>  static virStorageVolPtr
>  testStorageVolumeCreateXML(virStoragePoolPtr pool,
>                             const char *xmldesc,
> -                           unsigned int flags ATTRIBUTE_UNUSED) {
> +                           unsigned int flags)
> +{
>      testConnPtr privconn = pool->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      virStorageVolDefPtr privvol = NULL;
>      virStorageVolPtr ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             pool->name);
> @@ -4643,12 +4697,15 @@ static virStorageVolPtr
>  testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool,
>                                 const char *xmldesc,
>                                 virStorageVolPtr clonevol,
> -                               unsigned int flags ATTRIBUTE_UNUSED) {
> +                               unsigned int flags)
> +{
>      testConnPtr privconn = pool->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      virStorageVolDefPtr privvol = NULL, origvol = NULL;
>      virStorageVolPtr ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             pool->name);
> @@ -4732,13 +4789,16 @@ cleanup:
> 
>  static int
>  testStorageVolumeDelete(virStorageVolPtr vol,
> -                        unsigned int flags ATTRIBUTE_UNUSED) {
> +                        unsigned int flags)
> +{
>      testConnPtr privconn = vol->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      virStorageVolDefPtr privvol;
>      int i;
>      int ret = -1;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             vol->pool);
> @@ -4857,12 +4917,15 @@ cleanup:
> 
>  static char *
>  testStorageVolumeGetXMLDesc(virStorageVolPtr vol,
> -                            unsigned int flags ATTRIBUTE_UNUSED) {
> +                            unsigned int flags)
> +{
>      testConnPtr privconn = vol->conn->privateData;
>      virStoragePoolObjPtr privpool;
>      virStorageVolDefPtr privvol;
>      char *ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(privconn);
>      privpool = virStoragePoolObjFindByName(&privconn->pools,
>                                             vol->pool);
> @@ -4942,7 +5005,10 @@ cleanup:
>  /* Node device implementations */
>  static virDrvOpenStatus testDevMonOpen(virConnectPtr conn,
>                                         virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> -                                       unsigned int flags ATTRIBUTE_UNUSED) {
> +                                       unsigned int flags)
> +{
> +    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
> +
>      if (STRNEQ(conn->driver->name, "Test"))
>          return VIR_DRV_OPEN_DECLINED;
> 
> @@ -4958,12 +5024,14 @@ static int testDevMonClose(virConnectPtr conn) {
>  static int
>  testNodeNumOfDevices(virConnectPtr conn,
>                       const char *cap,
> -                     unsigned int flags ATTRIBUTE_UNUSED)
> +                     unsigned int flags)
>  {
>      testConnPtr driver = conn->privateData;
>      int ndevs = 0;
>      unsigned int i;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(driver);
>      for (i = 0; i < driver->devs.count; i++)
>          if ((cap == NULL) ||
> @@ -4979,12 +5047,14 @@ testNodeListDevices(virConnectPtr conn,
>                      const char *cap,
>                      char **const names,
>                      int maxnames,
> -                    unsigned int flags ATTRIBUTE_UNUSED)
> +                    unsigned int flags)
>  {
>      testConnPtr driver = conn->privateData;
>      int ndevs = 0;
>      unsigned int i;
> 
> +    virCheckFlags(0, -1);
> +
>      testDriverLock(driver);
>      for (i = 0; i < driver->devs.count && ndevs < maxnames; i++) {
>          virNodeDeviceObjLock(driver->devs.objs[i]);
> @@ -5035,12 +5105,14 @@ cleanup:
> 
>  static char *
>  testNodeDeviceGetXMLDesc(virNodeDevicePtr dev,
> -                         unsigned int flags ATTRIBUTE_UNUSED)
> +                         unsigned int flags)
>  {
>      testConnPtr driver = dev->conn->privateData;
>      virNodeDeviceObjPtr obj;
>      char *ret = NULL;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(driver);
>      obj = virNodeDeviceFindByName(&driver->devs, dev->name);
>      testDriverUnlock(driver);
> @@ -5166,7 +5238,7 @@ cleanup:
>  static virNodeDevicePtr
>  testNodeDeviceCreateXML(virConnectPtr conn,
>                          const char *xmlDesc,
> -                        unsigned int flags ATTRIBUTE_UNUSED)
> +                        unsigned int flags)
>  {
>      testConnPtr driver = conn->privateData;
>      virNodeDeviceDefPtr def = NULL;
> @@ -5176,6 +5248,8 @@ testNodeDeviceCreateXML(virConnectPtr conn,
>      virNodeDevicePtr dev = NULL;
>      virNodeDevCapsDefPtr caps;
> 
> +    virCheckFlags(0, NULL);
> +
>      testDriverLock(driver);
> 
>      def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE);
> @@ -5396,7 +5470,10 @@ static void testDomainEventQueue(testConnPtr driver,
> 
>  static virDrvOpenStatus testSecretOpen(virConnectPtr conn,
>                                         virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> -                                       unsigned int flags ATTRIBUTE_UNUSED) {
> +                                       unsigned int flags)
> +{
> +    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
> +
>      if (STRNEQ(conn->driver->name, "Test"))
>          return VIR_DRV_OPEN_DECLINED;
> 
> @@ -5412,7 +5489,10 @@ static int testSecretClose(virConnectPtr conn) {
> 
>  static virDrvOpenStatus testNWFilterOpen(virConnectPtr conn,
>                                           virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> -                                         unsigned int flags ATTRIBUTE_UNUSED) {
> +                                         unsigned int flags)
> +{
> +    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
> +
>      if (STRNEQ(conn->driver->name, "Test"))
>          return VIR_DRV_OPEN_DECLINED;
> 

ACK

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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