Re: [PATCH 08/19] storage: Use consistent variable names for driver

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

 



On Tue, May 09, 2017 at 11:30:15AM -0400, John Ferlan wrote:
> A virStoragePoolObjPtr will be an 'obj'.
> 
> A virStoragePoolPtr will be a 'pool'.
> 
> A virStorageVolPtr will be a 'vol'.
> 
> A virStorageVolDefPtr will be a 'voldef'.
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/storage/storage_driver.c | 1158 +++++++++++++++++++++---------------------
>  src/storage/storage_driver.h |    4 +-
>  2 files changed, 582 insertions(+), 580 deletions(-)
> 
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index 2103ed1..6122396 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -87,45 +87,45 @@ static void storageDriverUnlock(void)
>   * pools are removed.
>   */
>  static void
> -virStoragePoolUpdateInactive(virStoragePoolObjPtr *poolptr)
> +virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr)
>  {
> -    virStoragePoolObjPtr pool = *poolptr;
> +    virStoragePoolObjPtr obj = *objptr;
>  
> -    if (pool->configFile == NULL) {
> -        virStoragePoolObjRemove(&driver->pools, pool);
> -        *poolptr = NULL;
> -    } else if (pool->newDef) {
> -        virStoragePoolDefFree(pool->def);
> -        pool->def = pool->newDef;
> -        pool->newDef = NULL;
> +    if (obj->configFile == NULL) {
> +        virStoragePoolObjRemove(&driver->pools, obj);
> +        *objptr = NULL;
> +    } else if (obj->newDef) {
> +        virStoragePoolDefFree(obj->def);
> +        obj->def = obj->newDef;
> +        obj->newDef = NULL;
>      }
>  }
>  
>  
>  static void
> -storagePoolUpdateState(virStoragePoolObjPtr pool)
> +storagePoolUpdateState(virStoragePoolObjPtr obj)
>  {
>      bool active = false;
>      virStorageBackendPtr backend;
>      char *stateFile;
>  
>      if (!(stateFile = virFileBuildPath(driver->stateDir,
> -                                       pool->def->name, ".xml")))
> +                                       obj->def->name, ".xml")))
>          goto cleanup;
>  
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
> +    if ((backend = virStorageBackendForType(obj->def->type)) == NULL) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("Missing backend %d"), pool->def->type);
> +                       _("Missing backend %d"), obj->def->type);
>          goto cleanup;
>      }
>  
>      /* Backends which do not support 'checkPool' are considered
>       * inactive by default. */
>      if (backend->checkPool &&
> -        backend->checkPool(pool, &active) < 0) {
> +        backend->checkPool(obj, &active) < 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("Failed to initialize storage pool '%s': %s"),
> -                       pool->def->name, virGetLastErrorMessage());
> +                       obj->def->name, virGetLastErrorMessage());
>          active = false;
>      }
>  
> @@ -134,21 +134,21 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
>       * continue with other pools.
>       */
>      if (active) {
> -        virStoragePoolObjClearVols(pool);
> -        if (backend->refreshPool(NULL, pool) < 0) {
> +        virStoragePoolObjClearVols(obj);
> +        if (backend->refreshPool(NULL, obj) < 0) {
>              if (backend->stopPool)
> -                backend->stopPool(NULL, pool);
> +                backend->stopPool(NULL, obj);
>              virReportError(VIR_ERR_INTERNAL_ERROR,
>                             _("Failed to restart storage pool '%s': %s"),
> -                           pool->def->name, virGetLastErrorMessage());
> +                           obj->def->name, virGetLastErrorMessage());
>              active = false;
>          }
>      }
>  
> -    pool->active = active;
> +    obj->active = active;
>  
> -    if (!pool->active)
> -        virStoragePoolUpdateInactive(&pool);
> +    if (!obj->active)
> +        virStoragePoolUpdateInactive(&obj);
>  
>   cleanup:
>      if (!active && stateFile)
> @@ -164,11 +164,11 @@ storagePoolUpdateAllState(void)
>      size_t i;
>  
>      for (i = 0; i < driver->pools.count; i++) {
> -        virStoragePoolObjPtr pool = driver->pools.objs[i];
> +        virStoragePoolObjPtr obj = driver->pools.objs[i];
>  
> -        virStoragePoolObjLock(pool);
> -        storagePoolUpdateState(pool);
> -        virStoragePoolObjUnlock(pool);
> +        virStoragePoolObjLock(obj);
> +        storagePoolUpdateState(obj);
> +        virStoragePoolObjUnlock(obj);
>      }
>  }
>  
> @@ -186,24 +186,24 @@ storageDriverAutostart(void)
>      /* Ignoring NULL conn - let backends decide */
>  
>      for (i = 0; i < driver->pools.count; i++) {
> -        virStoragePoolObjPtr pool = driver->pools.objs[i];
> +        virStoragePoolObjPtr obj = driver->pools.objs[i];
>          virStorageBackendPtr backend;
>          bool started = false;
>  
> -        virStoragePoolObjLock(pool);
> -        if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
> -            virStoragePoolObjUnlock(pool);
> +        virStoragePoolObjLock(obj);
> +        if ((backend = virStorageBackendForType(obj->def->type)) == NULL) {
> +            virStoragePoolObjUnlock(obj);
>              continue;
>          }
>  
> -        if (pool->autostart &&
> -            !virStoragePoolObjIsActive(pool)) {
> +        if (obj->autostart &&
> +            !virStoragePoolObjIsActive(obj)) {
>              if (backend->startPool &&
> -                backend->startPool(conn, pool) < 0) {
> +                backend->startPool(conn, obj) < 0) {
>                  virReportError(VIR_ERR_INTERNAL_ERROR,
>                                 _("Failed to autostart storage pool '%s': %s"),
> -                               pool->def->name, virGetLastErrorMessage());
> -                virStoragePoolObjUnlock(pool);
> +                               obj->def->name, virGetLastErrorMessage());
> +                virStoragePoolObjUnlock(obj);
>                  continue;
>              }
>              started = true;
> @@ -212,25 +212,25 @@ storageDriverAutostart(void)
>          if (started) {
>              char *stateFile;
>  
> -            virStoragePoolObjClearVols(pool);
> +            virStoragePoolObjClearVols(obj);
>              stateFile = virFileBuildPath(driver->stateDir,
> -                                         pool->def->name, ".xml");
> +                                         obj->def->name, ".xml");
>              if (!stateFile ||
> -                virStoragePoolSaveState(stateFile, pool->def) < 0 ||
> -                backend->refreshPool(conn, pool) < 0) {
> +                virStoragePoolSaveState(stateFile, obj->def) < 0 ||
> +                backend->refreshPool(conn, obj) < 0) {
>                  if (stateFile)
>                      unlink(stateFile);
>                  if (backend->stopPool)
> -                    backend->stopPool(conn, pool);
> +                    backend->stopPool(conn, obj);
>                  virReportError(VIR_ERR_INTERNAL_ERROR,
>                                 _("Failed to autostart storage pool '%s': %s"),
> -                               pool->def->name, virGetLastErrorMessage());
> +                               obj->def->name, virGetLastErrorMessage());
>              } else {
> -                pool->active = true;
> +                obj->active = true;
>              }
>              VIR_FREE(stateFile);
>          }
> -        virStoragePoolObjUnlock(pool);
> +        virStoragePoolObjUnlock(obj);
>      }
>  
>      virObjectUnref(conn);
> @@ -391,10 +391,10 @@ static virStoragePoolObjPtr
>  storagePoolObjFindByUUID(const unsigned char *uuid,
>                           const char *name)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      char uuidstr[VIR_UUID_STRING_BUFLEN];
>  
> -    if (!(pool = virStoragePoolObjFindByUUID(&driver->pools, uuid))) {
> +    if (!(obj = virStoragePoolObjFindByUUID(&driver->pools, uuid))) {
>          virUUIDFormat(uuid, uuidstr);
>          if (name)
>              virReportError(VIR_ERR_NO_STORAGE_POOL,
> @@ -406,7 +406,7 @@ storagePoolObjFindByUUID(const unsigned char *uuid,
>                             uuidstr);
>      }
>  
> -    return pool;
> +    return obj;
>  }
>  
>  
> @@ -426,15 +426,15 @@ virStoragePoolObjFromStoragePool(virStoragePoolPtr pool)
>  static virStoragePoolObjPtr
>  storagePoolObjFindByName(const char *name)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>  
>      storageDriverLock();
> -    if (!(pool = virStoragePoolObjFindByName(&driver->pools, name)))
> +    if (!(obj = virStoragePoolObjFindByName(&driver->pools, name)))
>          virReportError(VIR_ERR_NO_STORAGE_POOL,
>                         _("no storage pool with matching name '%s'"), name);
>      storageDriverUnlock();
>  
> -    return pool;
> +    return obj;
>  }
>  
>  
> @@ -442,65 +442,63 @@ static virStoragePoolPtr
>  storagePoolLookupByUUID(virConnectPtr conn,
>                          const unsigned char *uuid)
>  {
> -    virStoragePoolObjPtr pool;
> -    virStoragePoolPtr ret = NULL;
> +    virStoragePoolObjPtr obj;
> +    virStoragePoolPtr pool = NULL;
>  
>      storageDriverLock();
> -    pool = storagePoolObjFindByUUID(uuid, NULL);
> +    obj = storagePoolObjFindByUUID(uuid, NULL);
>      storageDriverUnlock();
> -    if (!pool)
> +    if (!obj)
>          return NULL;
>  
> -    if (virStoragePoolLookupByUUIDEnsureACL(conn, pool->def) < 0)
> +    if (virStoragePoolLookupByUUIDEnsureACL(conn, obj->def) < 0)
>          goto cleanup;
>  
> -    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
> -                            NULL, NULL);
> +    pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL);
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> -    return ret;
> +    virStoragePoolObjUnlock(obj);
> +    return pool;
>  }
>  
>  static virStoragePoolPtr
>  storagePoolLookupByName(virConnectPtr conn,
>                          const char *name)
>  {
> -    virStoragePoolObjPtr pool;
> -    virStoragePoolPtr ret = NULL;
> +    virStoragePoolObjPtr obj;
> +    virStoragePoolPtr pool = NULL;
>  
> -    if (!(pool = storagePoolObjFindByName(name)))
> +    if (!(obj = storagePoolObjFindByName(name)))
>          return NULL;
>  
> -    if (virStoragePoolLookupByNameEnsureACL(conn, pool->def) < 0)
> +    if (virStoragePoolLookupByNameEnsureACL(conn, obj->def) < 0)
>          goto cleanup;
>  
> -    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
> -                            NULL, NULL);
> +    pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL);
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> -    return ret;
> +    virStoragePoolObjUnlock(obj);
> +    return pool;
>  }
>  
>  static virStoragePoolPtr
>  storagePoolLookupByVolume(virStorageVolPtr vol)
>  {
> -    virStoragePoolObjPtr pool;
> -    virStoragePoolPtr ret = NULL;
> +    virStoragePoolObjPtr obj;
> +    virStoragePoolPtr pool = NULL;
>  
> -    if (!(pool = storagePoolObjFindByName(vol->pool)))
> +    if (!(obj = storagePoolObjFindByName(vol->pool)))
>          return NULL;
>  
> -    if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, pool->def) < 0)
> +    if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    ret = virGetStoragePool(vol->conn, pool->def->name, pool->def->uuid,
> -                            NULL, NULL);
> +    pool = virGetStoragePool(vol->conn, obj->def->name, obj->def->uuid,
> +                             NULL, NULL);
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> -    return ret;
> +    virStoragePoolObjUnlock(obj);
> +    return pool;
>  }
>  
>  static int
> @@ -613,7 +611,8 @@ storageConnectFindStoragePoolSources(virConnectPtr conn,
>  }
>  
>  
> -static int storagePoolIsActive(virStoragePoolPtr pool)
> +static int
> +storagePoolIsActive(virStoragePoolPtr pool)
>  {
>      virStoragePoolObjPtr obj;
>      int ret = -1;
> @@ -631,7 +630,9 @@ static int storagePoolIsActive(virStoragePoolPtr pool)
>      return ret;
>  }
>  
> -static int storagePoolIsPersistent(virStoragePoolPtr pool)
> +
> +static int
> +storagePoolIsPersistent(virStoragePoolPtr pool)
>  {
>      virStoragePoolObjPtr obj;
>      int ret = -1;
> @@ -656,8 +657,8 @@ storagePoolCreateXML(virConnectPtr conn,
>                       unsigned int flags)
>  {
>      virStoragePoolDefPtr def;
> -    virStoragePoolObjPtr pool = NULL;
> -    virStoragePoolPtr ret = NULL;
> +    virStoragePoolObjPtr obj = NULL;
> +    virStoragePoolPtr pool = NULL;
>      virStorageBackendPtr backend;
>      virObjectEventPtr event = NULL;
>      char *stateFile = NULL;
> @@ -686,7 +687,7 @@ storagePoolCreateXML(virConnectPtr conn,
>      if ((backend = virStorageBackendForType(def->type)) == NULL)
>          goto cleanup;
>  
> -    if (!(pool = virStoragePoolObjAssignDef(&driver->pools, def)))
> +    if (!(obj = virStoragePoolObjAssignDef(&driver->pools, def)))
>          goto cleanup;
>      def = NULL;
>  
> @@ -698,56 +699,55 @@ storagePoolCreateXML(virConnectPtr conn,
>  
>          if (build_flags ||
>              (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) {
> -            if (backend->buildPool(conn, pool, build_flags) < 0) {
> -                virStoragePoolObjRemove(&driver->pools, pool);
> -                pool = NULL;
> +            if (backend->buildPool(conn, obj, build_flags) < 0) {
> +                virStoragePoolObjRemove(&driver->pools, obj);
> +                obj = NULL;
>                  goto cleanup;
>              }
>          }
>      }
>  
>      if (backend->startPool &&
> -        backend->startPool(conn, pool) < 0) {
> -        virStoragePoolObjRemove(&driver->pools, pool);
> -        pool = NULL;
> +        backend->startPool(conn, obj) < 0) {
> +        virStoragePoolObjRemove(&driver->pools, obj);
> +        obj = NULL;
>          goto cleanup;
>      }
>  
>      stateFile = virFileBuildPath(driver->stateDir,
> -                                 pool->def->name, ".xml");
> +                                 obj->def->name, ".xml");
>  
> -    virStoragePoolObjClearVols(pool);
> -    if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
> -        backend->refreshPool(conn, pool) < 0) {
> +    virStoragePoolObjClearVols(obj);
> +    if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 ||
> +        backend->refreshPool(conn, obj) < 0) {
>          if (stateFile)
>              unlink(stateFile);
>          if (backend->stopPool)
> -            backend->stopPool(conn, pool);
> -        virStoragePoolObjRemove(&driver->pools, pool);
> -        pool = NULL;
> +            backend->stopPool(conn, obj);
> +        virStoragePoolObjRemove(&driver->pools, obj);
> +        obj = NULL;
>          goto cleanup;
>      }
>  
> -    event = virStoragePoolEventLifecycleNew(pool->def->name,
> -                                            pool->def->uuid,
> +    event = virStoragePoolEventLifecycleNew(obj->def->name,
> +                                            obj->def->uuid,
>                                              VIR_STORAGE_POOL_EVENT_STARTED,
>                                              0);
>  
> -    VIR_INFO("Creating storage pool '%s'", pool->def->name);
> -    pool->active = true;
> +    VIR_INFO("Creating storage pool '%s'", obj->def->name);
> +    obj->active = true;
>  
> -    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
> -                            NULL, NULL);
> +    pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL);
>  
>   cleanup:
>      VIR_FREE(stateFile);
>      virStoragePoolDefFree(def);
>      if (event)
>          virObjectEventStateQueue(driver->storageEventState, event);
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
>      storageDriverUnlock();
> -    return ret;
> +    return pool;
>  }
>  
>  static virStoragePoolPtr
> @@ -756,8 +756,8 @@ storagePoolDefineXML(virConnectPtr conn,
>                       unsigned int flags)
>  {
>      virStoragePoolDefPtr def;
> -    virStoragePoolObjPtr pool = NULL;
> -    virStoragePoolPtr ret = NULL;
> +    virStoragePoolObjPtr obj = NULL;
> +    virStoragePoolPtr pool = NULL;
>      virObjectEventPtr event = NULL;
>  
>      virCheckFlags(0, NULL);
> @@ -781,13 +781,13 @@ storagePoolDefineXML(virConnectPtr conn,
>      if (virStorageBackendForType(def->type) == NULL)
>          goto cleanup;
>  
> -    if (!(pool = virStoragePoolObjAssignDef(&driver->pools, def)))
> +    if (!(obj = virStoragePoolObjAssignDef(&driver->pools, def)))
>          goto cleanup;
>  
> -    if (virStoragePoolObjSaveDef(driver, pool, def) < 0) {
> -        virStoragePoolObjRemove(&driver->pools, pool);
> +    if (virStoragePoolObjSaveDef(driver, obj, def) < 0) {
> +        virStoragePoolObjRemove(&driver->pools, obj);
>          def = NULL;
> -        pool = NULL;
> +        obj = NULL;
>          goto cleanup;
>      }
>  
> @@ -797,86 +797,85 @@ storagePoolDefineXML(virConnectPtr conn,
>  
>      def = NULL;
>  
> -    VIR_INFO("Defining storage pool '%s'", pool->def->name);
> -    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
> -                            NULL, NULL);
> +    VIR_INFO("Defining storage pool '%s'", obj->def->name);
> +    pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL);
>  
>   cleanup:
>      if (event)
>          virObjectEventStateQueue(driver->storageEventState, event);
>      virStoragePoolDefFree(def);
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
>      storageDriverUnlock();
> -    return ret;
> +    return pool;
>  }
>  
>  static int
> -storagePoolUndefine(virStoragePoolPtr obj)
> +storagePoolUndefine(virStoragePoolPtr pool)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virObjectEventPtr event = NULL;
>      int ret = -1;
>  
>      storageDriverLock();
> -    if (!(pool = storagePoolObjFindByUUID(obj->uuid, obj->name)))
> +    if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
>          goto cleanup;
>  
> -    if (virStoragePoolUndefineEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolUndefineEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if (virStoragePoolObjIsActive(pool)) {
> +    if (virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("storage pool '%s' is still active"),
> -                       pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
> -    if (pool->asyncjobs > 0) {
> +    if (obj->asyncjobs > 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("pool '%s' has asynchronous jobs running."),
> -                       pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
> -    if (virStoragePoolObjDeleteDef(pool) < 0)
> +    if (virStoragePoolObjDeleteDef(obj) < 0)
>          goto cleanup;
>  
> -    if (unlink(pool->autostartLink) < 0 &&
> +    if (unlink(obj->autostartLink) < 0 &&
>          errno != ENOENT &&
>          errno != ENOTDIR) {
>          char ebuf[1024];
>          VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
> -                  pool->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
> +                  obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
>      }
>  
> -    VIR_FREE(pool->configFile);
> -    VIR_FREE(pool->autostartLink);
> +    VIR_FREE(obj->configFile);
> +    VIR_FREE(obj->autostartLink);
>  
> -    event = virStoragePoolEventLifecycleNew(pool->def->name,
> -                                            pool->def->uuid,
> +    event = virStoragePoolEventLifecycleNew(obj->def->name,
> +                                            obj->def->uuid,
>                                              VIR_STORAGE_POOL_EVENT_UNDEFINED,
>                                              0);
>  
> -    VIR_INFO("Undefining storage pool '%s'", pool->def->name);
> -    virStoragePoolObjRemove(&driver->pools, pool);
> -    pool = NULL;
> +    VIR_INFO("Undefining storage pool '%s'", obj->def->name);
> +    virStoragePoolObjRemove(&driver->pools, obj);
> +    obj = NULL;
>      ret = 0;
>  
>   cleanup:
>      if (event)
>          virObjectEventStateQueue(driver->storageEventState, event);
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
>      storageDriverUnlock();
>      return ret;
>  }
>  
>  static int
> -storagePoolCreate(virStoragePoolPtr obj,
> +storagePoolCreate(virStoragePoolPtr pool,
>                    unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStorageBackendPtr backend;
>      virObjectEventPtr event = NULL;
>      int ret = -1;
> @@ -890,19 +889,19 @@ storagePoolCreate(virStoragePoolPtr obj,
>      VIR_EXCLUSIVE_FLAGS_RET(VIR_STORAGE_POOL_BUILD_OVERWRITE,
>                              VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, -1);
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return -1;
>  
> -    if (virStoragePoolCreateEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolCreateEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
> +    if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
>          goto cleanup;
>  
> -    if (virStoragePoolObjIsActive(pool)) {
> +    if (virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("storage pool '%s' is already active"),
> -                       pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
> @@ -914,117 +913,117 @@ storagePoolCreate(virStoragePoolPtr obj,
>  
>          if (build_flags ||
>              (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) {
> -            if (backend->buildPool(obj->conn, pool, build_flags) < 0)
> +            if (backend->buildPool(pool->conn, obj, build_flags) < 0)
>                  goto cleanup;
>          }
>      }
>  
> -    VIR_INFO("Starting up storage pool '%s'", pool->def->name);
> +    VIR_INFO("Starting up storage pool '%s'", obj->def->name);
>      if (backend->startPool &&
> -        backend->startPool(obj->conn, pool) < 0)
> +        backend->startPool(pool->conn, obj) < 0)
>          goto cleanup;
>  
>      stateFile = virFileBuildPath(driver->stateDir,
> -                                 pool->def->name, ".xml");
> +                                 obj->def->name, ".xml");
>  
> -    virStoragePoolObjClearVols(pool);
> -    if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
> -        backend->refreshPool(obj->conn, pool) < 0) {
> +    virStoragePoolObjClearVols(obj);
> +    if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 ||
> +        backend->refreshPool(pool->conn, obj) < 0) {
>          if (stateFile)
>              unlink(stateFile);
>          if (backend->stopPool)
> -            backend->stopPool(obj->conn, pool);
> +            backend->stopPool(pool->conn, obj);
>          goto cleanup;
>      }
>  
> -    event = virStoragePoolEventLifecycleNew(pool->def->name,
> -                                            pool->def->uuid,
> +    event = virStoragePoolEventLifecycleNew(obj->def->name,
> +                                            obj->def->uuid,
>                                              VIR_STORAGE_POOL_EVENT_STARTED,
>                                              0);
>  
> -    pool->active = true;
> +    obj->active = true;
>      ret = 0;
>  
>   cleanup:
>      VIR_FREE(stateFile);
>      if (event)
>          virObjectEventStateQueue(driver->storageEventState, event);
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  static int
> -storagePoolBuild(virStoragePoolPtr obj,
> +storagePoolBuild(virStoragePoolPtr pool,
>                   unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStorageBackendPtr backend;
>      int ret = -1;
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return -1;
>  
> -    if (virStoragePoolBuildEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolBuildEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
> +    if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
>          goto cleanup;
>  
> -    if (virStoragePoolObjIsActive(pool)) {
> +    if (virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("storage pool '%s' is already active"),
> -                       pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
>      if (backend->buildPool &&
> -        backend->buildPool(obj->conn, pool, flags) < 0)
> +        backend->buildPool(pool->conn, obj, flags) < 0)
>          goto cleanup;
>      ret = 0;
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  
>  static int
> -storagePoolDestroy(virStoragePoolPtr obj)
> +storagePoolDestroy(virStoragePoolPtr pool)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStorageBackendPtr backend;
>      virObjectEventPtr event = NULL;
>      char *stateFile = NULL;
>      int ret = -1;
>  
>      storageDriverLock();
> -    if (!(pool = storagePoolObjFindByUUID(obj->uuid, obj->name)))
> +    if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
>          goto cleanup;
>  
> -    if (virStoragePoolDestroyEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolDestroyEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
> +    if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
>          goto cleanup;
>  
> -    VIR_INFO("Destroying storage pool '%s'", pool->def->name);
> +    VIR_INFO("Destroying storage pool '%s'", obj->def->name);
>  
> -    if (!virStoragePoolObjIsActive(pool)) {
> +    if (!virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
> -                       _("storage pool '%s' is not active"), pool->def->name);
> +                       _("storage pool '%s' is not active"), obj->def->name);
>          goto cleanup;
>      }
>  
> -    if (pool->asyncjobs > 0) {
> +    if (obj->asyncjobs > 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("pool '%s' has asynchronous jobs running."),
> -                       pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
>      if (!(stateFile = virFileBuildPath(driver->stateDir,
> -                                       pool->def->name,
> +                                       obj->def->name,
>                                         ".xml")))
>          goto cleanup;
>  
> @@ -1032,67 +1031,67 @@ storagePoolDestroy(virStoragePoolPtr obj)
>      VIR_FREE(stateFile);
>  
>      if (backend->stopPool &&
> -        backend->stopPool(obj->conn, pool) < 0)
> +        backend->stopPool(pool->conn, obj) < 0)
>          goto cleanup;
>  
> -    virStoragePoolObjClearVols(pool);
> +    virStoragePoolObjClearVols(obj);
>  
> -    event = virStoragePoolEventLifecycleNew(pool->def->name,
> -                                            pool->def->uuid,
> +    event = virStoragePoolEventLifecycleNew(obj->def->name,
> +                                            obj->def->uuid,
>                                              VIR_STORAGE_POOL_EVENT_STOPPED,
>                                              0);
>  
> -    pool->active = false;
> +    obj->active = false;
>  
> -    virStoragePoolUpdateInactive(&pool);
> +    virStoragePoolUpdateInactive(&obj);
>  
>      ret = 0;
>  
>   cleanup:
>      if (event)
>          virObjectEventStateQueue(driver->storageEventState, event);
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
>      storageDriverUnlock();
>      return ret;
>  }
>  
>  static int
> -storagePoolDelete(virStoragePoolPtr obj,
> +storagePoolDelete(virStoragePoolPtr pool,
>                    unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStorageBackendPtr backend;
>      char *stateFile = NULL;
>      int ret = -1;
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return -1;
>  
> -    if (virStoragePoolDeleteEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolDeleteEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
> +    if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
>          goto cleanup;
>  
> -    VIR_INFO("Deleting storage pool '%s'", pool->def->name);
> +    VIR_INFO("Deleting storage pool '%s'", obj->def->name);
>  
> -    if (virStoragePoolObjIsActive(pool)) {
> +    if (virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("storage pool '%s' is still active"),
> -                       pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
> -    if (pool->asyncjobs > 0) {
> +    if (obj->asyncjobs > 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("pool '%s' has asynchronous jobs running."),
> -                              pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
>      if (!(stateFile = virFileBuildPath(driver->stateDir,
> -                                       pool->def->name,
> +                                       obj->def->name,
>                                         ".xml")))
>          goto cleanup;
>  
> @@ -1104,22 +1103,22 @@ storagePoolDelete(virStoragePoolPtr obj,
>                         "%s", _("pool does not support pool deletion"));
>          goto cleanup;
>      }
> -    if (backend->deletePool(obj->conn, pool, flags) < 0)
> +    if (backend->deletePool(pool->conn, obj, flags) < 0)
>          goto cleanup;
>  
>      ret = 0;
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  
>  static int
> -storagePoolRefresh(virStoragePoolPtr obj,
> +storagePoolRefresh(virStoragePoolPtr pool,
>                     unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStorageBackendPtr backend;
>      int ret = -1;
>      virObjectEventPtr event = NULL;
> @@ -1127,165 +1126,165 @@ storagePoolRefresh(virStoragePoolPtr obj,
>      virCheckFlags(0, -1);
>  
>      storageDriverLock();
> -    if (!(pool = storagePoolObjFindByUUID(obj->uuid, obj->name)))
> +    if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
>          goto cleanup;
>  
> -    if (virStoragePoolRefreshEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolRefreshEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
> +    if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
>          goto cleanup;
>  
> -    if (!virStoragePoolObjIsActive(pool)) {
> +    if (!virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
> -                       _("storage pool '%s' is not active"), pool->def->name);
> +                       _("storage pool '%s' is not active"), obj->def->name);
>          goto cleanup;
>      }
>  
> -    if (pool->asyncjobs > 0) {
> +    if (obj->asyncjobs > 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("pool '%s' has asynchronous jobs running."),
> -                       pool->def->name);
> +                       obj->def->name);
>          goto cleanup;
>      }
>  
> -    virStoragePoolObjClearVols(pool);
> -    if (backend->refreshPool(obj->conn, pool) < 0) {
> +    virStoragePoolObjClearVols(obj);
> +    if (backend->refreshPool(pool->conn, obj) < 0) {
>          if (backend->stopPool)
> -            backend->stopPool(obj->conn, pool);
> +            backend->stopPool(pool->conn, obj);
>  
> -        event = virStoragePoolEventLifecycleNew(pool->def->name,
> -                                                pool->def->uuid,
> +        event = virStoragePoolEventLifecycleNew(obj->def->name,
> +                                                obj->def->uuid,
>                                                  VIR_STORAGE_POOL_EVENT_STOPPED,
>                                                  0);
> -        pool->active = false;
> +        obj->active = false;
>  
> -        virStoragePoolUpdateInactive(&pool);
> +        virStoragePoolUpdateInactive(&obj);
>  
>          goto cleanup;
>      }
>  
> -    event = virStoragePoolEventRefreshNew(pool->def->name,
> -                                          pool->def->uuid);
> +    event = virStoragePoolEventRefreshNew(obj->def->name,
> +                                          obj->def->uuid);
>      ret = 0;
>  
>   cleanup:
>      if (event)
>          virObjectEventStateQueue(driver->storageEventState, event);
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
>      storageDriverUnlock();
>      return ret;
>  }
>  
>  
>  static int
> -storagePoolGetInfo(virStoragePoolPtr obj,
> +storagePoolGetInfo(virStoragePoolPtr pool,
>                     virStoragePoolInfoPtr info)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      int ret = -1;
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return -1;
>  
> -    if (virStoragePoolGetInfoEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolGetInfoEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if (virStorageBackendForType(pool->def->type) == NULL)
> +    if (virStorageBackendForType(obj->def->type) == NULL)
>          goto cleanup;
>  
>      memset(info, 0, sizeof(virStoragePoolInfo));
> -    if (pool->active)
> +    if (obj->active)
>          info->state = VIR_STORAGE_POOL_RUNNING;
>      else
>          info->state = VIR_STORAGE_POOL_INACTIVE;
> -    info->capacity = pool->def->capacity;
> -    info->allocation = pool->def->allocation;
> -    info->available = pool->def->available;
> +    info->capacity = obj->def->capacity;
> +    info->allocation = obj->def->allocation;
> +    info->available = obj->def->available;
>      ret = 0;
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  static char *
> -storagePoolGetXMLDesc(virStoragePoolPtr obj,
> +storagePoolGetXMLDesc(virStoragePoolPtr pool,
>                        unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStoragePoolDefPtr def;
>      char *ret = NULL;
>  
>      virCheckFlags(VIR_STORAGE_XML_INACTIVE, NULL);
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return NULL;
>  
> -    if (virStoragePoolGetXMLDescEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolGetXMLDescEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if ((flags & VIR_STORAGE_XML_INACTIVE) && pool->newDef)
> -        def = pool->newDef;
> +    if ((flags & VIR_STORAGE_XML_INACTIVE) && obj->newDef)
> +        def = obj->newDef;
>      else
> -        def = pool->def;
> +        def = obj->def;
>  
>      ret = virStoragePoolDefFormat(def);
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  static int
> -storagePoolGetAutostart(virStoragePoolPtr obj,
> +storagePoolGetAutostart(virStoragePoolPtr pool,
>                          int *autostart)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      int ret = -1;
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return -1;
>  
> -    if (virStoragePoolGetAutostartEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if (!pool->configFile) {
> +    if (!obj->configFile) {
>          *autostart = 0;
>      } else {
> -        *autostart = pool->autostart;
> +        *autostart = obj->autostart;
>      }
> +
>      ret = 0;
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  static int
> -storagePoolSetAutostart(virStoragePoolPtr obj,
> +storagePoolSetAutostart(virStoragePoolPtr pool,
>                          int autostart)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      int ret = -1;
>  
>      storageDriverLock();
> -    if (!(pool = storagePoolObjFindByUUID(obj->uuid, obj->name)))
> +    if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
>          goto cleanup;
>  
> -    if (virStoragePoolSetAutostartEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if (!pool->configFile) {
> +    if (!obj->configFile) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         "%s", _("pool has no config file"));
> -        goto cleanup;
>      }
>  
>      autostart = (autostart != 0);
>  
> -    if (pool->autostart != autostart) {
> +    if (obj->autostart != autostart) {
>          if (autostart) {
>              if (virFileMakePath(driver->autostartDir) < 0) {
>                  virReportSystemError(errno,
> @@ -1294,85 +1293,86 @@ storagePoolSetAutostart(virStoragePoolPtr obj,
>                  goto cleanup;
>              }
>  
> -            if (symlink(pool->configFile, pool->autostartLink) < 0) {
> +            if (symlink(obj->configFile, obj->autostartLink) < 0) {
>                  virReportSystemError(errno,
>                                       _("Failed to create symlink '%s' to '%s'"),
> -                                     pool->autostartLink, pool->configFile);
> +                                     obj->autostartLink, obj->configFile);
>                  goto cleanup;
>              }
>          } else {
> -            if (unlink(pool->autostartLink) < 0 &&
> +            if (unlink(obj->autostartLink) < 0 &&
>                  errno != ENOENT && errno != ENOTDIR) {
>                  virReportSystemError(errno,
>                                       _("Failed to delete symlink '%s'"),
> -                                     pool->autostartLink);
> +                                     obj->autostartLink);
>                  goto cleanup;
>              }
>          }
> -        pool->autostart = autostart;
> +        obj->autostart = autostart;
>      }
> +
>      ret = 0;
>  
>   cleanup:
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
>      storageDriverUnlock();
>      return ret;
>  }
>  
>  
>  static int
> -storagePoolNumOfVolumes(virStoragePoolPtr obj)
> +storagePoolNumOfVolumes(virStoragePoolPtr pool)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      int ret = -1;
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return -1;
>  
> -    if (virStoragePoolNumOfVolumesEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolNumOfVolumesEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if (!virStoragePoolObjIsActive(pool)) {
> +    if (!virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
> -                       _("storage pool '%s' is not active"), pool->def->name);
> +                       _("storage pool '%s' is not active"), obj->def->name);
>          goto cleanup;
>      }
>  
> -    ret = virStoragePoolObjNumOfVolumes(&pool->volumes, obj->conn, pool->def,
> +    ret = virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn, obj->def,
>                                          virStoragePoolNumOfVolumesCheckACL);
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  
>  static int
> -storagePoolListVolumes(virStoragePoolPtr obj,
> +storagePoolListVolumes(virStoragePoolPtr pool,
>                         char **const names,
>                         int maxnames)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      int n = -1;
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return -1;
>  
> -    if (virStoragePoolListVolumesEnsureACL(obj->conn, pool->def) < 0)
> +    if (virStoragePoolListVolumesEnsureACL(pool->conn, obj->def) < 0)
>          goto cleanup;
>  
> -    if (!virStoragePoolObjIsActive(pool)) {
> +    if (!virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
> -                       _("storage pool '%s' is not active"), pool->def->name);
> +                       _("storage pool '%s' is not active"), obj->def->name);
>          goto cleanup;
>      }
>  
> -    n = virStoragePoolObjVolumeGetNames(&pool->volumes, obj->conn, pool->def,
> +    n = virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn, obj->def,
>                                          virStoragePoolListVolumesCheckACL,
>                                          names, maxnames);
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return n;
>  }
>  
> @@ -1411,40 +1411,40 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
>  }
>  
>  static virStorageVolPtr
> -storageVolLookupByName(virStoragePoolPtr obj,
> +storageVolLookupByName(virStoragePoolPtr pool,
>                         const char *name)
>  {
> -    virStoragePoolObjPtr pool;
> -    virStorageVolDefPtr vol;
> -    virStorageVolPtr ret = NULL;
> +    virStoragePoolObjPtr obj;
> +    virStorageVolDefPtr voldef;
> +    virStorageVolPtr vol = NULL;
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return NULL;
>  
> -    if (!virStoragePoolObjIsActive(pool)) {
> +    if (!virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
> -                       _("storage pool '%s' is not active"), pool->def->name);
> +                       _("storage pool '%s' is not active"), obj->def->name);
>          goto cleanup;
>      }
>  
> -    vol = virStorageVolDefFindByName(pool, name);
> +    voldef = virStorageVolDefFindByName(obj, name);
>  
> -    if (!vol) {
> +    if (!voldef) {
>          virReportError(VIR_ERR_NO_STORAGE_VOL,
>                         _("no storage vol with matching name '%s'"),
>                         name);
>          goto cleanup;
>      }
>  
> -    if (virStorageVolLookupByNameEnsureACL(obj->conn, pool->def, vol) < 0)
> +    if (virStorageVolLookupByNameEnsureACL(pool->conn, obj->def, voldef) < 0)
>          goto cleanup;
>  
> -    ret = virGetStorageVol(obj->conn, pool->def->name, vol->name, vol->key,
> -                           NULL, NULL);
> +    vol = virGetStorageVol(pool->conn, obj->def->name, voldef->name,
> +                           voldef->key, NULL, NULL);
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> -    return ret;
> +    virStoragePoolObjUnlock(obj);
> +    return vol;
>  }
>  
>  
> @@ -1453,39 +1453,39 @@ storageVolLookupByKey(virConnectPtr conn,
>                        const char *key)
>  {
>      size_t i;
> -    virStorageVolPtr ret = NULL;
> +    virStorageVolPtr vol = NULL;
>  
>      storageDriverLock();
> -    for (i = 0; i < driver->pools.count && !ret; i++) {
> +    for (i = 0; i < driver->pools.count && !vol; i++) {
>          virStoragePoolObjLock(driver->pools.objs[i]);
>          if (virStoragePoolObjIsActive(driver->pools.objs[i])) {
> -            virStorageVolDefPtr vol =
> +            virStorageVolDefPtr voldef =
>                  virStorageVolDefFindByKey(driver->pools.objs[i], key);
>  
> -            if (vol) {
> +            if (voldef) {
>                  virStoragePoolDefPtr def = driver->pools.objs[i]->def;
> -                if (virStorageVolLookupByKeyEnsureACL(conn, def, vol) < 0) {
> +                if (virStorageVolLookupByKeyEnsureACL(conn, def, voldef) < 0) {
>                      virStoragePoolObjUnlock(driver->pools.objs[i]);
>                      goto cleanup;
>                  }
>  
> -                ret = virGetStorageVol(conn,
> +                vol = virGetStorageVol(conn,
>                                         def->name,
> -                                       vol->name,
> -                                       vol->key,
> +                                       voldef->name,
> +                                       voldef->key,
>                                         NULL, NULL);
>              }
>          }
>          virStoragePoolObjUnlock(driver->pools.objs[i]);
>      }
>  
> -    if (!ret)
> +    if (!vol)
>          virReportError(VIR_ERR_NO_STORAGE_VOL,
>                         _("no storage vol with matching key %s"), key);
>  
>   cleanup:
>      storageDriverUnlock();
> -    return ret;
> +    return vol;
>  }
>  
>  static virStorageVolPtr
> @@ -1493,7 +1493,7 @@ storageVolLookupByPath(virConnectPtr conn,
>                         const char *path)
>  {
>      size_t i;
> -    virStorageVolPtr ret = NULL;
> +    virStorageVolPtr vol = NULL;
>      char *cleanpath;
>  
>      cleanpath = virFileSanitizePath(path);
> @@ -1501,19 +1501,19 @@ storageVolLookupByPath(virConnectPtr conn,
>          return NULL;
>  
>      storageDriverLock();
> -    for (i = 0; i < driver->pools.count && !ret; i++) {
> -        virStoragePoolObjPtr pool = driver->pools.objs[i];
> -        virStorageVolDefPtr vol;
> +    for (i = 0; i < driver->pools.count && !vol; i++) {
> +        virStoragePoolObjPtr obj = driver->pools.objs[i];
> +        virStorageVolDefPtr voldef;
>          char *stable_path = NULL;
>  
> -        virStoragePoolObjLock(pool);
> +        virStoragePoolObjLock(obj);
>  
> -        if (!virStoragePoolObjIsActive(pool)) {
> -           virStoragePoolObjUnlock(pool);
> +        if (!virStoragePoolObjIsActive(obj)) {
> +           virStoragePoolObjUnlock(obj);
>             continue;
>          }
>  
> -        switch ((virStoragePoolType) pool->def->type) {
> +        switch ((virStoragePoolType) obj->def->type) {
>              case VIR_STORAGE_POOL_DIR:
>              case VIR_STORAGE_POOL_FS:
>              case VIR_STORAGE_POOL_NETFS:
> @@ -1523,7 +1523,7 @@ storageVolLookupByPath(virConnectPtr conn,
>              case VIR_STORAGE_POOL_SCSI:
>              case VIR_STORAGE_POOL_MPATH:
>              case VIR_STORAGE_POOL_VSTORAGE:
> -                stable_path = virStorageBackendStablePath(pool,
> +                stable_path = virStorageBackendStablePath(obj,
>                                                            cleanpath,
>                                                            false);
>                  if (stable_path == NULL) {
> @@ -1531,8 +1531,8 @@ storageVolLookupByPath(virConnectPtr conn,
>                       * getting the stable path for some of the pools.
>                       */
>                      VIR_WARN("Failed to get stable path for pool '%s'",
> -                             pool->def->name);
> -                    virStoragePoolObjUnlock(pool);
> +                             obj->def->name);
> +                    virStoragePoolObjUnlock(obj);
>                      continue;
>                  }
>                  break;
> @@ -1543,30 +1543,30 @@ storageVolLookupByPath(virConnectPtr conn,
>              case VIR_STORAGE_POOL_ZFS:
>              case VIR_STORAGE_POOL_LAST:
>                  if (VIR_STRDUP(stable_path, path) < 0) {
> -                     virStoragePoolObjUnlock(pool);
> +                     virStoragePoolObjUnlock(obj);
>                      goto cleanup;
>                  }
>                  break;
>          }
>  
> -        vol = virStorageVolDefFindByPath(pool, stable_path);
> +        voldef = virStorageVolDefFindByPath(obj, stable_path);
>          VIR_FREE(stable_path);
>  
> -        if (vol) {
> -            if (virStorageVolLookupByPathEnsureACL(conn, pool->def, vol) < 0) {
> -                virStoragePoolObjUnlock(pool);
> +        if (voldef) {
> +            if (virStorageVolLookupByPathEnsureACL(conn, obj->def, voldef) < 0) {
> +                virStoragePoolObjUnlock(obj);
>                  goto cleanup;
>              }
>  
> -            ret = virGetStorageVol(conn, pool->def->name,
> -                                   vol->name, vol->key,
> +            vol = virGetStorageVol(conn, obj->def->name,
> +                                   voldef->name, voldef->key,
>                                     NULL, NULL);
>          }
>  
> -        virStoragePoolObjUnlock(pool);
> +        virStoragePoolObjUnlock(obj);
>      }
>  
> -    if (!ret) {
> +    if (!vol) {
>          if (STREQ(path, cleanpath)) {
>              virReportError(VIR_ERR_NO_STORAGE_VOL,
>                             _("no storage vol with matching path '%s'"), path);
> @@ -1580,7 +1580,7 @@ storageVolLookupByPath(virConnectPtr conn,
>   cleanup:
>      VIR_FREE(cleanpath);
>      storageDriverUnlock();
> -    return ret;
> +    return vol;
>  }
>  
>  virStoragePoolPtr
> @@ -1588,7 +1588,7 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
>                                const char *path)
>  {
>      size_t i;
> -    virStoragePoolPtr ret = NULL;
> +    virStoragePoolPtr pool = NULL;
>      char *cleanpath;
>  
>      cleanpath = virFileSanitizePath(path);
> @@ -1596,49 +1596,49 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
>          return NULL;
>  
>      storageDriverLock();
> -    for (i = 0; i < driver->pools.count && !ret; i++) {
> -        virStoragePoolObjPtr pool = driver->pools.objs[i];
> +    for (i = 0; i < driver->pools.count && !pool; i++) {
> +        virStoragePoolObjPtr obj = driver->pools.objs[i];
>  
> -        virStoragePoolObjLock(pool);
> +        virStoragePoolObjLock(obj);
>  
> -        if (!virStoragePoolObjIsActive(pool)) {
> -            virStoragePoolObjUnlock(pool);
> +        if (!virStoragePoolObjIsActive(obj)) {
> +            virStoragePoolObjUnlock(obj);
>              continue;
>          }
>  
> -        if (STREQ(path, pool->def->target.path)) {
> -            ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
> -                                    NULL, NULL);
> +        if (STREQ(path, obj->def->target.path)) {
> +            pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid,
> +                                     NULL, NULL);
>          }
>  
> -        virStoragePoolObjUnlock(pool);
> +        virStoragePoolObjUnlock(obj);
>      }
>      storageDriverUnlock();
>  
> -    if (!ret) {
> +    if (!pool) {
>          virReportError(VIR_ERR_NO_STORAGE_VOL,
>                         _("no storage pool with matching target path '%s'"),
>                         path);
>      }
>  
>      VIR_FREE(cleanpath);
> -    return ret;
> +    return pool;
>  }
>  
>  
>  static void
> -storageVolRemoveFromPool(virStoragePoolObjPtr pool,
> -                         virStorageVolDefPtr vol)
> +storageVolRemoveFromPool(virStoragePoolObjPtr obj,
> +                         virStorageVolDefPtr voldef)
>  {
>      size_t i;
>  
> -    for (i = 0; i < pool->volumes.count; i++) {
> -        if (pool->volumes.objs[i] == vol) {
> +    for (i = 0; i < obj->volumes.count; i++) {
> +        if (obj->volumes.objs[i] == voldef) {
>              VIR_INFO("Deleting volume '%s' from storage pool '%s'",
> -                     vol->name, pool->def->name);
> -            virStorageVolDefFree(vol);
> +                     voldef->name, obj->def->name);
> +            virStorageVolDefFree(voldef);
>  
> -            VIR_DELETE_ELEMENT(pool->volumes.objs, i, pool->volumes.count);
> +            VIR_DELETE_ELEMENT(obj->volumes.objs, i, obj->volumes.count);
>              break;
>          }
>      }
> @@ -1646,10 +1646,10 @@ storageVolRemoveFromPool(virStoragePoolObjPtr pool,
>  
>  
>  static int
> -storageVolDeleteInternal(virStorageVolPtr obj,
> +storageVolDeleteInternal(virStorageVolPtr vol,
>                           virStorageBackendPtr backend,
> -                         virStoragePoolObjPtr pool,
> -                         virStorageVolDefPtr vol,
> +                         virStoragePoolObjPtr obj,
> +                         virStorageVolDefPtr voldef,
>                           unsigned int flags,
>                           bool updateMeta)
>  {
> @@ -1662,7 +1662,7 @@ storageVolDeleteInternal(virStorageVolPtr obj,
>          goto cleanup;
>      }
>  
> -    if (backend->deleteVol(obj->conn, pool, vol, flags) < 0)
> +    if (backend->deleteVol(vol->conn, obj, voldef, flags) < 0)
>          goto cleanup;
>  
>      /* Update pool metadata - don't update meta data from error paths
> @@ -1670,13 +1670,13 @@ storageVolDeleteInternal(virStorageVolPtr obj,
>       * Ignore the disk backend since it updates the pool values.
>       */
>      if (updateMeta) {
> -        if (pool->def->type != VIR_STORAGE_POOL_DISK) {
> -            pool->def->allocation -= vol->target.allocation;
> -            pool->def->available += vol->target.allocation;
> +        if (obj->def->type != VIR_STORAGE_POOL_DISK) {
> +            obj->def->allocation -= voldef->target.allocation;
> +            obj->def->available += voldef->target.allocation;
>          }
>      }
>  
> -    storageVolRemoveFromPool(pool, vol);
> +    storageVolRemoveFromPool(obj, voldef);
>      ret = 0;
>  
>   cleanup:
> @@ -1685,109 +1685,109 @@ storageVolDeleteInternal(virStorageVolPtr obj,
>  
>  
>  static virStorageVolDefPtr
> -virStorageVolDefFromVol(virStorageVolPtr obj,
> -                        virStoragePoolObjPtr *pool,
> +virStorageVolDefFromVol(virStorageVolPtr vol,
> +                        virStoragePoolObjPtr *obj,
>                          virStorageBackendPtr *backend)
>  {
> -    virStorageVolDefPtr vol = NULL;
> +    virStorageVolDefPtr voldef = NULL;
>  
> -    if (!(*pool = storagePoolObjFindByName(obj->pool)))
> +    if (!(*obj = storagePoolObjFindByName(vol->pool)))
>          return NULL;
>  
> -    if (!virStoragePoolObjIsActive(*pool)) {
> +    if (!virStoragePoolObjIsActive(*obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("storage pool '%s' is not active"),
> -                       (*pool)->def->name);
> +                       (*obj)->def->name);
>          goto error;
>      }
>  
> -    if (!(vol = virStorageVolDefFindByName(*pool, obj->name))) {
> +    if (!(voldef = virStorageVolDefFindByName(*obj, vol->name))) {
>          virReportError(VIR_ERR_NO_STORAGE_VOL,
>                         _("no storage vol with matching name '%s'"),
> -                       obj->name);
> +                       vol->name);
>          goto error;
>      }
>  
>      if (backend) {
> -        if (!(*backend = virStorageBackendForType((*pool)->def->type)))
> +        if (!(*backend = virStorageBackendForType((*obj)->def->type)))
>              goto error;
>      }
>  
> -    return vol;
> +    return voldef;
>  
>   error:
> -    virStoragePoolObjUnlock(*pool);
> -    *pool = NULL;
> +    virStoragePoolObjUnlock(*obj);
> +    *obj = NULL;
>  
>      return NULL;
>  }
>  
>  
>  static int
> -storageVolDelete(virStorageVolPtr obj,
> +storageVolDelete(virStorageVolPtr vol,
>                   unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStorageBackendPtr backend;
> -    virStorageVolDefPtr vol = NULL;
> +    virStorageVolDefPtr voldef = NULL;
>      int ret = -1;
>  
> -    if (!(vol = virStorageVolDefFromVol(obj, &pool, &backend)))
> +    if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
>          return -1;
>  
> -    if (virStorageVolDeleteEnsureACL(obj->conn, pool->def, vol) < 0)
> +    if (virStorageVolDeleteEnsureACL(vol->conn, obj->def, voldef) < 0)
>          goto cleanup;
>  
> -    if (vol->in_use) {
> +    if (voldef->in_use) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("volume '%s' is still in use."),
> -                       vol->name);
> +                       voldef->name);
>          goto cleanup;
>      }
>  
> -    if (vol->building) {
> +    if (voldef->building) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("volume '%s' is still being allocated."),
> -                       vol->name);
> +                       voldef->name);
>          goto cleanup;
>      }
>  
> -    if (storageVolDeleteInternal(obj, backend, pool, vol, flags, true) < 0)
> +    if (storageVolDeleteInternal(vol, backend, obj, voldef, flags, true) < 0)
>          goto cleanup;
>  
>      ret = 0;
>  
>   cleanup:
> -    virStoragePoolObjUnlock(pool);
> +    virStoragePoolObjUnlock(obj);
>      return ret;
>  }
>  
>  
>  static virStorageVolPtr
> -storageVolCreateXML(virStoragePoolPtr obj,
> +storageVolCreateXML(virStoragePoolPtr pool,
>                      const char *xmldesc,
>                      unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool;
> +    virStoragePoolObjPtr obj;
>      virStorageBackendPtr backend;
>      virStorageVolDefPtr voldef = NULL;
> -    virStorageVolPtr ret = NULL, volobj = NULL;
> +    virStorageVolPtr vol = NULL, volobj = NULL;

The @volobj should be also renamed, I would rename it like this:

    @ret -> @vol
    @volobj -> @newvol

and ...

>  
>      virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
>  
> -    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
> +    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
>          return NULL;
>  
> -    if (!virStoragePoolObjIsActive(pool)) {
> +    if (!virStoragePoolObjIsActive(obj)) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
> -                       _("storage pool '%s' is not active"), pool->def->name);
> +                       _("storage pool '%s' is not active"), obj->def->name);
>          goto cleanup;
>      }
>  
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
> +    if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
>          goto cleanup;
>  
> -    voldef = virStorageVolDefParseString(pool->def, xmldesc,
> +    voldef = virStorageVolDefParseString(obj->def, xmldesc,
>                                           VIR_VOL_XML_PARSE_OPT_CAPACITY);
>      if (voldef == NULL)
>          goto cleanup;
> @@ -1799,10 +1799,10 @@ storageVolCreateXML(virStoragePoolPtr obj,
>          goto cleanup;
>      }
>  
> -    if (virStorageVolCreateXMLEnsureACL(obj->conn, pool->def, voldef) < 0)
> +    if (virStorageVolCreateXMLEnsureACL(pool->conn, obj->def, voldef) < 0)
>          goto cleanup;
>  
> -    if (virStorageVolDefFindByName(pool, voldef->name)) {
> +    if (virStorageVolDefFindByName(obj, voldef->name)) {
>          virReportError(VIR_ERR_STORAGE_VOL_EXIST,
>                         _("'%s'"), voldef->name);
>          goto cleanup;
> @@ -1815,21 +1815,21 @@ storageVolCreateXML(virStoragePoolPtr obj,
>          goto cleanup;
>      }
>  
> -    if (VIR_REALLOC_N(pool->volumes.objs,
> -                      pool->volumes.count+1) < 0)
> +    if (VIR_REALLOC_N(obj->volumes.objs,
> +                      obj->volumes.count + 1) < 0)
>          goto cleanup;
>  
>      /* Wipe any key the user may have suggested, as volume creation
>       * will generate the canonical key.  */
>      VIR_FREE(voldef->key);
> -    if (backend->createVol(obj->conn, pool, voldef) < 0)
> +    if (backend->createVol(pool->conn, obj, voldef) < 0)
>          goto cleanup;
>  
> -    pool->volumes.objs[pool->volumes.count++] = voldef;
> -    volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
> +    obj->volumes.objs[obj->volumes.count++] = voldef;
> +    volobj = virGetStorageVol(pool->conn, obj->def->name, voldef->name,
>                                voldef->key, NULL, NULL);
>      if (!volobj) {
> -        pool->volumes.count--;
> +        obj->volumes.count--;
>          goto cleanup;
>      }
>  
> @@ -1850,24 +1850,24 @@ storageVolCreateXML(virStoragePoolPtr obj,
>          memcpy(buildvoldef, voldef, sizeof(*voldef));
>  
>          /* Drop the pool lock during volume allocation */
> -        pool->asyncjobs++;
> +        obj->asyncjobs++;
>          voldef->building = true;
> -        virStoragePoolObjUnlock(pool);
> +        virStoragePoolObjUnlock(obj);
>  
> -        buildret = backend->buildVol(obj->conn, pool, buildvoldef, flags);
> +        buildret = backend->buildVol(pool->conn, obj, buildvoldef, flags);
>  
>          VIR_FREE(buildvoldef);
>  
>          storageDriverLock();
> -        virStoragePoolObjLock(pool);
> +        virStoragePoolObjLock(obj);
>          storageDriverUnlock();
>  
>          voldef->building = false;
> -        pool->asyncjobs--;
> +        obj->asyncjobs--;
>  
>          if (buildret < 0) {
>              /* buildVol handles deleting volume on failure */
> -            storageVolRemoveFromPool(pool, voldef);
> +            storageVolRemoveFromPool(obj, voldef);
>              voldef = NULL;
>              goto cleanup;
>          }
> @@ -1875,8 +1875,8 @@ storageVolCreateXML(virStoragePoolPtr obj,
>      }
>  
>      if (backend->refreshVol &&
> -        backend->refreshVol(obj->conn, pool, voldef) < 0) {
> -        storageVolDeleteInternal(volobj, backend, pool, voldef,
> +        backend->refreshVol(pool->conn, obj, voldef) < 0) {
> +        storageVolDeleteInternal(volobj, backend, obj, voldef,
>                                   0, false);
>          voldef = NULL;
>          goto cleanup;
> @@ -1885,35 +1885,39 @@ storageVolCreateXML(virStoragePoolPtr obj,
>      /* Update pool metadata ignoring the disk backend since
>       * it updates the pool values.
>       */
> -    if (pool->def->type != VIR_STORAGE_POOL_DISK) {
> -        pool->def->allocation += voldef->target.allocation;
> -        pool->def->available -= voldef->target.allocation;
> +    if (obj->def->type != VIR_STORAGE_POOL_DISK) {
> +        obj->def->allocation += voldef->target.allocation;
> +        obj->def->available -= voldef->target.allocation;
>      }
>  
>      VIR_INFO("Creating volume '%s' in storage pool '%s'",
> -             volobj->name, pool->def->name);
> -    ret = volobj;
> +             volobj->name, obj->def->name);
> +    vol = volobj;
>      volobj = NULL;
>      voldef = NULL;
>  
>   cleanup:
>      virObjectUnref(volobj);
>      virStorageVolDefFree(voldef);
> -    if (pool)
> -        virStoragePoolObjUnlock(pool);
> -    return ret;
> +    if (obj)
> +        virStoragePoolObjUnlock(obj);
> +    return vol;
>  }
>  
>  static virStorageVolPtr
> -storageVolCreateXMLFrom(virStoragePoolPtr obj,
> +storageVolCreateXMLFrom(virStoragePoolPtr pool,
>                          const char *xmldesc,
> -                        virStorageVolPtr vobj,
> +                        virStorageVolPtr volsrc,
>                          unsigned int flags)
>  {
> -    virStoragePoolObjPtr pool, origpool = NULL;
> +    virStoragePoolObjPtr obj;
> +    virStoragePoolObjPtr objsrc = NULL;
>      virStorageBackendPtr backend;
> -    virStorageVolDefPtr origvol = NULL, newvol = NULL, shadowvol = NULL;
> -    virStorageVolPtr ret = NULL, volobj = NULL;
> +    virStorageVolDefPtr voldefsrc = NULL;
> +    virStorageVolDefPtr voldef = NULL;
> +    virStorageVolDefPtr shadowvol = NULL;
> +    virStorageVolPtr volobj = NULL;
> +    virStorageVolPtr vol = NULL;

... same here.

Pavel

Attachment: signature.asc
Description: Digital signature

--
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]
  Powered by Linux