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

[libvirt] [PATCH RFC 8/9] storage: Convert virStoragePoolObj[List] to use virPoolObj[Table]



Use the virPoolObj[Table] object management model in order to manage the
StoragePool objects.

While making the adjustments to use the new model, there are some code
formatting adjustments that were also made with the goal to follow more
recent code flow and layout.

For API's that were static, rather than use "virStoragePool*", the names were
converted to be "storagePool*" - makes it easier to determine while reading code
what is local and what is "outside" the perveyance of the module.

All storage pool and volume object management API's have their own
virstorageobj entry points now instead of being mashed in with storage_conf

Signed-off-by: John Ferlan <jferlan redhat com>
---
 po/POTFILES.in                         |    1 +
 src/Makefile.am                        |    3 +-
 src/conf/storage_conf.c                | 1062 +--------------------
 src/conf/storage_conf.h                |  138 +--
 src/conf/virstorageobj.c               | 1206 +++++++++++++++++++++++
 src/conf/virstorageobj.h               |  143 +++
 src/libvirt_private.syms               |   50 +-
 src/storage/storage_backend.h          |   32 +-
 src/storage/storage_backend_disk.c     |  182 ++--
 src/storage/storage_backend_fs.c       |  145 +--
 src/storage/storage_backend_gluster.c  |   37 +-
 src/storage/storage_backend_iscsi.c    |   65 +-
 src/storage/storage_backend_logical.c  |  127 +--
 src/storage/storage_backend_mpath.c    |   29 +-
 src/storage/storage_backend_rbd.c      |  109 ++-
 src/storage/storage_backend_scsi.c     |   57 +-
 src/storage/storage_backend_sheepdog.c |   90 +-
 src/storage/storage_backend_vstorage.c |   47 +-
 src/storage/storage_backend_zfs.c      |   68 +-
 src/storage/storage_driver.c           | 1645 +++++++++++++++-----------------
 src/storage/storage_driver.h           |    6 +-
 src/storage/storage_util.c             |  228 ++---
 src/storage/storage_util.h             |   31 +-
 src/test/test_driver.c                 | 1022 +++++++++-----------
 tests/storagevolxml2argvtest.c         |   16 +-
 25 files changed, 3303 insertions(+), 3236 deletions(-)
 create mode 100644 src/conf/virstorageobj.c
 create mode 100644 src/conf/virstorageobj.h

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0435265..a2e961f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -46,6 +46,7 @@ src/conf/virnodedeviceobj.c
 src/conf/virnwfilterobj.c
 src/conf/virpoolobj.c
 src/conf/virsecretobj.c
+src/conf/virstorageobj.c
 src/cpu/cpu.c
 src/cpu/cpu_arm.c
 src/cpu/cpu_map.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 73f3dd0..2d95020 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -380,7 +380,8 @@ POOLOBJ_SOURCES =						\
 
 # Storage driver generic impl APIs
 STORAGE_CONF_SOURCES =                                         \
-		conf/storage_conf.h conf/storage_conf.c
+		conf/storage_conf.h conf/storage_conf.c        \
+		conf/virstorageobj.h conf/virstorageobj.c
 
 # Interface driver generic impl APIs
 INTERFACE_CONF_SOURCES =                                       \
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8012b6f..b24b09c 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -26,7 +26,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <dirent.h>
 #include <unistd.h>
 #include <errno.h>
 #include <stdio.h>
@@ -395,8 +394,9 @@ virStoragePoolSourceFree(virStoragePoolSourcePtr source)
 }
 
 void
-virStoragePoolDefFree(virStoragePoolDefPtr def)
+virStoragePoolDefFree(void *opaque)
 {
+    virStoragePoolDefPtr def = opaque;
     if (!def)
         return;
 
@@ -410,56 +410,6 @@ virStoragePoolDefFree(virStoragePoolDefPtr def)
 }
 
 
-void
-virStoragePoolObjFree(virStoragePoolObjPtr obj)
-{
-    if (!obj)
-        return;
-
-    virObjectUnref(obj->volumes);
-
-    virStoragePoolDefFree(obj->def);
-    virStoragePoolDefFree(obj->newDef);
-
-    VIR_FREE(obj->configFile);
-    VIR_FREE(obj->autostartLink);
-
-    virMutexDestroy(&obj->lock);
-
-    VIR_FREE(obj);
-}
-
-void
-virStoragePoolObjListFree(virStoragePoolObjListPtr pools)
-{
-    size_t i;
-    for (i = 0; i < pools->count; i++)
-        virStoragePoolObjFree(pools->objs[i]);
-    VIR_FREE(pools->objs);
-    pools->count = 0;
-}
-
-void
-virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
-                        virStoragePoolObjPtr pool)
-{
-    size_t i;
-
-    virStoragePoolObjUnlock(pool);
-
-    for (i = 0; i < pools->count; i++) {
-        virStoragePoolObjLock(pools->objs[i]);
-        if (pools->objs[i] == pool) {
-            virStoragePoolObjUnlock(pools->objs[i]);
-            virStoragePoolObjFree(pools->objs[i]);
-
-            VIR_DELETE_ELEMENT(pools->objs, i, pools->count);
-            break;
-        }
-        virStoragePoolObjUnlock(pools->objs[i]);
-    }
-}
-
 static int
 virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
                              virStoragePoolSourcePtr source,
@@ -829,7 +779,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
     return ret;
 }
 
-static virStoragePoolDefPtr
+virStoragePoolDefPtr
 virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
 {
     virStoragePoolOptionsPtr options;
@@ -1729,463 +1679,10 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
 }
 
 
-virStoragePoolObjPtr
-virStoragePoolObjFindByUUID(virStoragePoolObjListPtr pools,
-                            const unsigned char *uuid)
-{
-    size_t i;
-
-    for (i = 0; i < pools->count; i++) {
-        virStoragePoolObjLock(pools->objs[i]);
-        if (!memcmp(pools->objs[i]->def->uuid, uuid, VIR_UUID_BUFLEN))
-            return pools->objs[i];
-        virStoragePoolObjUnlock(pools->objs[i]);
-    }
-
-    return NULL;
-}
-
-virStoragePoolObjPtr
-virStoragePoolObjFindByName(virStoragePoolObjListPtr pools,
-                            const char *name)
-{
-    size_t i;
-
-    for (i = 0; i < pools->count; i++) {
-        virStoragePoolObjLock(pools->objs[i]);
-        if (STREQ(pools->objs[i]->def->name, name))
-            return pools->objs[i];
-        virStoragePoolObjUnlock(pools->objs[i]);
-    }
-
-    return NULL;
-}
-
-virStoragePoolObjPtr
-virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr pool,
-                                         virStoragePoolDefPtr def)
-{
-    size_t i, j;
-
-    for (i = 0; i < pool->def->source.ndevice; i++) {
-        for (j = 0; j < def->source.ndevice; j++) {
-            if (STREQ(pool->def->source.devices[i].path, def->source.devices[j].path))
-                return pool;
-        }
-    }
-
-    return NULL;
-}
-
-
-void
-virStoragePoolObjClearVols(virStoragePoolObjPtr pool)
-{
-    virPoolObjTableClearAll(pool->volumes);
-}
-
-
-struct volSearchData {
-    const char *compare;
-};
-
-static bool
-volFindByKey(virPoolObjPtr obj,
-             void *opaque)
-{
-    virStorageVolDefPtr def = virPoolObjGetDef(obj);
-    struct volSearchData *data = opaque;
-
-    if (STREQ(def->key, data->compare))
-        return true;
-
-    return false;
-}
-
-
-virPoolObjPtr
-virStorageVolObjFindByKey(virStoragePoolObjPtr pool,
-                          const char *key)
-{
-    struct volSearchData data = { .compare = key };
-
-    return virPoolObjTableSearchRef(pool->volumes, volFindByKey, &data);
-}
-
-
-static bool
-volFindByPath(virPoolObjPtr obj,
-              void *opaque)
-{
-    virStorageVolDefPtr def = virPoolObjGetDef(obj);
-    struct volSearchData *data = opaque;
-
-    if (STREQ(def->target.path, data->compare))
-        return true;
-
-    return false;
-}
-
-
-virPoolObjPtr
-virStorageVolObjFindByPath(virStoragePoolObjPtr pool,
-                           const char *path)
-{
-    struct volSearchData data = { .compare = path };
-
-    return virPoolObjTableSearchRef(pool->volumes, volFindByPath, &data);
-}
-
-
-virPoolObjPtr
-virStorageVolObjFindByName(virStoragePoolObjPtr pool,
-                           const char *name)
-{
-    return virPoolObjTableFindByName(pool->volumes, name);
-}
-
-
-virStoragePoolObjPtr
-virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
-                           virStoragePoolDefPtr def)
-{
-    virStoragePoolObjPtr pool;
-
-    if ((pool = virStoragePoolObjFindByName(pools, def->name))) {
-        if (!virStoragePoolObjIsActive(pool)) {
-            virStoragePoolDefFree(pool->def);
-            pool->def = def;
-        } else {
-            virStoragePoolDefFree(pool->newDef);
-            pool->newDef = def;
-        }
-        return pool;
-    }
-
-    if (VIR_ALLOC(pool) < 0)
-        return NULL;
-
-    if (virMutexInit(&pool->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("cannot initialize mutex"));
-        VIR_FREE(pool);
-        return NULL;
-    }
-    virStoragePoolObjLock(pool);
-    pool->active = 0;
-
-    if (!(pool->volumes =
-          virPoolObjTableNew(VIR_POOLOBJTABLE_VOLUME,
-                             VIR_POOLOBJTABLE_VOLUME_HASHSTART, true))) {
-        virStoragePoolObjUnlock(pool);
-        virStoragePoolObjFree(pool);
-        return NULL;
-    }
-
-    if (VIR_APPEND_ELEMENT_COPY(pools->objs, pools->count, pool) < 0) {
-        virStoragePoolObjUnlock(pool);
-        virStoragePoolObjFree(pool);
-        return NULL;
-    }
-    pool->def = def;
-
-    return pool;
-}
-
-
-virPoolObjPtr
-virStoragePoolObjAddVolume(virStoragePoolObjPtr pool,
-                           virStorageVolDefPtr voldef)
-{
-    return virPoolObjTableAdd(pool->volumes, NULL, voldef->name, voldef,
-                              NULL, NULL, virStorageVolDefFree, NULL, 0);
-}
-
-
-void
-virStoragePoolObjRemoveVolume(virStoragePoolObjPtr pool,
-                              virPoolObjPtr *volobj)
-{
-    virPoolObjTableRemove(pool->volumes, volobj);
-}
-
-
-struct volCountData {
-    virConnectPtr conn;
-    virStoragePoolDefPtr pooldef;
-    virStoragePoolVolumeACLFilter aclfilter;
-    int count;
-};
-
-static int
-volCount(virPoolObjPtr obj,
-         void *opaque)
-{
-    struct volCountData *data = opaque;
-
-    /* Similar to virPoolObjTableListIterator */
-    if (data->aclfilter && !data->aclfilter(data->conn, data->pooldef, obj))
-        return 0;
-
-    data->count++;
-    return 0;
-}
-
-
-int
-virStoragePoolObjNumOfVolumes(virPoolObjTablePtr volumes,
-                              virConnectPtr conn,
-                              virStoragePoolDefPtr pooldef,
-                              virStoragePoolVolumeACLFilter aclfilter)
-{
-    struct volCountData data = { .conn = conn,
-                                 .count = 0,
-                                 .pooldef = pooldef,
-                                 .aclfilter = aclfilter };
-
-    if (virPoolObjTableList(volumes, conn, NULL, volCount, &data) < 0)
-        return 0;
-
-    return data.count;
-}
-
-
-struct volListData {
-    virConnectPtr conn;
-    virStoragePoolDefPtr pooldef;
-    virStoragePoolVolumeACLFilter aclfilter;
-    int nnames;
-    char **const names;
-    int maxnames;
-};
-
 static int
-volListVolumes(virPoolObjPtr obj,
-               void *opaque)
-{
-    virStorageVolDefPtr def = virPoolObjGetDef(obj);
-    struct volListData *data = opaque;
-
-    /* Similar to virPoolObjTableListIterator */
-    if (data->aclfilter && !data->aclfilter(data->conn, data->pooldef, obj))
-        return 0;
-
-    if (data->nnames < data->maxnames) {
-        if (VIR_STRDUP(data->names[data->nnames++], def->name) < 0)
-            return -1;
-    }
-
-    return 0;
-}
-
-
-int
-virStoragePoolObjListVolumes(virPoolObjTablePtr volumes,
-                             virConnectPtr conn,
-                             virStoragePoolDefPtr pooldef,
-                             virStoragePoolVolumeACLFilter aclfilter,
-                             char **const names,
-                             int maxnames)
-{
-    struct volListData data = { .conn = conn,
-                                .nnames = 0,
-                                .pooldef = pooldef,
-                                .aclfilter = aclfilter,
-                                .names = names,
-                                .maxnames = maxnames };
-
-    memset(names, 0, maxnames * sizeof(*names));
-
-    if (virPoolObjTableList(volumes, conn, NULL, volListVolumes, &data) < 0)
-        goto error;
-
-    return data.nnames;
-
- error:
-    while (--data.nnames >= 0)
-        VIR_FREE(names[data.nnames]);
-    return -1;
-}
-
-
-static virStoragePoolObjPtr
-virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
-                      const char *file,
-                      const char *path,
-                      const char *autostartLink)
-{
-    virStoragePoolDefPtr def;
-    virStoragePoolObjPtr pool;
-
-    if (!(def = virStoragePoolDefParseFile(path)))
-        return NULL;
-
-    if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Storage pool config filename '%s' does "
-                         "not match pool name '%s'"),
-                       path, def->name);
-        virStoragePoolDefFree(def);
-        return NULL;
-    }
-
-    if (!(pool = virStoragePoolObjAssignDef(pools, def))) {
-        virStoragePoolDefFree(def);
-        return NULL;
-    }
-
-    VIR_FREE(pool->configFile);  /* for driver reload */
-    if (VIR_STRDUP(pool->configFile, path) < 0) {
-        virStoragePoolObjRemove(pools, pool);
-        return NULL;
-    }
-    VIR_FREE(pool->autostartLink); /* for driver reload */
-    if (VIR_STRDUP(pool->autostartLink, autostartLink) < 0) {
-        virStoragePoolObjRemove(pools, pool);
-        return NULL;
-    }
-
-    pool->autostart = virFileLinkPointsTo(pool->autostartLink,
-                                          pool->configFile);
-
-    return pool;
-}
-
-
-virStoragePoolObjPtr
-virStoragePoolLoadState(virStoragePoolObjListPtr pools,
-                        const char *stateDir,
-                        const char *name)
-{
-    char *stateFile = NULL;
-    virStoragePoolDefPtr def = NULL;
-    virStoragePoolObjPtr pool = NULL;
-    xmlDocPtr xml = NULL;
-    xmlXPathContextPtr ctxt = NULL;
-    xmlNodePtr node = NULL;
-
-    if (!(stateFile = virFileBuildPath(stateDir, name, ".xml")))
-        goto error;
-
-    if (!(xml = virXMLParseCtxt(stateFile, NULL, _("(pool state)"), &ctxt)))
-        goto error;
-
-    if (!(node = virXPathNode("//pool", ctxt))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Could not find any 'pool' element in state file"));
-        goto error;
-    }
-
-    ctxt->node = node;
-    if (!(def = virStoragePoolDefParseXML(ctxt)))
-        goto error;
-
-    if (STRNEQ(name, def->name)) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Storage pool state file '%s' does not match "
-                         "pool name '%s'"),
-                       stateFile, def->name);
-        goto error;
-    }
-
-    /* create the object */
-    if (!(pool = virStoragePoolObjAssignDef(pools, def)))
-        goto error;
-
-    /* XXX: future handling of some additional useful status data,
-     * for now, if a status file for a pool exists, the pool will be marked
-     * as active
-     */
-
-    pool->active = 1;
-
- cleanup:
-    VIR_FREE(stateFile);
-    xmlFreeDoc(xml);
-    xmlXPathFreeContext(ctxt);
-    return pool;
-
- error:
-    virStoragePoolDefFree(def);
-    goto cleanup;
-}
-
-
-int
-virStoragePoolLoadAllState(virStoragePoolObjListPtr pools,
-                           const char *stateDir)
-{
-    DIR *dir;
-    struct dirent *entry;
-    int ret = -1;
-    int rc;
-
-    if ((rc = virDirOpenIfExists(&dir, stateDir)) <= 0)
-        return rc;
-
-    while ((ret = virDirRead(dir, &entry, stateDir)) > 0) {
-        virStoragePoolObjPtr pool;
-
-        if (!virFileStripSuffix(entry->d_name, ".xml"))
-            continue;
-
-        if (!(pool = virStoragePoolLoadState(pools, stateDir, entry->d_name)))
-            continue;
-        virStoragePoolObjUnlock(pool);
-    }
-
-    VIR_DIR_CLOSE(dir);
-    return ret;
-}
-
-
-int
-virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
-                             const char *configDir,
-                             const char *autostartDir)
-{
-    DIR *dir;
-    struct dirent *entry;
-    int ret;
-    int rc;
-
-    if ((rc = virDirOpenIfExists(&dir, configDir)) <= 0)
-        return rc;
-
-    while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
-        char *path;
-        char *autostartLink;
-        virStoragePoolObjPtr pool;
-
-        if (!virFileHasSuffix(entry->d_name, ".xml"))
-            continue;
-
-        if (!(path = virFileBuildPath(configDir, entry->d_name, NULL)))
-            continue;
-
-        if (!(autostartLink = virFileBuildPath(autostartDir, entry->d_name,
-                                               NULL))) {
-            VIR_FREE(path);
-            continue;
-        }
-
-        pool = virStoragePoolObjLoad(pools, entry->d_name, path,
-                                     autostartLink);
-        if (pool)
-            virStoragePoolObjUnlock(pool);
-
-        VIR_FREE(path);
-        VIR_FREE(autostartLink);
-    }
-
-    VIR_DIR_CLOSE(dir);
-    return ret;
-}
-
-
-static int virStoragePoolSaveXML(const char *path,
-                                 virStoragePoolDefPtr def,
-                                 const char *xml)
+virStoragePoolSaveXML(const char *path,
+                      virStoragePoolDefPtr def,
+                      const char *xml)
 {
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     int ret = -1;
@@ -2255,52 +1752,6 @@ virStoragePoolSaveConfig(const char *configFile,
     return ret;
 }
 
-int
-virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
-                         virStoragePoolObjPtr pool,
-                         virStoragePoolDefPtr def)
-{
-    if (!pool->configFile) {
-        if (virFileMakePath(driver->configDir) < 0) {
-            virReportSystemError(errno,
-                                 _("cannot create config directory %s"),
-                                 driver->configDir);
-            return -1;
-        }
-
-        if (!(pool->configFile = virFileBuildPath(driver->configDir,
-                                                  def->name, ".xml"))) {
-            return -1;
-        }
-
-        if (!(pool->autostartLink = virFileBuildPath(driver->autostartDir,
-                                                     def->name, ".xml"))) {
-            VIR_FREE(pool->configFile);
-            return -1;
-        }
-    }
-
-    return virStoragePoolSaveConfig(pool->configFile, def);
-}
-
-int
-virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool)
-{
-    if (!pool->configFile) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("no config file for %s"), pool->def->name);
-        return -1;
-    }
-
-    if (unlink(pool->configFile) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("cannot remove config for %s"),
-                       pool->def->name);
-        return -1;
-    }
-
-    return 0;
-}
 
 virStoragePoolSourcePtr
 virStoragePoolSourceListNewSource(virStoragePoolSourceListPtr list)
@@ -2356,68 +1807,6 @@ virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def)
 
 
 /*
- * virStoragePoolObjIsDuplicate:
- * @doms : virStoragePoolObjListPtr to search
- * @def  : virStoragePoolDefPtr definition of pool to lookup
- * @check_active: If true, ensure that pool is not active
- *
- * Returns: -1 on error
- *          0 if pool is new
- *          1 if pool is a duplicate
- */
-int
-virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
-                             virStoragePoolDefPtr def,
-                             unsigned int check_active)
-{
-    int ret = -1;
-    virStoragePoolObjPtr pool = NULL;
-
-    /* See if a Pool with matching UUID already exists */
-    pool = virStoragePoolObjFindByUUID(pools, def->uuid);
-    if (pool) {
-        /* UUID matches, but if names don't match, refuse it */
-        if (STRNEQ(pool->def->name, def->name)) {
-            char uuidstr[VIR_UUID_STRING_BUFLEN];
-            virUUIDFormat(pool->def->uuid, uuidstr);
-            virReportError(VIR_ERR_OPERATION_FAILED,
-                           _("pool '%s' is already defined with uuid %s"),
-                           pool->def->name, uuidstr);
-            goto cleanup;
-        }
-
-        if (check_active) {
-            /* UUID & name match, but if Pool is already active, refuse it */
-            if (virStoragePoolObjIsActive(pool)) {
-                virReportError(VIR_ERR_OPERATION_INVALID,
-                               _("pool is already active as '%s'"),
-                               pool->def->name);
-                goto cleanup;
-            }
-        }
-
-        ret = 1;
-    } else {
-        /* UUID does not match, but if a name matches, refuse it */
-        pool = virStoragePoolObjFindByName(pools, def->name);
-        if (pool) {
-            char uuidstr[VIR_UUID_STRING_BUFLEN];
-            virUUIDFormat(pool->def->uuid, uuidstr);
-            virReportError(VIR_ERR_OPERATION_FAILED,
-                           _("pool '%s' already exists with uuid %s"),
-                           def->name, uuidstr);
-            goto cleanup;
-        }
-        ret = 0;
-    }
-
- cleanup:
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    return ret;
-}
-
-/*
  * virStoragePoolGetVhbaSCSIHostParent:
  *
  * Using the Node Device Driver, find the host# name found via wwnn/wwpn
@@ -2475,442 +1864,3 @@ virStoragePoolGetVhbaSCSIHostParent(virConnectPtr conn,
     virObjectUnref(device);
     return vhba_parent;
 }
-
-static int
-getSCSIHostNumber(virStoragePoolSourceAdapter adapter,
-                  unsigned int *hostnum)
-{
-    int ret = -1;
-    unsigned int num;
-    char *name = NULL;
-
-    if (adapter.data.scsi_host.has_parent) {
-        virPCIDeviceAddress addr = adapter.data.scsi_host.parentaddr;
-        unsigned int unique_id = adapter.data.scsi_host.unique_id;
-
-        if (!(name = virGetSCSIHostNameByParentaddr(addr.domain,
-                                                    addr.bus,
-                                                    addr.slot,
-                                                    addr.function,
-                                                    unique_id)))
-            goto cleanup;
-        if (virGetSCSIHostNumber(name, &num) < 0)
-            goto cleanup;
-    } else {
-        if (virGetSCSIHostNumber(adapter.data.scsi_host.name, &num) < 0)
-            goto cleanup;
-    }
-
-    *hostnum = num;
-    ret = 0;
-
- cleanup:
-    VIR_FREE(name);
-    return ret;
-}
-
-/*
- * matchFCHostToSCSIHost:
- *
- * @conn: Connection pointer
- * @fc_adapter: fc_host adapter (either def or pool->def)
- * @scsi_hostnum: Already determined "scsi_pool" hostnum
- *
- * Returns true/false whether there is a match between the incoming
- *         fc_adapter host# and the scsi_host host#
- */
-static bool
-matchFCHostToSCSIHost(virConnectPtr conn,
-                      virStoragePoolSourceAdapter fc_adapter,
-                      unsigned int scsi_hostnum)
-{
-    char *name = NULL;
-    char *parent_name = NULL;
-    unsigned int fc_hostnum;
-
-    /* If we have a parent defined, get its hostnum, and compare to the
-     * scsi_hostnum. If they are the same, then we have a match
-     */
-    if (fc_adapter.data.fchost.parent &&
-        virGetSCSIHostNumber(fc_adapter.data.fchost.parent, &fc_hostnum) == 0 &&
-        scsi_hostnum == fc_hostnum)
-        return true;
-
-    /* If we find an fc_adapter name, then either libvirt created a vHBA
-     * for this fc_host or a 'virsh nodedev-create' generated a vHBA.
-     */
-    if ((name = virGetFCHostNameByWWN(NULL, fc_adapter.data.fchost.wwnn,
-                                      fc_adapter.data.fchost.wwpn))) {
-
-        /* Get the scsi_hostN for the vHBA in order to see if it
-         * matches our scsi_hostnum
-         */
-        if (virGetSCSIHostNumber(name, &fc_hostnum) == 0 &&
-            scsi_hostnum == fc_hostnum) {
-            VIR_FREE(name);
-            return true;
-        }
-
-        /* We weren't provided a parent, so we have to query the node
-         * device driver in order to ascertain the parent of the vHBA.
-         * If the parent fc_hostnum is the same as the scsi_hostnum, we
-         * have a match.
-         */
-        if (conn && !fc_adapter.data.fchost.parent) {
-            parent_name = virStoragePoolGetVhbaSCSIHostParent(conn, name);
-            if (parent_name) {
-                if (virGetSCSIHostNumber(parent_name, &fc_hostnum) == 0 &&
-                    scsi_hostnum == fc_hostnum) {
-                    VIR_FREE(parent_name);
-                    VIR_FREE(name);
-                    return true;
-                }
-                VIR_FREE(parent_name);
-            } else {
-                /* Throw away the error and fall through */
-                virResetLastError();
-                VIR_DEBUG("Could not determine parent vHBA");
-            }
-        }
-        VIR_FREE(name);
-    }
-
-    /* NB: Lack of a name means that this vHBA hasn't yet been created,
-     *     which means our scsi_host cannot be using the vHBA. Furthermore,
-     *     lack of a provided parent means libvirt is going to choose the
-     *     "best" fc_host capable adapter based on availabilty. That could
-     *     conflict with an existing scsi_host definition, but there's no
-     *     way to know that now.
-     */
-    return false;
-}
-
-static bool
-matchSCSIAdapterParent(virStoragePoolObjPtr pool,
-                       virStoragePoolDefPtr def)
-{
-    virPCIDeviceAddressPtr pooladdr =
-        &pool->def->source.adapter.data.scsi_host.parentaddr;
-    virPCIDeviceAddressPtr defaddr =
-        &def->source.adapter.data.scsi_host.parentaddr;
-    int pool_unique_id =
-        pool->def->source.adapter.data.scsi_host.unique_id;
-    int def_unique_id =
-        def->source.adapter.data.scsi_host.unique_id;
-    if (pooladdr->domain == defaddr->domain &&
-        pooladdr->bus == defaddr->bus &&
-        pooladdr->slot == defaddr->slot &&
-        pooladdr->function == defaddr->function &&
-        pool_unique_id == def_unique_id) {
-        return true;
-    }
-    return false;
-}
-
-static bool
-virStoragePoolSourceMatchSingleHost(virStoragePoolSourcePtr poolsrc,
-                                    virStoragePoolSourcePtr defsrc)
-{
-    if (poolsrc->nhost != 1 && defsrc->nhost != 1)
-        return false;
-
-    if (defsrc->hosts[0].port &&
-        poolsrc->hosts[0].port != defsrc->hosts[0].port)
-        return false;
-
-    return STREQ(poolsrc->hosts[0].name, defsrc->hosts[0].name);
-}
-
-
-static bool
-virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr matchpool,
-                               virStoragePoolDefPtr def)
-{
-    virStoragePoolSourcePtr poolsrc = &matchpool->def->source;
-    virStoragePoolSourcePtr defsrc = &def->source;
-
-    /* NB: Do not check the source host name */
-    if (STRNEQ_NULLABLE(poolsrc->initiator.iqn, defsrc->initiator.iqn))
-        return false;
-
-    return true;
-}
-
-
-int
-virStoragePoolSourceFindDuplicate(virConnectPtr conn,
-                                  virStoragePoolObjListPtr pools,
-                                  virStoragePoolDefPtr def)
-{
-    size_t i;
-    int ret = 1;
-    virStoragePoolObjPtr pool = NULL;
-    virStoragePoolObjPtr matchpool = NULL;
-
-    /* Check the pool list for duplicate underlying storage */
-    for (i = 0; i < pools->count; i++) {
-        pool = pools->objs[i];
-        if (def->type != pool->def->type)
-            continue;
-
-        /* Don't match against ourself if re-defining existing pool ! */
-        if (STREQ(pool->def->name, def->name))
-            continue;
-
-        virStoragePoolObjLock(pool);
-
-        switch ((virStoragePoolType)pool->def->type) {
-        case VIR_STORAGE_POOL_DIR:
-            if (STREQ(pool->def->target.path, def->target.path))
-                matchpool = pool;
-            break;
-
-        case VIR_STORAGE_POOL_GLUSTER:
-            if (STREQ(pool->def->source.name, def->source.name) &&
-                STREQ_NULLABLE(pool->def->source.dir, def->source.dir) &&
-                virStoragePoolSourceMatchSingleHost(&pool->def->source,
-                                                    &def->source))
-                matchpool = pool;
-            break;
-
-        case VIR_STORAGE_POOL_NETFS:
-            if (STREQ(pool->def->source.dir, def->source.dir) &&
-                virStoragePoolSourceMatchSingleHost(&pool->def->source,
-                                                    &def->source))
-                matchpool = pool;
-            break;
-
-        case VIR_STORAGE_POOL_SCSI:
-            if (pool->def->source.adapter.type ==
-                VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST &&
-                def->source.adapter.type ==
-                VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
-                if (STREQ(pool->def->source.adapter.data.fchost.wwnn,
-                          def->source.adapter.data.fchost.wwnn) &&
-                    STREQ(pool->def->source.adapter.data.fchost.wwpn,
-                          def->source.adapter.data.fchost.wwpn))
-                    matchpool = pool;
-            } else if (pool->def->source.adapter.type ==
-                       VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST &&
-                       def->source.adapter.type ==
-                       VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
-                unsigned int pool_hostnum, def_hostnum;
-
-                if (pool->def->source.adapter.data.scsi_host.has_parent &&
-                    def->source.adapter.data.scsi_host.has_parent &&
-                    matchSCSIAdapterParent(pool, def)) {
-                    matchpool = pool;
-                    break;
-                }
-
-                if (getSCSIHostNumber(pool->def->source.adapter,
-                                      &pool_hostnum) < 0 ||
-                    getSCSIHostNumber(def->source.adapter, &def_hostnum) < 0)
-                    break;
-                if (pool_hostnum == def_hostnum)
-                    matchpool = pool;
-            } else if (pool->def->source.adapter.type ==
-                       VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST &&
-                       def->source.adapter.type ==
-                       VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
-                unsigned int scsi_hostnum;
-
-                /* Get the scsi_hostN for the scsi_host source adapter def */
-                if (getSCSIHostNumber(def->source.adapter,
-                                      &scsi_hostnum) < 0)
-                    break;
-
-                if (matchFCHostToSCSIHost(conn, pool->def->source.adapter,
-                                          scsi_hostnum)) {
-                    matchpool = pool;
-                    break;
-                }
-
-            } else if (pool->def->source.adapter.type ==
-                       VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST &&
-                       def->source.adapter.type ==
-                       VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
-                unsigned int scsi_hostnum;
-
-                if (getSCSIHostNumber(pool->def->source.adapter,
-                                      &scsi_hostnum) < 0)
-                    break;
-
-                if (matchFCHostToSCSIHost(conn, def->source.adapter,
-                                          scsi_hostnum)) {
-                    matchpool = pool;
-                    break;
-                }
-            }
-            break;
-        case VIR_STORAGE_POOL_ISCSI:
-            matchpool = virStoragePoolSourceFindDuplicateDevices(pool, def);
-            if (matchpool) {
-                if (!virStoragePoolSourceISCSIMatch(matchpool, def))
-                    matchpool = NULL;
-            }
-            break;
-        case VIR_STORAGE_POOL_FS:
-        case VIR_STORAGE_POOL_LOGICAL:
-        case VIR_STORAGE_POOL_DISK:
-        case VIR_STORAGE_POOL_ZFS:
-            matchpool = virStoragePoolSourceFindDuplicateDevices(pool, def);
-            break;
-        case VIR_STORAGE_POOL_SHEEPDOG:
-            if (virStoragePoolSourceMatchSingleHost(&pool->def->source,
-                                                    &def->source))
-                matchpool = pool;
-            break;
-        case VIR_STORAGE_POOL_MPATH:
-            /* Only one mpath pool is valid per host */
-            matchpool = pool;
-            break;
-        case VIR_STORAGE_POOL_VSTORAGE:
-            if (STREQ(pool->def->source.name, def->source.name))
-                matchpool = pool;
-            break;
-        case VIR_STORAGE_POOL_RBD:
-        case VIR_STORAGE_POOL_LAST:
-            break;
-        }
-        virStoragePoolObjUnlock(pool);
-
-        if (matchpool)
-            break;
-    }
-
-    if (matchpool) {
-        virReportError(VIR_ERR_OPERATION_FAILED,
-                       _("Storage source conflict with pool: '%s'"),
-                       matchpool->def->name);
-        ret = -1;
-    }
-    return ret;
-}
-
-void
-virStoragePoolObjLock(virStoragePoolObjPtr obj)
-{
-    virMutexLock(&obj->lock);
-}
-
-void
-virStoragePoolObjUnlock(virStoragePoolObjPtr obj)
-{
-    virMutexUnlock(&obj->lock);
-}
-
-#define MATCH(FLAG) (flags & (FLAG))
-static bool
-virStoragePoolMatch(virStoragePoolObjPtr poolobj,
-                    unsigned int flags)
-{
-    /* filter by active state */
-    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) &&
-        !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE) &&
-           virStoragePoolObjIsActive(poolobj)) ||
-          (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE) &&
-           !virStoragePoolObjIsActive(poolobj))))
-        return false;
-
-    /* filter by persistence */
-    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_PERSISTENT) &&
-        !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT) &&
-           poolobj->configFile) ||
-          (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT) &&
-           !poolobj->configFile)))
-        return false;
-
-    /* filter by autostart option */
-    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART) &&
-        !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART) &&
-           poolobj->autostart) ||
-          (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART) &&
-           !poolobj->autostart)))
-        return false;
-
-    /* filter by pool type */
-    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)) {
-        if (!((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_DIR) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_DIR))     ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FS) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_FS))      ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NETFS) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_NETFS))   ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_LOGICAL) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_LOGICAL)) ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_DISK) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_DISK))    ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_ISCSI))   ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SCSI) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_SCSI))    ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_MPATH) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_MPATH))   ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_RBD) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_RBD))     ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_SHEEPDOG)) ||
-              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_GLUSTER))))
-            return false;
-    }
-
-    return true;
-}
-#undef MATCH
-
-int
-virStoragePoolObjListExport(virConnectPtr conn,
-                            virStoragePoolObjList poolobjs,
-                            virStoragePoolPtr **pools,
-                            virStoragePoolObjListFilter filter,
-                            unsigned int flags)
-{
-    virStoragePoolPtr *tmp_pools = NULL;
-    virStoragePoolPtr pool = NULL;
-    int npools = 0;
-    int ret = -1;
-    size_t i;
-
-    if (pools && VIR_ALLOC_N(tmp_pools, poolobjs.count + 1) < 0)
-        goto cleanup;
-
-    for (i = 0; i < poolobjs.count; i++) {
-        virStoragePoolObjPtr poolobj = poolobjs.objs[i];
-        virStoragePoolObjLock(poolobj);
-        if ((!filter || filter(conn, poolobj->def)) &&
-            virStoragePoolMatch(poolobj, flags)) {
-            if (pools) {
-                if (!(pool = virGetStoragePool(conn,
-                                               poolobj->def->name,
-                                               poolobj->def->uuid,
-                                               NULL, NULL))) {
-                    virStoragePoolObjUnlock(poolobj);
-                    goto cleanup;
-                }
-                tmp_pools[npools] = pool;
-            }
-            npools++;
-        }
-        virStoragePoolObjUnlock(poolobj);
-    }
-
-    if (tmp_pools) {
-        /* trim the array to the final size */
-        ignore_value(VIR_REALLOC_N(tmp_pools, npools + 1));
-        *pools = tmp_pools;
-        tmp_pools = NULL;
-    }
-
-    ret = npools;
-
- cleanup:
-    if (tmp_pools) {
-        for (i = 0; i < npools; i++)
-            virObjectUnref(tmp_pools[i]);
-    }
-
-    VIR_FREE(tmp_pools);
-    return ret;
-}
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index cfc8281..96bfd90 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -258,48 +258,6 @@ struct _virStoragePoolDef {
     virStoragePoolTarget target;
 };
 
-typedef struct _virStoragePoolObj virStoragePoolObj;
-typedef virStoragePoolObj *virStoragePoolObjPtr;
-
-struct _virStoragePoolObj {
-    virMutex lock;
-
-    char *configFile;
-    char *autostartLink;
-    bool active;
-    int autostart;
-    unsigned int asyncjobs;
-
-    virStoragePoolDefPtr def;
-    virStoragePoolDefPtr newDef;
-
-    virPoolObjTablePtr volumes;
-};
-
-typedef struct _virStoragePoolObjList virStoragePoolObjList;
-typedef virStoragePoolObjList *virStoragePoolObjListPtr;
-struct _virStoragePoolObjList {
-    size_t count;
-    virStoragePoolObjPtr *objs;
-};
-
-typedef struct _virStorageDriverState virStorageDriverState;
-typedef virStorageDriverState *virStorageDriverStatePtr;
-
-struct _virStorageDriverState {
-    virMutex lock;
-
-    virStoragePoolObjList pools;
-
-    char *configDir;
-    char *autostartDir;
-    char *stateDir;
-    bool privileged;
-
-    /* Immutable pointer, self-locking APIs */
-    virObjectEventStatePtr storageEventState;
-};
-
 typedef struct _virStoragePoolSourceList virStoragePoolSourceList;
 typedef virStoragePoolSourceList *virStoragePoolSourceListPtr;
 struct _virStoragePoolSourceList {
@@ -308,47 +266,7 @@ struct _virStoragePoolSourceList {
     virStoragePoolSourcePtr sources;
 };
 
-typedef bool (*virStoragePoolObjListFilter)(virConnectPtr conn, void *opaque);
-
-static inline int
-virStoragePoolObjIsActive(virStoragePoolObjPtr pool)
-{
-    return pool->active;
-}
-
-int virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
-                                 const char *configDir,
-                                 const char *autostartDir);
-
-int virStoragePoolLoadAllState(virStoragePoolObjListPtr pools,
-                               const char *stateDir);
-
-virStoragePoolObjPtr
-virStoragePoolLoadState(virStoragePoolObjListPtr pools,
-                        const char *stateDir,
-                        const char *name);
-virStoragePoolObjPtr
-virStoragePoolObjFindByUUID(virStoragePoolObjListPtr pools,
-                            const unsigned char *uuid);
-virStoragePoolObjPtr
-virStoragePoolObjFindByName(virStoragePoolObjListPtr pools,
-                            const char *name);
-virStoragePoolObjPtr
-virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr pool,
-                                         virStoragePoolDefPtr def);
-
-virPoolObjPtr
-virStorageVolObjFindByKey(virStoragePoolObjPtr pool,
-                          const char *key);
-virPoolObjPtr
-virStorageVolObjFindByPath(virStoragePoolObjPtr pool,
-                           const char *path);
-virPoolObjPtr
-virStorageVolObjFindByName(virStoragePoolObjPtr pool,
-                           const char *name);
-
-void virStoragePoolObjClearVols(virStoragePoolObjPtr pool);
-
+virStoragePoolDefPtr virStoragePoolDefParseXML(xmlXPathContextPtr ctxt);
 virStoragePoolDefPtr virStoragePoolDefParseString(const char *xml);
 virStoragePoolDefPtr virStoragePoolDefParseFile(const char *filename);
 virStoragePoolDefPtr virStoragePoolDefParseNode(xmlDocPtr xml,
@@ -377,49 +295,17 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool,
 char *virStorageVolDefFormat(virStoragePoolDefPtr pool,
                              virStorageVolDefPtr def);
 
-virStoragePoolObjPtr
-virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
-                           virStoragePoolDefPtr def);
-
-virPoolObjPtr virStoragePoolObjAddVolume(virStoragePoolObjPtr pool,
-                                         virStorageVolDefPtr voldef);
-
-void virStoragePoolObjRemoveVolume(virStoragePoolObjPtr pool,
-                                   virPoolObjPtr *volobj);
-
-typedef bool (*virStoragePoolVolumeACLFilter)
-    (virConnectPtr conn, virStoragePoolDefPtr pool, void *objdef);
-
-int virStoragePoolObjNumOfVolumes(virPoolObjTablePtr volumes,
-                                  virConnectPtr conn,
-                                  virStoragePoolDefPtr pooldef,
-                                  virStoragePoolVolumeACLFilter aclfilter);
-
-int virStoragePoolObjListVolumes(virPoolObjTablePtr volumes,
-                                 virConnectPtr conn,
-                                 virStoragePoolDefPtr pooldef,
-                                 virStoragePoolVolumeACLFilter aclfilter,
-                                 char **const names,
-                                 int maxnames);
-
 int virStoragePoolSaveState(const char *stateFile,
                             virStoragePoolDefPtr def);
 int virStoragePoolSaveConfig(const char *configFile,
                              virStoragePoolDefPtr def);
-int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
-                             virStoragePoolObjPtr pool,
-                             virStoragePoolDefPtr def);
-int virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool);
 
 void virStorageVolDefFree(void *opaque);
 void virStoragePoolSourceClear(virStoragePoolSourcePtr source);
 void virStoragePoolSourceDeviceClear(virStoragePoolSourceDevicePtr dev);
 void virStoragePoolSourceFree(virStoragePoolSourcePtr source);
-void virStoragePoolDefFree(virStoragePoolDefPtr def);
-void virStoragePoolObjFree(virStoragePoolObjPtr pool);
-void virStoragePoolObjListFree(virStoragePoolObjListPtr pools);
-void virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
-                             virStoragePoolObjPtr pool);
+void virStoragePoolDefFree(void *opaque);
+void virStorageObjPrivateFree(void *opaque);
 
 virStoragePoolSourcePtr
 virStoragePoolDefParseSourceString(const char *srcSpec,
@@ -428,22 +314,10 @@ virStoragePoolSourcePtr
 virStoragePoolSourceListNewSource(virStoragePoolSourceListPtr list);
 char *virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def);
 
-int virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
-                                 virStoragePoolDefPtr def,
-                                 unsigned int check_active);
-
 char *virStoragePoolGetVhbaSCSIHostParent(virConnectPtr conn,
                                           const char *name)
     ATTRIBUTE_NONNULL(1);
 
-int virStoragePoolSourceFindDuplicate(virConnectPtr conn,
-                                      virStoragePoolObjListPtr pools,
-                                      virStoragePoolDefPtr def);
-
-void virStoragePoolObjLock(virStoragePoolObjPtr obj);
-void virStoragePoolObjUnlock(virStoragePoolObjPtr obj);
-
-
 typedef enum {
     VIR_STORAGE_POOL_FS_AUTO = 0,
     VIR_STORAGE_POOL_FS_EXT2,
@@ -571,10 +445,4 @@ VIR_ENUM_DECL(virStoragePartedFs)
                  VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART  | \
                  VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)
 
-int virStoragePoolObjListExport(virConnectPtr conn,
-                                virStoragePoolObjList poolobjs,
-                                virStoragePoolPtr **pools,
-                                virStoragePoolObjListFilter filter,
-                                unsigned int flags);
-
 #endif /* __VIR_STORAGE_CONF_H__ */
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
new file mode 100644
index 0000000..665f1a0
--- /dev/null
+++ b/src/conf/virstorageobj.c
@@ -0,0 +1,1206 @@
+/*
+ * virstorageobj.c: internal storage pool and volume objects handling
+ *                  (derived from storage_conf.c)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <config.h>
+#include <dirent.h>
+
+#include "datatypes.h"
+#include "virstorageobj.h"
+
+#include "viralloc.h"
+#include "virerror.h"
+#include "virfile.h"
+#include "virlog.h"
+#include "virstring.h"
+
+#define VIR_FROM_THIS VIR_FROM_STORAGE
+
+VIR_LOG_INIT("conf.virstorageobj");
+
+struct _virStoragePoolObjPrivate {
+    char *configFile;
+    char *autostartLink;
+    unsigned int asyncjobs;
+
+    virPoolObjTablePtr volumes;
+};
+
+
+static void
+virStoragePoolObjPrivateFree(void *obj)
+{
+    virStoragePoolObjPrivatePtr objpriv = obj;
+    if (!objpriv)
+        return;
+
+    virObjectUnref(objpriv->volumes);
+
+    VIR_FREE(objpriv->configFile);
+    VIR_FREE(objpriv->autostartLink);
+    VIR_FREE(objpriv);
+}
+
+
+static virStoragePoolObjPrivatePtr
+virStoragePoolObjPrivateAlloc(void)
+{
+    virStoragePoolObjPrivatePtr objpriv = NULL;
+
+    if (VIR_ALLOC(objpriv) < 0)
+        return NULL;
+
+    if (!(objpriv->volumes =
+          virPoolObjTableNew(VIR_POOLOBJTABLE_VOLUME,
+                             VIR_POOLOBJTABLE_VOLUME_HASHSTART, true)))
+        goto error;
+
+    return objpriv;
+
+ error:
+    virStoragePoolObjPrivateFree(objpriv);
+    return NULL;
+}
+
+
+const char *
+virStoragePoolObjPrivateGetConfigFile(virPoolObjPtr poolobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    return objpriv->configFile;
+}
+
+
+const char *
+virStoragePoolObjPrivateGetAutostartLink(virPoolObjPtr poolobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    return objpriv->autostartLink;
+}
+
+
+int
+virStoragePoolObjPrivateGetAsyncjobs(virPoolObjPtr poolobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    return objpriv->asyncjobs;
+}
+
+
+void
+virStoragePoolObjPrivateIncrAsyncjobs(virPoolObjPtr poolobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    objpriv->asyncjobs++;
+}
+
+
+void
+virStoragePoolObjPrivateDecrAsyncjobs(virPoolObjPtr poolobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    objpriv->asyncjobs--;
+}
+
+
+virPoolObjTablePtr
+virStoragePoolObjPrivateGetVolumes(virPoolObjPtr poolobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    return objpriv->volumes;
+}
+
+
+virPoolObjPtr
+virStoragePoolObjAddVolume(virPoolObjPtr poolobj,
+                           virStorageVolDefPtr voldef)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    return virPoolObjTableAdd(objpriv->volumes, NULL, voldef->name,
+                              voldef, NULL, NULL, virStorageVolDefFree,
+                              NULL, 0);
+}
+
+
+void
+virStoragePoolObjRemoveVolume(virPoolObjPtr poolobj,
+                              virPoolObjPtr *volobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    virPoolObjTableRemove(objpriv->volumes, volobj);
+}
+
+
+void
+virStoragePoolObjClearVols(virPoolObjPtr poolobj)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+    virPoolObjTableClearAll(objpriv->volumes);
+}
+
+
+struct volCountData {
+    virConnectPtr conn;
+    virStoragePoolDefPtr pooldef;
+    virStoragePoolVolumeACLFilter aclfilter;
+    int count;
+};
+
+static int
+volCount(virPoolObjPtr obj,
+         void *opaque)
+{
+    struct volCountData *data = opaque;
+
+    /* Similar to virPoolObjTableListIterator */
+    if (data->aclfilter && !data->aclfilter(data->conn, data->pooldef, obj))
+        return 0;
+
+    data->count++;
+    return 0;
+}
+
+
+int
+virStoragePoolObjNumOfVolumes(virPoolObjTablePtr volumes,
+                              virConnectPtr conn,
+                              virStoragePoolDefPtr pooldef,
+                              virStoragePoolVolumeACLFilter aclfilter)
+{
+    struct volCountData data = { .conn = conn,
+                                 .count = 0,
+                                 .pooldef = pooldef,
+                                 .aclfilter = aclfilter };
+
+    if (virPoolObjTableList(volumes, conn, NULL, volCount, &data) < 0)
+        return 0;
+
+    return data.count;
+}
+
+
+struct volListData {
+    virConnectPtr conn;
+    virStoragePoolDefPtr pooldef;
+    virStoragePoolVolumeACLFilter aclfilter;
+    int nnames;
+    char **const names;
+    int maxnames;
+};
+
+static int
+volListVolumes(virPoolObjPtr obj,
+               void *opaque)
+{
+    virStorageVolDefPtr def = virPoolObjGetDef(obj);
+    struct volListData *data = opaque;
+
+    /* Similar to virPoolObjTableListIterator */
+    if (data->aclfilter && !data->aclfilter(data->conn, data->pooldef, obj))
+        return 0;
+
+    if (data->nnames < data->maxnames) {
+        if (VIR_STRDUP(data->names[data->nnames++], def->name) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
+
+int
+virStoragePoolObjListVolumes(virPoolObjTablePtr volumes,
+                             virConnectPtr conn,
+                             virStoragePoolDefPtr pooldef,
+                             virStoragePoolVolumeACLFilter aclfilter,
+                             char **const names,
+                             int maxnames)
+{
+    struct volListData data = { .conn = conn,
+                                .nnames = 0,
+                                .pooldef = pooldef,
+                                .aclfilter = aclfilter,
+                                .names = names,
+                                .maxnames = maxnames };
+
+    memset(names, 0, maxnames * sizeof(*names));
+
+    if (virPoolObjTableList(volumes, conn, NULL, volListVolumes, &data) < 0)
+        goto error;
+
+    return data.nnames;
+
+ error:
+    while (--data.nnames >= 0)
+        VIR_FREE(names[data.nnames]);
+    return -1;
+}
+
+
+/*
+ * virStoragePoolObjIsDuplicate:
+ * @pools: Pool to search
+ * @def: virStoragePoolDefPtr definition of pool to lookup
+ * @check_active: If true, ensure that pool is not active
+ *
+ * Returns: -1 on error
+ *          0 if pool is new
+ *          1 if pool is a duplicate
+ */
+int
+virStoragePoolObjIsDuplicate(virPoolObjTablePtr pools,
+                             virStoragePoolDefPtr def,
+                             unsigned int check_active)
+{
+    int ret = -1;
+    virPoolObjPtr obj = NULL;
+
+    /* See if a Pool with matching UUID already exists */
+    if ((obj = virPoolObjTableFindByUUIDRef(pools, def->uuid))) {
+        virStoragePoolDefPtr objdef = virPoolObjGetDef(obj);
+
+        /* UUID matches, but if names don't match, refuse it */
+        if (STRNEQ(objdef->name, def->name)) {
+            char uuidstr[VIR_UUID_STRING_BUFLEN];
+            virUUIDFormat(objdef->uuid, uuidstr);
+            virReportError(VIR_ERR_OPERATION_FAILED,
+                           _("pool '%s' is already defined with uuid %s"),
+                           objdef->name, uuidstr);
+            goto cleanup;
+        }
+
+        if (check_active) {
+            /* UUID & name match, but if Pool is already active, refuse it */
+            if (virPoolObjIsActive(obj)) {
+                virReportError(VIR_ERR_OPERATION_INVALID,
+                               _("pool is already active as '%s'"),
+                               objdef->name);
+                goto cleanup;
+            }
+        }
+
+        ret = 1;
+    } else {
+        /* UUID does not match, but if a name matches, refuse it */
+        if ((obj = virPoolObjTableFindByName(pools, def->name))) {
+            virStoragePoolDefPtr objdef = virPoolObjGetDef(obj);
+            char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+            virUUIDFormat(objdef->uuid, uuidstr);
+            virReportError(VIR_ERR_OPERATION_FAILED,
+                           _("pool '%s' already exists with uuid %s"),
+                           objdef->name, uuidstr);
+            goto cleanup;
+        }
+        ret = 0;
+    }
+
+ cleanup:
+    virPoolObjEndAPI(&obj);
+    return ret;
+}
+
+
+static int
+storagePoolAssignDef(virPoolObjPtr obj,
+                     void *newDef,
+                     void *oldDef ATTRIBUTE_UNUSED,
+                     unsigned int assignFlags ATTRIBUTE_UNUSED)
+{
+    virStoragePoolDefPtr newdef = newDef;
+
+    if (!virPoolObjIsActive(obj))
+        virPoolObjSetDef(obj, newdef);
+    else
+        virPoolObjSetNewDef(obj, newdef);
+    return 0;
+}
+
+
+virPoolObjPtr
+virStoragePoolObjAdd(virPoolObjTablePtr pools,
+                     virStoragePoolDefPtr def)
+{
+    virPoolObjPtr obj = NULL;
+    virStoragePoolObjPrivatePtr objpriv = NULL;
+    char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+    virUUIDFormat(def->uuid, uuidstr);
+
+    if (!(obj = virPoolObjTableAdd(pools, uuidstr, def->name,
+                                   def, NULL, NULL, virStoragePoolDefFree,
+                                   storagePoolAssignDef, 0)))
+        return NULL;
+
+    if (!(objpriv = virPoolObjGetPrivateData(obj))) {
+        if (!(objpriv = virStoragePoolObjPrivateAlloc()))
+            goto error;
+
+        virPoolObjSetPrivateData(obj, objpriv, virStoragePoolObjPrivateFree);
+    }
+
+    return obj;
+
+ error:
+    virPoolObjTableRemove(pools, &obj);
+    virPoolObjEndAPI(&obj);
+    return NULL;
+}
+
+
+static virPoolObjPtr
+virStoragePoolObjLoad(virPoolObjTablePtr pools,
+                      const char *configFile)
+{
+    virStoragePoolDefPtr def;
+
+    if (!(def = virStoragePoolDefParseFile(configFile)))
+        return NULL;
+
+    if (!virFileMatchesNameSuffix(configFile, def->name, ".xml")) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Storage pool config filename '%s' does "
+                         "not match pool name '%s'"),
+                       configFile, def->name);
+        virStoragePoolDefFree(def);
+        return NULL;
+    }
+
+    return virStoragePoolObjAdd(pools, def);
+}
+
+
+static virPoolObjPtr
+virStoragePoolLoadState(virPoolObjTablePtr pools,
+                        const char *stateDir,
+                        const char *name)
+{
+    char *stateFile = NULL;
+    virStoragePoolDefPtr def = NULL;
+    virPoolObjPtr obj = NULL;
+    xmlDocPtr xml = NULL;
+    xmlXPathContextPtr ctxt = NULL;
+    xmlNodePtr node = NULL;
+
+    if (!(stateFile = virFileBuildPath(stateDir, name, ".xml")))
+        goto error;
+
+    if (!(xml = virXMLParseCtxt(stateFile, NULL, _("(pool state)"), &ctxt)))
+        goto error;
+
+    if (!(node = virXPathNode("//pool", ctxt))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Could not find any 'pool' element in state file"));
+        goto error;
+    }
+
+    ctxt->node = node;
+    if (!(def = virStoragePoolDefParseXML(ctxt)))
+        goto error;
+
+    if (STRNEQ(name, def->name)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Storage pool state file '%s' does not match "
+                         "pool name '%s'"),
+                       stateFile, def->name);
+        goto error;
+    }
+
+    /* create the object */
+    if (!(obj = virStoragePoolObjAdd(pools, def)))
+        goto error;
+
+    /* XXX: future handling of some additional useful status data,
+     * for now, if a status file for a pool exists, the pool will be marked
+     * as active
+     */
+    virPoolObjSetActive(obj, true);
+
+ cleanup:
+    VIR_FREE(stateFile);
+    xmlFreeDoc(xml);
+    xmlXPathFreeContext(ctxt);
+    return obj;
+
+ error:
+    virStoragePoolDefFree(def);
+    goto cleanup;
+}
+
+
+int
+virStoragePoolObjLoadAllState(virPoolObjTablePtr pools,
+                              const char *stateDir)
+{
+    DIR *dir;
+    struct dirent *entry;
+    int ret = -1;
+    int rc;
+
+    if ((rc = virDirOpenIfExists(&dir, stateDir)) <= 0)
+        return rc;
+
+    while ((ret = virDirRead(dir, &entry, stateDir)) > 0) {
+        virPoolObjPtr obj;
+
+        if (!virFileStripSuffix(entry->d_name, ".xml"))
+            continue;
+
+        if (!(obj = virStoragePoolLoadState(pools, stateDir, entry->d_name)))
+            continue;
+        virPoolObjEndAPI(&obj);
+    }
+
+    VIR_DIR_CLOSE(dir);
+    return ret;
+}
+
+
+int
+virStoragePoolObjLoadAllConfigs(virPoolObjTablePtr pools,
+                                const char *configDir,
+                                const char *autostartDir)
+{
+    DIR *dir;
+    struct dirent *entry;
+    int ret;
+    int rc;
+
+    if ((rc = virDirOpenIfExists(&dir, configDir)) <= 0)
+        return rc;
+
+    while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
+        char *configFile;
+        char *autostartLink;
+        virPoolObjPtr obj;
+        virStoragePoolObjPrivatePtr objpriv;
+
+        if (!virFileHasSuffix(entry->d_name, ".xml"))
+            continue;
+
+        if (!(configFile = virFileBuildPath(configDir, entry->d_name, NULL)))
+            continue;
+
+        if (!(autostartLink = virFileBuildPath(autostartDir, entry->d_name,
+                                               NULL))) {
+            VIR_FREE(configFile);
+            continue;
+        }
+
+        if (!(obj = virStoragePoolObjLoad(pools, configFile))) {
+            VIR_FREE(configFile);
+            VIR_FREE(autostartLink);
+            continue;
+        }
+        objpriv = virPoolObjGetPrivateData(obj);
+
+        /* for driver reload */
+        VIR_FREE(objpriv->configFile);
+        VIR_FREE(objpriv->autostartLink);
+
+        VIR_STEAL_PTR(objpriv->configFile, configFile);
+        VIR_STEAL_PTR(objpriv->autostartLink, autostartLink);
+
+        if (virFileLinkPointsTo(objpriv->autostartLink, objpriv->configFile))
+            virPoolObjSetAutostart(obj, true);
+        else
+            virPoolObjSetAutostart(obj, false);
+
+        virPoolObjEndAPI(&obj);
+    }
+
+    VIR_DIR_CLOSE(dir);
+    return ret;
+}
+
+
+int
+virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
+                         virPoolObjPtr obj)
+{
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(obj);
+
+    if (!objpriv->configFile) {
+        if (virFileMakePath(driver->configDir) < 0) {
+            virReportSystemError(errno,
+                                 _("cannot create config directory %s"),
+                                 driver->configDir);
+            return -1;
+        }
+
+        if (!(objpriv->configFile = virFileBuildPath(driver->configDir,
+                                                     def->name, ".xml"))) {
+            return -1;
+        }
+
+        if (!(objpriv->autostartLink = virFileBuildPath(driver->autostartDir,
+                                                        def->name, ".xml"))) {
+            VIR_FREE(objpriv->configFile);
+            return -1;
+        }
+    }
+
+    return virStoragePoolSaveConfig(objpriv->configFile, def);
+}
+
+
+int
+virStoragePoolObjDeleteDef(virPoolObjPtr obj)
+{
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(obj);
+
+    if (!objpriv->configFile) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("no config file for %s"), def->name);
+        return -1;
+    }
+
+    if (unlink(objpriv->configFile) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("cannot remove config for %s"),
+                       def->name);
+        return -1;
+    }
+
+    if (unlink(objpriv->autostartLink) < 0 &&
+        errno != ENOENT && errno != ENOTDIR) {
+        char ebuf[1024];
+
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Failed to delete autostart link '%s': %s"),
+                       objpriv->autostartLink,
+                       virStrerror(errno, ebuf, sizeof(ebuf)));
+        return -1;
+    }
+
+    return 0;
+}
+
+struct storageCountData {
+    bool wantActive;
+    int count;
+};
+
+static int
+storageCount(virPoolObjPtr obj,
+             void *opaque)
+{
+    struct storageCountData *data = opaque;
+
+    if ((data->wantActive && virPoolObjIsActive(obj)) ||
+        (!data->wantActive && !virPoolObjIsActive(obj)))
+        data->count++;
+
+    return 0;
+}
+
+
+int
+virStoragePoolObjNumOfStoragePools(virPoolObjTablePtr pools,
+                                   virConnectPtr conn,
+                                   bool wantActive,
+                                   virPoolObjACLFilter aclfilter)
+{
+    struct storageCountData data = { .count = 0,
+                                     .wantActive = wantActive };
+
+    if (virPoolObjTableList(pools, conn, aclfilter, storageCount, &data) < 0)
+        return 0;
+
+    return data.count;
+}
+
+
+struct poolNameData {
+    bool wantActive;
+    int nnames;
+    char **const names;
+    int maxnames;
+};
+
+static int
+storageGetNames(virPoolObjPtr obj ATTRIBUTE_UNUSED,
+                void *opaque)
+{
+    struct poolNameData *data = opaque;
+
+    if (data->nnames < data->maxnames) {
+        if (data->wantActive && virPoolObjIsActive(obj)) {
+            virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+
+            if (VIR_STRDUP(data->names[data->nnames++], def->name) < 0)
+                return -1;
+        } else if (!data->wantActive && !virPoolObjIsActive(obj)) {
+            virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+
+            if (VIR_STRDUP(data->names[data->nnames++], def->name) < 0)
+                return -1;
+        }
+    }
+    return 0;
+}
+
+
+int
+virStoragePoolObjGetNames(virPoolObjTablePtr pools,
+                          virConnectPtr conn,
+                          bool wantActive,
+                          virPoolObjACLFilter aclfilter,
+                          char **const names,
+                          int maxnames)
+{
+    struct poolNameData data = { .wantActive = wantActive,
+                                 .nnames = 0,
+                                 .names = names,
+                                 .maxnames = maxnames };
+
+    memset(names, 0, sizeof(*names) * maxnames);
+    if (virPoolObjTableList(pools, conn, aclfilter,
+                            storageGetNames, &data) < 0)
+        goto error;
+
+    return data.nnames;
+
+ error:
+    while (--data.nnames >= 0)
+        VIR_FREE(names[data.nnames]);
+    return -1;
+}
+
+
+static int
+getSCSIHostNumber(virStoragePoolSourceAdapter adapter,
+                  unsigned int *hostnum)
+{
+    int ret = -1;
+    unsigned int num;
+    char *name = NULL;
+
+    if (adapter.data.scsi_host.has_parent) {
+        virPCIDeviceAddress addr = adapter.data.scsi_host.parentaddr;
+        unsigned int unique_id = adapter.data.scsi_host.unique_id;
+
+        if (!(name = virGetSCSIHostNameByParentaddr(addr.domain,
+                                                    addr.bus,
+                                                    addr.slot,
+                                                    addr.function,
+                                                    unique_id)))
+            goto cleanup;
+        if (virGetSCSIHostNumber(name, &num) < 0)
+            goto cleanup;
+    } else {
+        if (virGetSCSIHostNumber(adapter.data.scsi_host.name, &num) < 0)
+            goto cleanup;
+    }
+
+    *hostnum = num;
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(name);
+    return ret;
+}
+
+
+/*
+ * matchFCHostToSCSIHost:
+ *
+ * @conn: Connection pointer
+ * @fc_adapter: fc_host adapter (either def or pool->def)
+ * @scsi_hostnum: Already determined "scsi_pool" hostnum
+ *
+ * Returns true/false whether there is a match between the incoming
+ *         fc_adapter host# and the scsi_host host#
+ */
+static bool
+matchFCHostToSCSIHost(virConnectPtr conn,
+                      virStoragePoolSourceAdapter fc_adapter,
+                      unsigned int scsi_hostnum)
+{
+    char *name = NULL;
+    char *parent_name = NULL;
+    unsigned int fc_hostnum;
+
+    /* If we have a parent defined, get its hostnum, and compare to the
+     * scsi_hostnum. If they are the same, then we have a match
+     */
+    if (fc_adapter.data.fchost.parent &&
+        virGetSCSIHostNumber(fc_adapter.data.fchost.parent, &fc_hostnum) == 0 &&
+        scsi_hostnum == fc_hostnum)
+        return true;
+
+    /* If we find an fc_adapter name, then either libvirt created a vHBA
+     * for this fc_host or a 'virsh nodedev-create' generated a vHBA.
+     */
+    if ((name = virGetFCHostNameByWWN(NULL, fc_adapter.data.fchost.wwnn,
+                                      fc_adapter.data.fchost.wwpn))) {
+
+        /* Get the scsi_hostN for the vHBA in order to see if it
+         * matches our scsi_hostnum
+         */
+        if (virGetSCSIHostNumber(name, &fc_hostnum) == 0 &&
+            scsi_hostnum == fc_hostnum) {
+            VIR_FREE(name);
+            return true;
+        }
+
+        /* We weren't provided a parent, so we have to query the node
+         * device driver in order to ascertain the parent of the vHBA.
+         * If the parent fc_hostnum is the same as the scsi_hostnum, we
+         * have a match.
+         */
+        if (conn && !fc_adapter.data.fchost.parent) {
+            parent_name = virStoragePoolGetVhbaSCSIHostParent(conn, name);
+            if (parent_name) {
+                if (virGetSCSIHostNumber(parent_name, &fc_hostnum) == 0 &&
+                    scsi_hostnum == fc_hostnum) {
+                    VIR_FREE(parent_name);
+                    VIR_FREE(name);
+                    return true;
+                }
+                VIR_FREE(parent_name);
+            } else {
+                /* Throw away the error and fall through */
+                virResetLastError();
+                VIR_DEBUG("Could not determine parent vHBA");
+            }
+        }
+        VIR_FREE(name);
+    }
+
+    /* NB: Lack of a name means that this vHBA hasn't yet been created,
+     *     which means our scsi_host cannot be using the vHBA. Furthermore,
+     *     lack of a provided parent means libvirt is going to choose the
+     *     "best" fc_host capable adapter based on availabilty. That could
+     *     conflict with an existing scsi_host definition, but there's no
+     *     way to know that now.
+     */
+    return false;
+}
+
+
+static bool
+matchSCSIAdapterParent(virPoolObjPtr obj,
+                       virStoragePoolDefPtr def)
+{
+    virStoragePoolDefPtr objdef = virPoolObjGetDef(obj);
+    virPCIDeviceAddressPtr objaddr =
+        &objdef->source.adapter.data.scsi_host.parentaddr;
+    virPCIDeviceAddressPtr defaddr =
+        &def->source.adapter.data.scsi_host.parentaddr;
+    int obj_unique_id =
+        objdef->source.adapter.data.scsi_host.unique_id;
+    int def_unique_id =
+        def->source.adapter.data.scsi_host.unique_id;
+
+    return (objaddr->domain == defaddr->domain &&
+            objaddr->bus == defaddr->bus &&
+            objaddr->slot == defaddr->slot &&
+            objaddr->function == defaddr->function &&
+            obj_unique_id == def_unique_id);
+}
+
+
+static bool
+virStoragePoolSourceMatchSingleHost(virStoragePoolSourcePtr poolsrc,
+                                    virStoragePoolSourcePtr defsrc)
+{
+    if (poolsrc->nhost != 1 && defsrc->nhost != 1)
+        return false;
+
+    if (defsrc->hosts[0].port &&
+        poolsrc->hosts[0].port != defsrc->hosts[0].port)
+        return false;
+
+    return STREQ(poolsrc->hosts[0].name, defsrc->hosts[0].name);
+}
+
+
+static bool
+virStoragePoolSourceISCSIMatch(virPoolObjPtr obj,
+                               virStoragePoolDefPtr def)
+{
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(obj);
+    virStoragePoolSourcePtr objsrc = &pooldef->source;
+    virStoragePoolSourcePtr defsrc = &def->source;
+
+    /* NB: Do not check the source host name */
+    if (STRNEQ_NULLABLE(objsrc->initiator.iqn, defsrc->initiator.iqn))
+        return false;
+
+    return true;
+}
+
+
+struct storagePoolDuplicateData {
+    virConnectPtr conn;
+    virStoragePoolDefPtr def;
+};
+
+static bool
+storagePoolSourceFindDuplicateDevices(virPoolObjPtr obj,
+                                      virStoragePoolDefPtr def)
+{
+    virStoragePoolDefPtr objdef = virPoolObjGetDef(obj);
+    size_t i, j;
+
+    for (i = 0; i < objdef->source.ndevice; i++) {
+        for (j = 0; j < def->source.ndevice; j++) {
+            if (STREQ(objdef->source.devices[i].path,
+                      def->source.devices[j].path))
+                return true;
+        }
+    }
+
+    return false;
+}
+
+
+static bool
+storagePoolSourceFindDuplicate(virPoolObjPtr obj,
+                               void *opaque)
+{
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    struct storagePoolDuplicateData *data = opaque;
+
+    /* Check the pool list for duplicate underlying storage */
+    if (data->def->type != def->type)
+        return false;
+
+    /* Don't match against ourself if re-defining existing pool ! */
+    if (STREQ(def->name, data->def->name))
+        return false;
+
+    switch ((virStoragePoolType)def->type) {
+    case VIR_STORAGE_POOL_DIR:
+        if (STREQ(def->target.path, data->def->target.path))
+            return true;
+        break;
+
+    case VIR_STORAGE_POOL_GLUSTER:
+        if (STREQ(def->source.name, data->def->source.name) &&
+            STREQ_NULLABLE(def->source.dir, data->def->source.dir) &&
+            virStoragePoolSourceMatchSingleHost(&def->source,
+                                                &data->def->source))
+            return true;
+        break;
+
+    case VIR_STORAGE_POOL_NETFS:
+        if (STREQ(def->source.dir, data->def->source.dir) &&
+            virStoragePoolSourceMatchSingleHost(&def->source,
+                                                &data->def->source))
+            return true;
+        break;
+
+    case VIR_STORAGE_POOL_SCSI:
+        if (def->source.adapter.type ==
+            VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST &&
+            data->def->source.adapter.type ==
+            VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
+            if (STREQ(def->source.adapter.data.fchost.wwnn,
+                      data->def->source.adapter.data.fchost.wwnn) &&
+                STREQ(def->source.adapter.data.fchost.wwpn,
+                      data->def->source.adapter.data.fchost.wwpn))
+                return true;
+        } else if (def->source.adapter.type ==
+                   VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST &&
+                   data->def->source.adapter.type ==
+                   VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
+            unsigned int pool_hostnum, def_hostnum;
+
+            if (def->source.adapter.data.scsi_host.has_parent &&
+                data->def->source.adapter.data.scsi_host.has_parent &&
+                matchSCSIAdapterParent(obj, data->def))
+                return true;
+
+            if (getSCSIHostNumber(def->source.adapter,
+                                  &pool_hostnum) < 0 ||
+                getSCSIHostNumber(data->def->source.adapter, &def_hostnum) < 0)
+                break;
+            if (pool_hostnum == def_hostnum)
+                return true;
+        } else if (def->source.adapter.type ==
+                   VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST &&
+                   data->def->source.adapter.type ==
+                   VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
+            unsigned int scsi_hostnum;
+
+            /* Get the scsi_hostN for the scsi_host source adapter def */
+            if (getSCSIHostNumber(data->def->source.adapter,
+                                  &scsi_hostnum) < 0)
+                break;
+
+            if (matchFCHostToSCSIHost(data->conn, def->source.adapter,
+                                      scsi_hostnum)) {
+                return true;
+            }
+
+        } else if (def->source.adapter.type ==
+                   VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST &&
+                   data->def->source.adapter.type ==
+                   VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
+            unsigned int scsi_hostnum;
+
+            if (getSCSIHostNumber(def->source.adapter,
+                                  &scsi_hostnum) < 0)
+                break;
+
+            if (matchFCHostToSCSIHost(data->conn, data->def->source.adapter,
+                                      scsi_hostnum))
+                return true;
+        }
+        break;
+    case VIR_STORAGE_POOL_ISCSI:
+        if (storagePoolSourceFindDuplicateDevices(obj, data->def)) {
+            if (virStoragePoolSourceISCSIMatch(obj, data->def))
+                return true;
+        }
+        break;
+    case VIR_STORAGE_POOL_FS:
+    case VIR_STORAGE_POOL_LOGICAL:
+    case VIR_STORAGE_POOL_DISK:
+    case VIR_STORAGE_POOL_ZFS:
+        if (storagePoolSourceFindDuplicateDevices(obj, data->def))
+            return true;
+        break;
+    case VIR_STORAGE_POOL_SHEEPDOG:
+        if (virStoragePoolSourceMatchSingleHost(&def->source,
+                                                &data->def->source))
+            return true;
+        break;
+    case VIR_STORAGE_POOL_MPATH:
+        /* Only one mpath pool is valid per host */
+        return true;
+        break;
+    case VIR_STORAGE_POOL_VSTORAGE:
+        if (STREQ(def->source.name, def->source.name))
+            return true;
+        break;
+    case VIR_STORAGE_POOL_RBD:
+    case VIR_STORAGE_POOL_LAST:
+        break;
+    }
+
+    return false;
+}
+
+
+bool
+virStoragePoolObjFindDuplicate(virPoolObjTablePtr pools,
+                               virConnectPtr conn,
+                               virStoragePoolDefPtr def)
+{
+    virPoolObjPtr obj;
+    struct storagePoolDuplicateData data = { .conn = conn,
+                                             .def = def };
+
+    if ((obj = virPoolObjTableSearchRef(pools, storagePoolSourceFindDuplicate,
+                                        &data))) {
+        virStoragePoolDefPtr objdef = virPoolObjGetDef(obj);
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("Storage source conflict with pool: '%s'"),
+                       objdef->name);
+        virPoolObjEndAPI(&obj);
+        return true;
+    }
+
+    return false;
+
+}
+
+
+#define MATCH(FLAG) (flags & (FLAG))
+static bool
+virStoragePoolMatch(virPoolObjPtr obj,
+                    unsigned int flags)
+{
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(obj);
+
+    /* filter by active state */
+    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) &&
+        !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE) &&
+           virPoolObjIsActive(obj)) ||
+          (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE) &&
+           !virPoolObjIsActive(obj))))
+        return false;
+
+    /* filter by persistence */
+    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_PERSISTENT) &&
+        !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT) &&
+           objpriv->configFile) ||
+          (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT) &&
+           !objpriv->configFile)))
+        return false;
+
+    /* filter by autostart option */
+    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART) &&
+        !((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART) &&
+           virPoolObjIsAutostart(obj)) ||
+          (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART) &&
+           !virPoolObjIsAutostart(obj))))
+        return false;
+
+    /* filter by pool type */
+    if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)) {
+        if (!((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_DIR) &&
+               (def->type == VIR_STORAGE_POOL_DIR))     ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FS) &&
+               (def->type == VIR_STORAGE_POOL_FS))      ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NETFS) &&
+               (def->type == VIR_STORAGE_POOL_NETFS))   ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_LOGICAL) &&
+               (def->type == VIR_STORAGE_POOL_LOGICAL)) ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_DISK) &&
+               (def->type == VIR_STORAGE_POOL_DISK))    ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI) &&
+               (def->type == VIR_STORAGE_POOL_ISCSI))   ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SCSI) &&
+               (def->type == VIR_STORAGE_POOL_SCSI))    ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_MPATH) &&
+               (def->type == VIR_STORAGE_POOL_MPATH))   ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_RBD) &&
+               (def->type == VIR_STORAGE_POOL_RBD))     ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG) &&
+               (def->type == VIR_STORAGE_POOL_SHEEPDOG)) ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER) &&
+               (def->type == VIR_STORAGE_POOL_GLUSTER))))
+            return false;
+    }
+
+    return true;
+}
+#undef MATCH
+
+int
+virStoragePoolObjExportList(virConnectPtr conn,
+                            virPoolObjTablePtr poolobjs,
+                            virStoragePoolPtr **pools,
+                            virPoolObjACLFilter aclfilter,
+                            unsigned int flags)
+{
+    virPoolObjPtr *objs = NULL;
+    size_t nobjs;
+    virStoragePoolPtr *tmp_pools = NULL;
+    size_t i;
+
+    if (virPoolObjTableCollect(poolobjs, conn, &objs, &nobjs, aclfilter,
+                               virStoragePoolMatch, flags) < 0)
+        return -1;
+
+    if (pools) {
+        if (VIR_ALLOC_N(tmp_pools, nobjs + 1) < 0)
+            goto cleanup;
+
+        for (i = 0; i < nobjs; i++) {
+            virStoragePoolDefPtr def;
+
+            virObjectLock(objs[i]);
+            def = virPoolObjGetDef(objs[i]);
+            tmp_pools[i] = virGetStoragePool(conn, def->name, def->uuid,
+                                             NULL, NULL);
+            virObjectUnlock(objs[i]);
+            if (!tmp_pools[i])
+                goto cleanup;
+        }
+
+        VIR_STEAL_PTR(*pools, tmp_pools);
+    }
+
+ cleanup:
+    virObjectListFree(tmp_pools);
+    virObjectListFreeCount(objs, nobjs);
+
+    return nobjs;
+}
+
+
+struct volSearchData {
+    const char *compare;
+};
+
+static bool
+volFindByKey(virPoolObjPtr obj,
+             void *opaque)
+{
+    virStorageVolDefPtr def = virPoolObjGetDef(obj);
+    struct volSearchData *data = opaque;
+
+    if (STREQ(def->key, data->compare))
+        return true;
+
+    return false;
+}
+
+
+virPoolObjPtr
+virStorageVolObjFindByKey(virPoolObjPtr poolobj,
+                          const char *key)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+    struct volSearchData data = { .compare = key };
+
+    return virPoolObjTableSearchRef(objpriv->volumes, volFindByKey, &data);
+}
+
+
+static bool
+volFindByPath(virPoolObjPtr obj,
+              void *opaque)
+{
+    virStorageVolDefPtr def = virPoolObjGetDef(obj);
+    struct volSearchData *data = opaque;
+
+    if (STREQ(def->target.path, data->compare))
+        return true;
+
+    return false;
+}
+
+
+virPoolObjPtr
+virStorageVolObjFindByPath(virPoolObjPtr poolobj,
+                           const char *path)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+    struct volSearchData data = { .compare = path };
+
+    return virPoolObjTableSearchRef(objpriv->volumes, volFindByPath, &data);
+}
+
+
+virPoolObjPtr
+virStorageVolObjFindByName(virPoolObjPtr poolobj,
+                           const char *name)
+{
+    virStoragePoolObjPrivatePtr objpriv = virPoolObjGetPrivateData(poolobj);
+
+    return virPoolObjTableFindByName(objpriv->volumes, name);
+}
diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h
new file mode 100644
index 0000000..bbdc9aa
--- /dev/null
+++ b/src/conf/virstorageobj.h
@@ -0,0 +1,143 @@
+/*
+ * virstorageobj.h: internal storage pool and volume objects handling
+ *                  (derived from storage_conf.h)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VIR_STORAGEOBJ_H__
+# define __VIR_STORAGEOBJ_H__
+
+# include "internal.h"
+
+# include "storage_conf.h"
+# include "virpoolobj.h"
+
+typedef struct _virStoragePoolObjPrivate virStoragePoolObjPrivate;
+typedef virStoragePoolObjPrivate *virStoragePoolObjPrivatePtr;
+
+typedef struct _virStorageDriverState virStorageDriverState;
+typedef virStorageDriverState *virStorageDriverStatePtr;
+
+struct _virStorageDriverState {
+    virMutex lock;
+
+    virPoolObjTablePtr pools;
+
+    char *configDir;
+    char *autostartDir;
+    char *stateDir;
+    bool privileged;
+
+    /* Immutable pointer, self-locking APIs */
+    virObjectEventStatePtr storageEventState;
+};
+
+const char *virStoragePoolObjPrivateGetConfigFile(virPoolObjPtr poolobj);
+
+const char *virStoragePoolObjPrivateGetAutostartLink(virPoolObjPtr poolobj);
+
+int virStoragePoolObjPrivateGetAutostart(virPoolObjPtr poolobj);
+
+void virStoragePoolObjPrivateSetAutostart(virPoolObjPtr poolobj,
+                                          int autostart);
+
+int virStoragePoolObjPrivateGetAsyncjobs(virPoolObjPtr poolobj);
+
+void virStoragePoolObjPrivateIncrAsyncjobs(virPoolObjPtr poolobj);
+
+void virStoragePoolObjPrivateDecrAsyncjobs(virPoolObjPtr poolobj);
+
+virPoolObjTablePtr
+virStoragePoolObjPrivateGetVolumes(virPoolObjPtr poolobj);
+
+virPoolObjPtr
+virStoragePoolObjAddVolume(virPoolObjPtr poolobj, virStorageVolDefPtr voldef);
+
+void
+virStoragePoolObjRemoveVolume(virPoolObjPtr poolobj, virPoolObjPtr *volobj);
+
+void virStoragePoolObjClearVols(virPoolObjPtr pool);
+
+typedef bool (*virStoragePoolVolumeACLFilter)
+    (virConnectPtr conn, virStoragePoolDefPtr pool, void *objdef);
+
+int virStoragePoolObjNumOfVolumes(virPoolObjTablePtr volumes,
+                                  virConnectPtr conn,
+                                  virStoragePoolDefPtr pooldef,
+                                  virStoragePoolVolumeACLFilter aclfilter);
+
+int virStoragePoolObjListVolumes(virPoolObjTablePtr volumes,
+                                 virConnectPtr conn,
+                                 virStoragePoolDefPtr pooldef,
+                                 virStoragePoolVolumeACLFilter aclfilter,
+                                 char **const names,
+                                 int maxnames);
+
+int virStoragePoolObjIsDuplicate(virPoolObjTablePtr pools,
+                                 virStoragePoolDefPtr def,
+                                 unsigned int check_active);
+
+virPoolObjPtr
+virStoragePoolObjAdd(virPoolObjTablePtr pools,
+                     virStoragePoolDefPtr def);
+
+int virStoragePoolObjLoadAllConfigs(virPoolObjTablePtr pools,
+                                    const char *configDir,
+                                    const char *autostartDir);
+
+int virStoragePoolObjLoadAllState(virPoolObjTablePtr pools,
+                                  const char *stateDir);
+
+int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
+                             virPoolObjPtr obj);
+
+int virStoragePoolObjDeleteDef(virPoolObjPtr obj);
+
+int virStoragePoolObjNumOfStoragePools(virPoolObjTablePtr pools,
+                                       virConnectPtr conn,
+                                       bool wantActive,
+                                       virPoolObjACLFilter aclfilter);
+
+int virStoragePoolObjGetNames(virPoolObjTablePtr pools,
+                              virConnectPtr conn,
+                              bool wantActive,
+                              virPoolObjACLFilter aclfilter,
+                              char **const names,
+                              int maxnames);
+
+bool virStoragePoolObjFindDuplicate(virPoolObjTablePtr pools,
+                                    virConnectPtr conn,
+                                    virStoragePoolDefPtr def);
+
+int virStoragePoolObjExportList(virConnectPtr conn,
+                                virPoolObjTablePtr poolobjs,
+                                virStoragePoolPtr **pools,
+                                virPoolObjACLFilter aclfilter,
+                                unsigned int flags);
+
+virPoolObjPtr
+virStorageVolObjFindByKey(virPoolObjPtr poolobj,
+                          const char *key);
+
+virPoolObjPtr
+virStorageVolObjFindByPath(virPoolObjPtr poolobj,
+                           const char *path);
+
+virPoolObjPtr
+virStorageVolObjFindByName(virPoolObjPtr poolobj,
+                           const char *name);
+
+#endif /* __VIR_STORAGEOBJ_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 14c3682..5c91988 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -860,32 +860,12 @@ virStoragePoolFormatFileSystemNetTypeToString;
 virStoragePoolFormatFileSystemTypeToString;
 virStoragePoolFormatLogicalTypeToString;
 virStoragePoolGetVhbaSCSIHostParent;
-virStoragePoolLoadAllConfigs;
-virStoragePoolLoadAllState;
-virStoragePoolObjAddVolume;
-virStoragePoolObjAssignDef;
-virStoragePoolObjClearVols;
-virStoragePoolObjDeleteDef;
-virStoragePoolObjFindByName;
-virStoragePoolObjFindByUUID;
-virStoragePoolObjIsDuplicate;
-virStoragePoolObjListExport;
-virStoragePoolObjListFree;
-virStoragePoolObjListVolumes;
-virStoragePoolObjLock;
-virStoragePoolObjNumOfVolumes;
-virStoragePoolObjRemove;
-virStoragePoolObjRemoveVolume;
-virStoragePoolObjSaveDef;
-virStoragePoolObjUnlock;
 virStoragePoolSaveConfig;
 virStoragePoolSaveState;
 virStoragePoolSourceAdapterTypeFromString;
 virStoragePoolSourceAdapterTypeToString;
 virStoragePoolSourceClear;
 virStoragePoolSourceDeviceClear;
-virStoragePoolSourceFindDuplicate;
-virStoragePoolSourceFindDuplicateDevices;
 virStoragePoolSourceFree;
 virStoragePoolSourceListFormat;
 virStoragePoolSourceListNewSource;
@@ -896,9 +876,6 @@ virStorageVolDefFree;
 virStorageVolDefParseFile;
 virStorageVolDefParseNode;
 virStorageVolDefParseString;
-virStorageVolObjFindByKey;
-virStorageVolObjFindByName;
-virStorageVolObjFindByPath;
 virStorageVolTypeFromString;
 virStorageVolTypeToString;
 
@@ -1013,6 +990,33 @@ virSecretObjSetValue;
 virSecretObjSetValueSize;
 
 
+# conf/virstorageobj.h
+virStoragePoolObjAdd;
+virStoragePoolObjAddVolume;
+virStoragePoolObjClearVols;
+virStoragePoolObjDeleteDef;
+virStoragePoolObjExportList;
+virStoragePoolObjFindDuplicate;
+virStoragePoolObjGetNames;
+virStoragePoolObjIsDuplicate;
+virStoragePoolObjListVolumes;
+virStoragePoolObjLoadAllConfigs;
+virStoragePoolObjLoadAllState;
+virStoragePoolObjNumOfStoragePools;
+virStoragePoolObjNumOfVolumes;
+virStoragePoolObjPrivateDecrAsyncjobs;
+virStoragePoolObjPrivateGetAsyncjobs;
+virStoragePoolObjPrivateGetAutostartLink;
+virStoragePoolObjPrivateGetConfigFile;
+virStoragePoolObjPrivateGetVolumes;
+virStoragePoolObjPrivateIncrAsyncjobs;
+virStoragePoolObjRemoveVolume;
+virStoragePoolObjSaveDef;
+virStorageVolObjFindByKey;
+virStorageVolObjFindByName;
+virStorageVolObjFindByPath;
+
+
 # cpu/cpu.h
 cpuBaseline;
 cpuBaselineXML;
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index b8fb368..e82fc31 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -22,25 +22,25 @@
 # include <sys/stat.h>
 
 # include "internal.h"
-# include "storage_conf.h"
+# include "virstorageobj.h"
 # include "storage_driver.h"
 
 typedef char * (*virStorageBackendFindPoolSources)(virConnectPtr conn,
                                                    const char *srcSpec,
                                                    unsigned int flags);
-typedef int (*virStorageBackendCheckPool)(virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendCheckPool)(virPoolObjPtr obj,
                                           bool *active);
 typedef int (*virStorageBackendStartPool)(virConnectPtr conn,
-                                          virStoragePoolObjPtr pool);
+                                          virPoolObjPtr obj);
 typedef int (*virStorageBackendBuildPool)(virConnectPtr conn,
-                                          virStoragePoolObjPtr pool,
+                                          virPoolObjPtr obj,
                                           unsigned int flags);
 typedef int (*virStorageBackendRefreshPool)(virConnectPtr conn,
-                                            virStoragePoolObjPtr pool);
+                                            virPoolObjPtr obj);
 typedef int (*virStorageBackendStopPool)(virConnectPtr conn,
-                                         virStoragePoolObjPtr pool);
+                                         virPoolObjPtr obj);
 typedef int (*virStorageBackendDeletePool)(virConnectPtr conn,
-                                           virStoragePoolObjPtr pool,
+                                           virPoolObjPtr obj,
                                            unsigned int flags);
 
 /* A 'buildVol' backend must remove any volume created on error since
@@ -53,45 +53,45 @@ typedef int (*virStorageBackendDeletePool)(virConnectPtr conn,
  * also avoids extra round trips to just delete a file.
  */
 typedef int (*virStorageBackendBuildVol)(virConnectPtr conn,
-                                         virStoragePoolObjPtr pool,
+                                         virPoolObjPtr poolobj,
                                          virStorageVolDefPtr vol,
                                          unsigned int flags);
 typedef int (*virStorageBackendCreateVol)(virConnectPtr conn,
-                                          virStoragePoolObjPtr pool,
+                                          virPoolObjPtr poolobj,
                                           virStorageVolDefPtr vol);
 typedef int (*virStorageBackendRefreshVol)(virConnectPtr conn,
-                                           virStoragePoolObjPtr pool,
+                                           virPoolObjPtr poolobj,
                                            virStorageVolDefPtr vol);
 typedef int (*virStorageBackendDeleteVol)(virConnectPtr conn,
-                                          virStoragePoolObjPtr pool,
+                                          virPoolObjPtr poolobj,
                                           virStorageVolDefPtr vol,
                                           unsigned int flags);
 typedef int (*virStorageBackendBuildVolFrom)(virConnectPtr conn,
-                                             virStoragePoolObjPtr pool,
+                                             virPoolObjPtr poolobj,
                                              virStorageVolDefPtr origvol,
                                              virStorageVolDefPtr newvol,
                                              unsigned int flags);
 typedef int (*virStorageBackendVolumeResize)(virConnectPtr conn,
-                                             virStoragePoolObjPtr pool,
+                                             virPoolObjPtr poolobj,
                                              virStorageVolDefPtr vol,
                                              unsigned long long capacity,
                                              unsigned int flags);
 typedef int (*virStorageBackendVolumeDownload)(virConnectPtr conn,
-                                               virStoragePoolObjPtr obj,
+                                               virPoolObjPtr poolobj,
                                                virStorageVolDefPtr vol,
                                                virStreamPtr stream,
                                                unsigned long long offset,
                                                unsigned long long length,
                                                unsigned int flags);
 typedef int (*virStorageBackendVolumeUpload)(virConnectPtr conn,
-                                             virStoragePoolObjPtr obj,
+                                             virPoolObjPtr poolobj,
                                              virStorageVolDefPtr vol,
                                              virStreamPtr stream,
                                              unsigned long long offset,
                                              unsigned long long len,
                                              unsigned int flags);
 typedef int (*virStorageBackendVolumeWipe)(virConnectPtr conn,
-                                           virStoragePoolObjPtr pool,
+                                           virPoolObjPtr poolobj,
                                            virStorageVolDefPtr vol,
                                            unsigned int algorithm,
                                            unsigned int flags);
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index dcf4e3e..b1ac431 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -58,10 +58,11 @@ volPartFindExtended(virPoolObjPtr volobj,
 
 
 static int
-virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
+virStorageBackendDiskMakeDataVol(virPoolObjPtr poolobj,
                                  char **const groups,
                                  virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(poolobj);
     char *tmp, *devpath, *partname;
 
     /* Prepended path will be same for all partitions, so we can
@@ -83,7 +84,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
             return -1;
         }
 
-        if (!(volobj = virStoragePoolObjAddVolume(pool, vol))) {
+        if (!(volobj = virStoragePoolObjAddVolume(poolobj, vol))) {
             virStorageVolDefFree(vol);
             return -1;
         }
@@ -100,7 +101,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
          * dir every time its run. Should figure out a more efficient
          * way of doing this...
          */
-        vol->target.path = virStorageBackendStablePath(pool, devpath, true);
+        vol->target.path = virStorageBackendStablePath(poolobj, devpath, true);
         VIR_FREE(devpath);
         if (vol->target.path == NULL)
             return -1;
@@ -122,7 +123,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
          * our deletion will fail because the name we generated is wrong.
          * Check for our conditions and see if the generated name is the
          * same as StablePath returns and has the 'p' in it */
-        if (pool->def->source.devices[0].part_separator ==
+        if (pooldef->source.devices[0].part_separator ==
             VIR_TRISTATE_BOOL_YES &&
             !virIsDevMapperDevice(vol->target.path) &&
             STREQ(groups[0], vol->target.path) &&
@@ -166,7 +167,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
         }
 
         if (VIR_STRDUP(vol->source.extents[0].path,
-                       pool->def->source.devices[0].path) < 0)
+                       pooldef->source.devices[0].path) < 0)
             return -1;
     }
 
@@ -210,9 +211,11 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
 
     /* Find the extended partition and increase the allocation value */
     if (vol->source.partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) {
+        virPoolObjTablePtr volumes =
+            virStoragePoolObjPrivateGetVolumes(poolobj);
         virPoolObjPtr volobj;
 
-        if ((volobj = virPoolObjTableSearch(pool->volumes, volPartFindExtended,
+        if ((volobj = virPoolObjTableSearch(volumes, volPartFindExtended,
                                             NULL))) {
             virStorageVolDefPtr voldef = virPoolObjGetDef(volobj);
             voldef->target.allocation += vol->target.allocation;
@@ -221,18 +224,19 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
     }
 
     if (STRNEQ(groups[2], "metadata"))
-        pool->def->allocation += vol->target.allocation;
-    if (vol->source.extents[0].end > pool->def->capacity)
-        pool->def->capacity = vol->source.extents[0].end;
+        pooldef->allocation += vol->target.allocation;
+    if (vol->source.extents[0].end > pooldef->capacity)
+        pooldef->capacity = vol->source.extents[0].end;
 
     return 0;
 }
 
 static int
-virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool,
+virStorageBackendDiskMakeFreeExtent(virPoolObjPtr poolobj,
                                     char **const groups)
 {
-    virStoragePoolSourceDevicePtr dev = &pool->def->source.devices[0];
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(poolobj);
+    virStoragePoolSourceDevicePtr dev = &pooldef->source.devices[0];
 
     if (VIR_REALLOC_N(dev->freeExtents,
                       dev->nfreeExtent + 1) < 0)
@@ -262,11 +266,11 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool,
     if (dev->freeExtents[dev->nfreeExtent].start == 0)
         dev->freeExtents[dev->nfreeExtent].start = SECTOR_SIZE;
 
-    pool->def->available +=
+    pooldef->available +=
         (dev->freeExtents[dev->nfreeExtent].end -
          dev->freeExtents[dev->nfreeExtent].start);
-    if (dev->freeExtents[dev->nfreeExtent].end > pool->def->capacity)
-        pool->def->capacity = dev->freeExtents[dev->nfreeExtent].end;
+    if (dev->freeExtents[dev->nfreeExtent].end > pooldef->capacity)
+        pooldef->capacity = dev->freeExtents[dev->nfreeExtent].end;
 
     dev->nfreeExtent++;
 
@@ -275,7 +279,7 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool,
 
 
 struct virStorageBackendDiskPoolVolData {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr poolobj;
     virStorageVolDefPtr vol;
 };
 
@@ -285,7 +289,7 @@ virStorageBackendDiskMakeVol(size_t ntok ATTRIBUTE_UNUSED,
                              void *opaque)
 {
     struct virStorageBackendDiskPoolVolData *data = opaque;
-    virStoragePoolObjPtr pool = data->pool;
+    virPoolObjPtr poolobj = data->poolobj;
     /*
      * Ignore normal+metadata, and logical+metadata partitions
      * since they're basically internal book-keeping regions
@@ -311,7 +315,7 @@ virStorageBackendDiskMakeVol(size_t ntok ATTRIBUTE_UNUSED,
             } else {
                 virPoolObjPtr volobj;
 
-                if ((volobj = virStorageVolObjFindByKey(pool, groups[0]))) {
+                if ((volobj = virStorageVolObjFindByKey(poolobj, groups[0]))) {
                     /* If no key, the volume must be newly created. If groups[0]
                      * isn't already a volume, assume it's the path we want */
                     virPoolObjEndAPI(&volobj);
@@ -320,10 +324,10 @@ virStorageBackendDiskMakeVol(size_t ntok ATTRIBUTE_UNUSED,
             }
         }
 
-        return virStorageBackendDiskMakeDataVol(pool, groups, voldef);
+        return virStorageBackendDiskMakeDataVol(poolobj, groups, voldef);
     } else if (STREQ(groups[2], "free")) {
         /* ....or free space extents */
-        return virStorageBackendDiskMakeFreeExtent(pool, groups);
+        return virStorageBackendDiskMakeFreeExtent(poolobj, groups);
     } else {
         /* This code path should never happen unless someone changed
          * libvirt_parthelper forgot to change this code */
@@ -342,7 +346,7 @@ virStorageBackendDiskMakeVol(size_t ntok ATTRIBUTE_UNUSED,
  * and we can even ensure the output is friendly.
  */
 static int
-virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
+virStorageBackendDiskReadPartitions(virPoolObjPtr poolobj,
                                     virStorageVolDefPtr vol)
 {
     /*
@@ -353,10 +357,11 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
      *
      */
 
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     char *parthelper_path;
     virCommandPtr cmd;
     struct virStorageBackendDiskPoolVolData cbdata = {
-        .pool = pool,
+        .poolobj = poolobj,
         .vol = vol,
     };
     int ret;
@@ -367,7 +372,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
         return -1;
 
     cmd = virCommandNewArgList(parthelper_path,
-                               pool->def->source.devices[0].path,
+                               def->source.devices[0].path,
                                NULL);
 
     /* Check for the presence of the part_separator='yes'. Pass this
@@ -376,16 +381,15 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
      * the generated device name for a source device which ends with
      * a non-numeric value (e.g. mpatha would generate mpathap#).
      */
-    if (pool->def->source.devices[0].part_separator ==
-        VIR_TRISTATE_BOOL_YES)
+    if (def->source.devices[0].part_separator == VIR_TRISTATE_BOOL_YES)
         virCommandAddArg(cmd, "-p");
 
     /* If a volume is passed, virStorageBackendDiskMakeVol only updates the
      * pool allocation for that single volume.
      */
     if (!vol)
-        pool->def->allocation = 0;
-    pool->def->capacity = pool->def->available = 0;
+        def->allocation = 0;
+    def->capacity = def->available = 0;
 
     ret = virCommandRunNul(cmd,
                            6,
@@ -401,8 +405,10 @@ virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRIBUTE_UNUSED,
                                       char **const groups,
                                       void *data)
 {
-    virStoragePoolObjPtr pool = data;
-    virStoragePoolSourceDevicePtr device = &(pool->def->source.devices[0]);
+    virPoolObjPtr poolobj = data;
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
+    virStoragePoolSourceDevicePtr device = &(def->source.devices[0]);
     if (virStrToLong_i(groups[0], NULL, 0, &device->geometry.cylinders) < 0 ||
         virStrToLong_i(groups[1], NULL, 0, &device->geometry.heads) < 0 ||
         virStrToLong_i(groups[2], NULL, 0, &device->geometry.sectors) < 0) {
@@ -415,8 +421,9 @@ virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRIBUTE_UNUSED,
 }
 
 static int
-virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
+virStorageBackendDiskReadGeometry(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     char *parthelper_path;
     virCommandPtr cmd;
     int ret;
@@ -427,14 +434,14 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
         return -1;
 
     cmd = virCommandNewArgList(parthelper_path,
-                                             pool->def->source.devices[0].path,
-                                             "-g",
-                                             NULL);
+                               def->source.devices[0].path,
+                               "-g",
+                               NULL);
 
     ret = virCommandRunNul(cmd,
                            3,
                            virStorageBackendDiskMakePoolGeometry,
-                           pool);
+                           poolobj);
     virCommandFree(cmd);
     VIR_FREE(parthelper_path);
     return ret;
@@ -442,34 +449,37 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
 
 static int
 virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                 virStoragePoolObjPtr pool)
+                                 virPoolObjPtr poolobj)
 {
-    VIR_FREE(pool->def->source.devices[0].freeExtents);
-    pool->def->source.devices[0].nfreeExtent = 0;
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
+    VIR_FREE(def->source.devices[0].freeExtents);
+    def->source.devices[0].nfreeExtent = 0;
 
     virFileWaitForDevices();
 
-    if (!virFileExists(pool->def->source.devices[0].path)) {
+    if (!virFileExists(def->source.devices[0].path)) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("device path '%s' doesn't exist"),
-                       pool->def->source.devices[0].path);
+                       def->source.devices[0].path);
         return -1;
     }
 
-    if (virStorageBackendDiskReadGeometry(pool) != 0)
+    if (virStorageBackendDiskReadGeometry(poolobj) != 0)
         return -1;
 
-    return virStorageBackendDiskReadPartitions(pool, NULL);
+    return virStorageBackendDiskReadPartitions(poolobj, NULL);
 }
 
 
 static int
 virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                               virStoragePoolObjPtr pool)
+                               virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     const char *format =
-        virStoragePoolFormatDiskTypeToString(pool->def->source.format);
-    const char *path = pool->def->source.devices[0].path;
+        virStoragePoolFormatDiskTypeToString(def->source.format);
+    const char *path = def->source.devices[0].path;
 
     virFileWaitForDevices();
 
@@ -491,10 +501,11 @@ virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
  */
 static int
 virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                               virStoragePoolObjPtr pool,
+                               virPoolObjPtr poolobj,
                                unsigned int flags)
 {
-    int format = pool->def->source.format;
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+    int format = def->source.format;
     const char *fmt;
     bool ok_to_mklabel = false;
     int ret = -1;
@@ -511,22 +522,22 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     if (flags & VIR_STORAGE_POOL_BUILD_OVERWRITE) {
         ok_to_mklabel = true;
     } else {
-        if (virStorageBackendDeviceIsEmpty(pool->def->source.devices[0].path,
-                                              fmt, true))
+        if (virStorageBackendDeviceIsEmpty(def->source.devices[0].path,
+                                           fmt, true))
             ok_to_mklabel = true;
     }
 
     if (ok_to_mklabel) {
         /* eg parted /dev/sda mklabel --script msdos */
         if (format == VIR_STORAGE_POOL_DISK_UNKNOWN)
-            format = pool->def->source.format = VIR_STORAGE_POOL_DISK_DOS;
+            format = def->source.format = VIR_STORAGE_POOL_DISK_DOS;
         if (format == VIR_STORAGE_POOL_DISK_DOS)
             fmt = "msdos";
         else
             fmt = virStoragePoolFormatDiskTypeToString(format);
 
         cmd = virCommandNewArgList(PARTED,
-                                   pool->def->source.devices[0].path,
+                                   def->source.devices[0].path,
                                    "mklabel",
                                    "--script",
                                    fmt,
@@ -566,16 +577,19 @@ volNumOfPartTypes(virPoolObjPtr volobj,
  * Important when the partition table is of msdos type
  */
 static int
-virStorageBackendDiskPartTypeToCreate(virStoragePoolObjPtr pool)
+virStorageBackendDiskPartTypeToCreate(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     struct volPartListData data = { .count = 0 };
 
-    if (pool->def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
+    if (def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
+        virPoolObjTablePtr volumes =
+            virStoragePoolObjPrivateGetVolumes(poolobj);
 
         /* count primary and extended partitions,
          * can't be more than 3 to create a new primary partition */
-        if (virPoolObjTableList(pool->volumes, NULL, NULL,
-                                volNumOfPartTypes, &data) == 0) {
+        if (virPoolObjTableList(volumes, NULL, NULL, volNumOfPartTypes,
+                                &data) == 0) {
             if (data.count >= 4)
                 return VIR_STORAGE_VOL_DISK_TYPE_LOGICAL;
         }
@@ -586,13 +600,15 @@ virStorageBackendDiskPartTypeToCreate(virStoragePoolObjPtr pool)
 }
 
 static int
-virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool,
+virStorageBackendDiskPartFormat(virPoolObjPtr poolobj,
                                 virStorageVolDefPtr vol,
                                 char** partFormat)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+    virPoolObjTablePtr volumes = virStoragePoolObjPrivateGetVolumes(poolobj);
     virPoolObjPtr volobj;
 
-    if (pool->def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
+    if (def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
         const char *partedFormat;
         partedFormat = virStoragePartedFsTypeToString(vol->target.format);
         if (partedFormat == NULL) {
@@ -602,8 +618,8 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool,
         }
         if (vol->target.format == VIR_STORAGE_VOL_DISK_EXTENDED) {
             /* make sure we don't have an extended partition already */
-            if ((volobj == virPoolObjTableSearch(pool->volumes,
-                                                 volPartFindExtended, NULL))) {
+            if ((volobj == virPoolObjTableSearch(volumes, volPartFindExtended,
+                                                 NULL))) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("extended partition already exists"));
                 virPoolObjEndAPI(&volobj);
@@ -617,14 +633,14 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool,
                and after that check if an extended partition exists
                to create logical partitions. */
             /* XXX Only support one extended partition */
-            switch (virStorageBackendDiskPartTypeToCreate(pool)) {
+            switch (virStorageBackendDiskPartTypeToCreate(poolobj)) {
             case VIR_STORAGE_VOL_DISK_TYPE_PRIMARY:
                 if (virAsprintf(partFormat, "primary %s", partedFormat) < 0)
                     return -1;
                 break;
             case VIR_STORAGE_VOL_DISK_TYPE_LOGICAL:
                 /* make sure we have an extended partition */
-                if ((volobj == virPoolObjTableSearch(pool->volumes,
+                if ((volobj == virPoolObjTableSearch(volumes,
                                                      volPartFindExtended,
                                                      NULL))) {
                     if (virAsprintf(partFormat, "logical %s",
@@ -660,23 +676,24 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool,
  * partitions
  */
 static int
-virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
+virStorageBackendDiskPartBoundaries(virPoolObjPtr poolobj,
                                     unsigned long long *start,
                                     unsigned long long *end,
                                     unsigned long long allocation)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     size_t i;
     int smallestExtent = -1;
     unsigned long long smallestSize = 0;
     unsigned long long extraBytes = 0;
     unsigned long long alignedAllocation = allocation;
-    virStoragePoolSourceDevicePtr dev = &pool->def->source.devices[0];
+    virStoragePoolSourceDevicePtr dev = &def->source.devices[0];
     unsigned long long cylinderSize = (unsigned long long)dev->geometry.heads *
                                       dev->geometry.sectors * SECTOR_SIZE;
 
     VIR_DEBUG("find free area: allocation %llu, cyl size %llu", allocation,
           cylinderSize);
-    int partType = virStorageBackendDiskPartTypeToCreate(pool);
+    int partType = virStorageBackendDiskPartTypeToCreate(poolobj);
 
     /* how many extra bytes we have since we allocate
        aligned to the cylinder boundary */
@@ -688,7 +705,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
              dev->freeExtents[i].start;
          unsigned long long neededSize = allocation;
 
-         if (pool->def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
+         if (def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
              /* align to cylinder boundary */
              neededSize += extraBytes;
              if ((*start % cylinderSize) > extraBytes) {
@@ -736,7 +753,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
     }
 
     *end = *start + alignedAllocation;
-    if (pool->def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
+    if (def->source.format == VIR_STORAGE_POOL_DISK_DOS) {
         /* adjust our allocation if start is not at a cylinder boundary */
         *end -= (*start % cylinderSize);
     }
@@ -750,7 +767,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
 
 /* virStorageBackendDiskDeleteVol
  * @conn: Pointer to a libvirt connection
- * @pool: Pointer to the storage pool
+ * @poolobj: Pointer to the storage pool
  * @vol: Pointer to the volume definition
  * @flags: flags (unused for now)
  *
@@ -775,14 +792,15 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
  */
 static int
 virStorageBackendDiskDeleteVol(virConnectPtr conn,
-                               virStoragePoolObjPtr pool,
+                               virPoolObjPtr poolobj,
                                virStorageVolDefPtr vol,
                                unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     char *part_num = NULL;
     char *devpath = NULL;
     char *dev_name;
-    char *src_path = pool->def->source.devices[0].path;
+    char *src_path = def->source.devices[0].path;
     char *srcname = last_component(src_path);
     virCommandPtr cmd = NULL;
     bool isDevMapperDevice;
@@ -852,8 +870,8 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
      * virStorageBackendDiskMakeDataVol and trying to redo that logic
      * here is pointless
      */
-    virStoragePoolObjClearVols(pool);
-    if (virStorageBackendDiskRefreshPool(conn, pool) < 0)
+    virStoragePoolObjClearVols(poolobj);
+    if (virStorageBackendDiskRefreshPool(conn, poolobj) < 0)
         goto cleanup;
 
     rc = 0;
@@ -866,14 +884,15 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
 
 static int
 virStorageBackendDiskCreateVol(virConnectPtr conn,
-                               virStoragePoolObjPtr pool,
+                               virPoolObjPtr poolobj,
                                virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int res = -1;
     char *partFormat = NULL;
     unsigned long long startOffset = 0, endOffset = 0;
     virCommandPtr cmd = virCommandNewArgList(PARTED,
-                                             pool->def->source.devices[0].path,
+                                             def->source.devices[0].path,
                                              "mkpart",
                                              "--script",
                                              NULL);
@@ -885,11 +904,11 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
         goto cleanup;
     }
 
-    if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0)
+    if (virStorageBackendDiskPartFormat(poolobj, vol, &partFormat) != 0)
         goto cleanup;
     virCommandAddArg(cmd, partFormat);
 
-    if (virStorageBackendDiskPartBoundaries(pool, &startOffset,
+    if (virStorageBackendDiskPartBoundaries(poolobj, &startOffset,
                                             &endOffset,
                                             vol->target.capacity) != 0) {
         goto cleanup;
@@ -905,19 +924,19 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
     virFileWaitForDevices();
 
     /* Blow away free extent info, as we're about to re-populate it */
-    VIR_FREE(pool->def->source.devices[0].freeExtents);
-    pool->def->source.devices[0].nfreeExtent = 0;
+    VIR_FREE(def->source.devices[0].freeExtents);
+    def->source.devices[0].nfreeExtent = 0;
 
     /* Specifying a target path is meaningless */
     VIR_FREE(vol->target.path);
 
     /* Fetch actual extent info, generate key */
-    if (virStorageBackendDiskReadPartitions(pool, vol) < 0) {
+    if (virStorageBackendDiskReadPartitions(poolobj, vol) < 0) {
         /* Best effort to remove the partition. Ignore any errors
          * since we could be calling this with vol->target.path == NULL
          */
         virErrorPtr save_err = virSaveLastError();
-        ignore_value(virStorageBackendDiskDeleteVol(conn, pool, vol, 0));
+        ignore_value(virStorageBackendDiskDeleteVol(conn, poolobj, vol, 0));
         virSetError(save_err);
         virFreeError(save_err);
         goto cleanup;
@@ -933,7 +952,7 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
 
 static int
 virStorageBackendDiskBuildVolFrom(virConnectPtr conn,
-                                  virStoragePoolObjPtr pool,
+                                  virPoolObjPtr poolobj,
                                   virStorageVolDefPtr vol,
                                   virStorageVolDefPtr inputvol,
                                   unsigned int flags)
@@ -944,19 +963,20 @@ virStorageBackendDiskBuildVolFrom(virConnectPtr conn,
     if (!build_func)
         return -1;
 
-    return build_func(conn, pool, vol, inputvol, flags);
+    return build_func(conn, poolobj, vol, inputvol, flags);
 }
 
 
 static int
 virStorageBackendDiskVolWipe(virConnectPtr conn,
-                             virStoragePoolObjPtr pool,
+                             virPoolObjPtr poolobj,
                              virStorageVolDefPtr vol,
                              unsigned int algorithm,
                              unsigned int flags)
 {
     if (vol->source.partType != VIR_STORAGE_VOL_DISK_TYPE_EXTENDED)
-        return virStorageBackendVolWipeLocal(conn, pool, vol, algorithm, flags);
+        return virStorageBackendVolWipeLocal(conn, poolobj, vol,
+                                             algorithm, flags);
 
     /* Wiping an extended partition is not support */
     virReportError(VIR_ERR_NO_SUPPORT,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 71f605b..2a30dd9 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -38,7 +38,6 @@
 #include "virerror.h"
 #include "storage_backend_fs.h"
 #include "storage_util.h"
-#include "storage_conf.h"
 #include "virstoragefile.h"
 #include "vircommand.h"
 #include "viralloc.h"
@@ -213,34 +212,36 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
 }
 
 /**
- * @pool storage pool to check FS types
+ * @poolobj: storage pool to check FS types
  *
  * Determine if storage pool FS types are properly set up
  *
  * Return 0 if everything's OK, -1 on error
  */
 static int
-virStorageBackendFileSystemIsValid(virStoragePoolObjPtr pool)
+virStorageBackendFileSystemIsValid(virPoolObjPtr poolobj)
 {
-    if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
-        if (pool->def->source.nhost != 1) {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
+    if (def->type == VIR_STORAGE_POOL_NETFS) {
+        if (def->source.nhost != 1) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("expected exactly 1 host for the storage pool"));
             return -1;
         }
-        if (pool->def->source.hosts[0].name == NULL) {
+        if (def->source.hosts[0].name == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "%s", _("missing source host"));
             return -1;
         }
-        if (pool->def->source.dir == NULL) {
+        if (def->source.dir == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "%s", _("missing source path"));
             return -1;
         }
     } else {
-        if (pool->def->source.ndevice != 1) {
-            if (pool->def->source.ndevice == 0)
+        if (def->source.ndevice != 1) {
+            if (def->source.ndevice == 0)
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("missing source device"));
             else
@@ -256,30 +257,31 @@ virStorageBackendFileSystemIsValid(virStoragePoolObjPtr pool)
 
 /**
  * virStorageBackendFileSystemGetPoolSource
- * @pool: storage pool object pointer
+ * @poolobj: storage pool object pointer
  *
  * Allocate/return a string representing the FS storage pool source.
  * It is up to the caller to VIR_FREE the allocated string
  */
 static char *
-virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
+virStorageBackendFileSystemGetPoolSource(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     char *src = NULL;
 
-    if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
-        if (pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS) {
+    if (def->type == VIR_STORAGE_POOL_NETFS) {
+        if (def->source.format == VIR_STORAGE_POOL_NETFS_CIFS) {
             if (virAsprintf(&src, "//%s/%s",
-                            pool->def->source.hosts[0].name,
-                            pool->def->source.dir) < 0)
+                            def->source.hosts[0].name,
+                            def->source.dir) < 0)
                 return NULL;
         } else {
             if (virAsprintf(&src, "%s:%s",
-                            pool->def->source.hosts[0].name,
-                            pool->def->source.dir) < 0)
+                            def->source.hosts[0].name,
+                            def->source.dir) < 0)
                 return NULL;
         }
     } else {
-        if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0)
+        if (VIR_STRDUP(src, def->source.devices[0].path) < 0)
             return NULL;
     }
     return src;
@@ -287,15 +289,16 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
 
 
 /**
- * @pool storage pool to check for status
+ * @poolobj: storage pool to check for status
  *
  * Determine if a storage pool is already mounted
  *
  * Return 0 if not mounted, 1 if mounted, -1 on error
  */
 static int
-virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
+virStorageBackendFileSystemIsMounted(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     char *src = NULL;
     FILE *mtab;
@@ -311,14 +314,13 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
     }
 
     while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
-        if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
+        if (!(src = virStorageBackendFileSystemGetPoolSource(poolobj)))
             goto cleanup;
 
         /* compare both mount destinations and sources to be sure the mounted
          * FS pool is really the one we're looking for
          */
-        if ((rc1 = virFileComparePaths(ent.mnt_dir,
-                                       pool->def->target.path)) < 0 ||
+        if ((rc1 = virFileComparePaths(ent.mnt_dir, def->target.path)) < 0 ||
             (rc2 = virFileComparePaths(ent.mnt_fsname, src)) < 0)
             goto cleanup;
 
@@ -339,7 +341,7 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
 }
 
 /**
- * @pool storage pool to mount
+ * @poolobj: storage pool to mount
  *
  * Ensure that a FS storage pool is mounted on its target location.
  * If already mounted, this is a no-op
@@ -347,68 +349,69 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
  * Returns 0 if successfully mounted, -1 on error
  */
 static int
-virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
+virStorageBackendFileSystemMount(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     char *src = NULL;
     /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
      *  while plain 'mount' does. We have to craft separate argvs to
      *  accommodate this */
-    bool netauto = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
-                    pool->def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
-    bool glusterfs = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
-                      pool->def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
-    bool cifsfs = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
-                   pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
+    bool netauto = (def->type == VIR_STORAGE_POOL_NETFS &&
+                    def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
+    bool glusterfs = (def->type == VIR_STORAGE_POOL_NETFS &&
+                      def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
+    bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
+                   def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
     virCommandPtr cmd = NULL;
     int ret = -1;
     int rc;
 
-    if (virStorageBackendFileSystemIsValid(pool) < 0)
+    if (virStorageBackendFileSystemIsValid(poolobj) < 0)
         return -1;
 
-    if ((rc = virStorageBackendFileSystemIsMounted(pool)) < 0)
+    if ((rc = virStorageBackendFileSystemIsMounted(poolobj)) < 0)
         return -1;
 
     /* Short-circuit if already mounted */
     if (rc == 1) {
-        VIR_INFO("Target '%s' is already mounted", pool->def->target.path);
+        VIR_INFO("Target '%s' is already mounted", def->target.path);
         return 0;
     }
 
-    if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
+    if (!(src = virStorageBackendFileSystemGetPoolSource(poolobj)))
         return -1;
 
     if (netauto)
         cmd = virCommandNewArgList(MOUNT,
                                    src,
-                                   pool->def->target.path,
+                                   def->target.path,
                                    NULL);
     else if (glusterfs)
         cmd = virCommandNewArgList(MOUNT,
                                    "-t",
-                                   virStoragePoolFormatFileSystemNetTypeToString(pool->def->source.format),
+                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
                                    src,
                                    "-o",
                                    "direct-io-mode=1",
-                                   pool->def->target.path,
+                                   def->target.path,
                                    NULL);
     else if (cifsfs)
         cmd = virCommandNewArgList(MOUNT,
                                    "-t",
-                                   virStoragePoolFormatFileSystemNetTypeToString(pool->def->source.format),
+                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
                                    src,
-                                   pool->def->target.path,
+                                   def->target.path,
                                    "-o",
                                    "guest",
                                    NULL);
     else
         cmd = virCommandNewArgList(MOUNT,
                                    "-t",
-                                   (pool->def->type == VIR_STORAGE_POOL_FS ?
-                                    virStoragePoolFormatFileSystemTypeToString(pool->def->source.format) :
-                                    virStoragePoolFormatFileSystemNetTypeToString(pool->def->source.format)),
+                                   (def->type == VIR_STORAGE_POOL_FS ?
+                                    virStoragePoolFormatFileSystemTypeToString(def->source.format) :
+                                    virStoragePoolFormatFileSystemNetTypeToString(def->source.format)),
                                    src,
-                                   pool->def->target.path,
+                                   def->target.path,
                                    NULL);
 
     if (virCommandRun(cmd, NULL) < 0)
@@ -424,7 +427,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
 
 /**
  * @conn connection to report errors against
- * @pool storage pool to start
+ * @poolobj: storage pool to start
  *
  * Starts a directory or FS based storage pool.  The underlying source
  * device will be mounted for FS based pools.
@@ -433,10 +436,11 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
  */
 static int
 virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                 virStoragePoolObjPtr pool)
+                                 virPoolObjPtr poolobj)
 {
-    if (pool->def->type != VIR_STORAGE_POOL_DIR &&
-        virStorageBackendFileSystemMount(pool) < 0)
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+    if (def->type != VIR_STORAGE_POOL_DIR &&
+        virStorageBackendFileSystemMount(poolobj) < 0)
         return -1;
 
     return 0;
@@ -445,7 +449,7 @@ virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 /**
  * @conn connection to report errors against
- * @pool storage pool to unmount
+ * @poolobj: storage pool to unmount
  *
  * Stops a file storage pool.  The underlying source device is unmounted
  * for FS based pools.  Any cached data about volumes is released.
@@ -457,20 +461,21 @@ virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
  */
 static int
 virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                virStoragePoolObjPtr pool)
+                                virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     int ret = -1;
     int rc;
 
-    if (virStorageBackendFileSystemIsValid(pool) < 0)
+    if (virStorageBackendFileSystemIsValid(poolobj) < 0)
         return -1;
 
     /* Short-circuit if already unmounted */
-    if ((rc = virStorageBackendFileSystemIsMounted(pool)) != 1)
+    if ((rc = virStorageBackendFileSystemIsMounted(poolobj)) != 1)
         return rc;
 
-    cmd = virCommandNewArgList(UMOUNT, pool->def->target.path, NULL);
+    cmd = virCommandNewArgList(UMOUNT, def->target.path, NULL);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
@@ -483,20 +488,22 @@ virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 
 static int
-virStorageBackendFileSystemCheck(virStoragePoolObjPtr pool,
+virStorageBackendFileSystemCheck(virPoolObjPtr poolobj,
                                  bool *isActive)
 {
-    if (pool->def->type == VIR_STORAGE_POOL_DIR) {
-        *isActive = virFileExists(pool->def->target.path);
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
+    if (def->type == VIR_STORAGE_POOL_DIR) {
+        *isActive = virFileExists(def->target.path);
 #if WITH_STORAGE_FS
     } else {
         int ret;
         *isActive = false;
 
-        if (virStorageBackendFileSystemIsValid(pool) < 0)
+        if (virStorageBackendFileSystemIsValid(poolobj) < 0)
             return -1;
 
-        if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 0) {
+        if ((ret = virStorageBackendFileSystemIsMounted(poolobj)) != 0) {
             if (ret < 0)
                 return -1;
             *isActive = true;
@@ -507,6 +514,7 @@ virStorageBackendFileSystemCheck(virStoragePoolObjPtr pool,
     return 0;
 }
 
+
 /* some platforms don't support mkfs */
 #ifdef MKFS
 static int
@@ -558,28 +566,29 @@ virStorageBackendExecuteMKFS(const char *device ATTRIBUTE_UNUSED,
 #endif /* #ifdef MKFS */
 
 static int
-virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
+virStorageBackendMakeFileSystem(virPoolObjPtr poolobj,
                                 unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     const char *device = NULL, *format = NULL;
     bool ok_to_mkfs = false;
     int ret = -1;
 
-    if (pool->def->source.devices == NULL) {
+    if (def->source.devices == NULL) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("No source device specified when formatting pool '%s'"),
-                       pool->def->name);
+                       def->name);
         goto error;
     }
 
-    device = pool->def->source.devices[0].path;
-    format = virStoragePoolFormatFileSystemTypeToString(pool->def->source.format);
+    device = def->source.devices[0].path;
+    format = virStoragePoolFormatFileSystemTypeToString(def->source.format);
     VIR_DEBUG("source device: '%s' format: '%s'", device, format);
 
     if (!virFileExists(device)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("Source device does not exist when formatting pool '%s'"),
-                       pool->def->name);
+                       def->name);
         goto error;
     }
 
@@ -600,7 +609,7 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
 
 /**
  * @conn connection to report errors against
- * @pool storage pool to build
+ * @poolobj: storage pool to build
  * @flags controls the pool formatting behaviour
  *
  * Build a directory or FS based storage pool.
@@ -621,7 +630,7 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
  */
 static int
 virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                 virStoragePoolObjPtr pool,
+                                 virPoolObjPtr poolobj,
                                  unsigned int flags)
 {
     virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
@@ -631,11 +640,11 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
                             VIR_STORAGE_POOL_BUILD_NO_OVERWRITE,
                             -1);
 
-    if (virStorageBackendBuildLocal(pool) < 0)
+    if (virStorageBackendBuildLocal(poolobj) < 0)
         return -1;
 
     if (flags != 0)
-        return virStorageBackendMakeFileSystem(pool, flags);
+        return virStorageBackendMakeFileSystem(poolobj, flags);
 
     return 0;
 }
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index aa9d7be..c797e29 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -24,7 +24,6 @@
 #include <glusterfs/api/glfs.h>
 
 #include "storage_backend_gluster.h"
-#include "storage_conf.h"
 #include "viralloc.h"
 #include "virerror.h"
 #include "virlog.h"
@@ -71,11 +70,12 @@ virStorageBackendGlusterClose(virStorageBackendGlusterStatePtr state)
 }
 
 static virStorageBackendGlusterStatePtr
-virStorageBackendGlusterOpen(virStoragePoolObjPtr pool)
+virStorageBackendGlusterOpen(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virStorageBackendGlusterStatePtr ret = NULL;
-    const char *name = pool->def->source.name;
-    const char *dir = pool->def->source.dir;
+    const char *name = def->source.name;
+    const char *dir = def->source.dir;
     bool trailing_slash = true;
 
     /* Volume name must not contain '/'; optional path allows use of a
@@ -112,11 +112,11 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool)
         goto error;
     if (VIR_STRDUP(ret->uri->scheme, "gluster") < 0)
         goto error;
-    if (VIR_STRDUP(ret->uri->server, pool->def->source.hosts[0].name) < 0)
+    if (VIR_STRDUP(ret->uri->server, def->source.hosts[0].name) < 0)
         goto error;
     if (virAsprintf(&ret->uri->path, "/%s%s", ret->volname, ret->dir) < 0)
         goto error;
-    ret->uri->port = pool->def->source.hosts[0].port;
+    ret->uri->port = def->source.hosts[0].port;
 
     /* Actually connect to glfs */
     if (!(ret->vol = glfs_new(ret->volname))) {
@@ -339,8 +339,9 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
 
 static int
 virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                    virStoragePoolObjPtr pool)
+                                    virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     virStorageBackendGlusterStatePtr state = NULL;
     struct {
@@ -354,7 +355,7 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     struct stat st;
     struct statvfs sb;
 
-    if (!(state = virStorageBackendGlusterOpen(pool)))
+    if (!(state = virStorageBackendGlusterOpen(poolobj)))
         goto cleanup;
 
     /* Why oh why did glfs 3.4 decide to expose only readdir_r rather
@@ -388,7 +389,7 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
         if (!vol)
             continue;
 
-        if (!(volobj = virStoragePoolObjAddVolume(pool, vol))) {
+        if (!(volobj = virStoragePoolObjAddVolume(poolobj, vol))) {
             virStorageVolDefFree(vol);
             goto cleanup;
         }
@@ -406,11 +407,11 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool->def->capacity = ((unsigned long long)sb.f_frsize *
-                           (unsigned long long)sb.f_blocks);
-    pool->def->available = ((unsigned long long)sb.f_bfree *
-                            (unsigned long long)sb.f_frsize);
-    pool->def->allocation = pool->def->capacity - pool->def->available;
+    def->capacity = ((unsigned long long)sb.f_frsize *
+                     (unsigned long long)sb.f_blocks);
+    def->available = ((unsigned long long)sb.f_bfree *
+                      (unsigned long long)sb.f_frsize);
+    def->allocation = def->capacity - def->available;
 
     ret = 0;
  cleanup:
@@ -418,14 +419,14 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
         glfs_closedir(dir);
     virStorageBackendGlusterClose(state);
     if (ret < 0)
-        virStoragePoolObjClearVols(pool);
+        virStoragePoolObjClearVols(poolobj);
     return ret;
 }
 
 
 static int
 virStorageBackendGlusterVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool,
+                                  virPoolObjPtr poolobj,
                                   virStorageVolDefPtr vol,
                                   unsigned int flags)
 {
@@ -449,7 +450,7 @@ virStorageBackendGlusterVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
         break;
 
     case VIR_STORAGE_VOL_NETWORK:
-        if (!(state = virStorageBackendGlusterOpen(pool)))
+        if (!(state = virStorageBackendGlusterOpen(poolobj)))
             goto cleanup;
 
         if (glfs_unlink(state->vol, vol->name) < 0) {
@@ -463,7 +464,7 @@ virStorageBackendGlusterVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
         break;
 
     case VIR_STORAGE_VOL_NETDIR:
-        if (!(state = virStorageBackendGlusterOpen(pool)))
+        if (!(state = virStorageBackendGlusterOpen(poolobj)))
             goto cleanup;
 
         if (glfs_rmdir(state->vol, vol->target.path) < 0) {
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 2813341..32a509f 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -80,10 +80,11 @@ virStorageBackendISCSIPortal(virStoragePoolSourcePtr source)
 
 
 static char *
-virStorageBackendISCSISession(virStoragePoolObjPtr pool,
+virStorageBackendISCSISession(virPoolObjPtr obj,
                               bool probe)
 {
-    return virISCSIGetSession(pool->def->source.devices[0].path, probe);
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    return virISCSIGetSession(def->source.devices[0].path, probe);
 }
 
 
@@ -129,7 +130,7 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
 }
 
 static int
-virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
+virStorageBackendISCSIFindLUs(virPoolObjPtr obj,
                               const char *session)
 {
     char *sysfs_path;
@@ -143,7 +144,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
     if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0)
         goto cleanup;
 
-    if (virStorageBackendSCSIFindLUs(pool, host) < 0)
+    if (virStorageBackendSCSIFindLUs(obj, host) < 0)
         goto cleanup;
 
     retval = 0;
@@ -232,34 +233,35 @@ virStorageBackendISCSIFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
 }
 
 static int
-virStorageBackendISCSICheckPool(virStoragePoolObjPtr pool,
+virStorageBackendISCSICheckPool(virPoolObjPtr obj,
                                 bool *isActive)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     char *session = NULL;
     int ret = -1;
 
     *isActive = false;
 
-    if (pool->def->source.nhost != 1) {
+    if (def->source.nhost != 1) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Expected exactly 1 host for the storage pool"));
         return -1;
     }
 
-    if (pool->def->source.hosts[0].name == NULL) {
+    if (def->source.hosts[0].name == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("missing source host"));
         return -1;
     }
 
-    if (pool->def->source.ndevice != 1 ||
-        pool->def->source.devices[0].path == NULL) {
+    if (def->source.ndevice != 1 ||
+        def->source.devices[0].path == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("missing source device"));
         return -1;
     }
 
-    if ((session = virStorageBackendISCSISession(pool, true)) != NULL) {
+    if ((session = virStorageBackendISCSISession(obj, true)) != NULL) {
         *isActive = true;
         VIR_FREE(session);
     }
@@ -325,46 +327,47 @@ virStorageBackendISCSISetAuth(const char *portal,
 
 static int
 virStorageBackendISCSIStartPool(virConnectPtr conn,
-                                virStoragePoolObjPtr pool)
+                                virPoolObjPtr obj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     char *portal = NULL;
     char *session = NULL;
     int ret = -1;
 
-    if (pool->def->source.nhost != 1) {
+    if (def->source.nhost != 1) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Expected exactly 1 host for the storage pool"));
         return -1;
     }
 
-    if (pool->def->source.hosts[0].name == NULL) {
+    if (def->source.hosts[0].name == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("missing source host"));
         return -1;
     }
 
-    if (pool->def->source.ndevice != 1 ||
-        pool->def->source.devices[0].path == NULL) {
+    if (def->source.ndevice != 1 ||
+        def->source.devices[0].path == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("missing source device"));
         return -1;
     }
 
-    if ((session = virStorageBackendISCSISession(pool, true)) == NULL) {
-        if ((portal = virStorageBackendISCSIPortal(&pool->def->source)) == NULL)
+    if ((session = virStorageBackendISCSISession(obj, true)) == NULL) {
+        if ((portal = virStorageBackendISCSIPortal(&def->source)) == NULL)
             goto cleanup;
 
         /* Create a static node record for the IQN target. Must be done
          * in order for login to the target */
-        if (virISCSINodeNew(portal, pool->def->source.devices[0].path) < 0)
+        if (virISCSINodeNew(portal, def->source.devices[0].path) < 0)
             goto cleanup;
 
-        if (virStorageBackendISCSISetAuth(portal, conn, &pool->def->source) < 0)
+        if (virStorageBackendISCSISetAuth(portal, conn, &def->source) < 0)
             goto cleanup;
 
         if (virISCSIConnectionLogin(portal,
-                                    pool->def->source.initiator.iqn,
-                                    pool->def->source.devices[0].path) < 0)
+                                    def->source.initiator.iqn,
+                                    def->source.devices[0].path) < 0)
             goto cleanup;
     }
     ret = 0;
@@ -377,17 +380,18 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
 
 static int
 virStorageBackendISCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool)
+                                  virPoolObjPtr obj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     char *session = NULL;
 
-    pool->def->allocation = pool->def->capacity = pool->def->available = 0;
+    def->allocation = def->capacity = def->available = 0;
 
-    if ((session = virStorageBackendISCSISession(pool, false)) == NULL)
+    if ((session = virStorageBackendISCSISession(obj, false)) == NULL)
         goto cleanup;
     if (virISCSIRescanLUNs(session) < 0)
         goto cleanup;
-    if (virStorageBackendISCSIFindLUs(pool, session) < 0)
+    if (virStorageBackendISCSIFindLUs(obj, session) < 0)
         goto cleanup;
     VIR_FREE(session);
 
@@ -401,22 +405,23 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendISCSIStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                               virStoragePoolObjPtr pool)
+                               virPoolObjPtr obj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     char *portal;
     char *session;
     int ret = -1;
 
-    if ((session = virStorageBackendISCSISession(pool, true)) == NULL)
+    if ((session = virStorageBackendISCSISession(obj, true)) == NULL)
         return 0;
     VIR_FREE(session);
 
-    if ((portal = virStorageBackendISCSIPortal(&pool->def->source)) == NULL)
+    if ((portal = virStorageBackendISCSIPortal(&def->source)) == NULL)
         return -1;
 
     if (virISCSIConnectionLogout(portal,
-                                 pool->def->source.initiator.iqn,
-                                 pool->def->source.devices[0].path) < 0)
+                                 def->source.initiator.iqn,
+                                 def->source.devices[0].path) < 0)
         goto cleanup;
     ret = 0;
 
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index ad66656..4e95d01 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -33,7 +33,6 @@
 
 #include "virerror.h"
 #include "storage_backend_logical.h"
-#include "storage_conf.h"
 #include "vircommand.h"
 #include "viralloc.h"
 #include "virlog.h"
@@ -49,14 +48,15 @@ VIR_LOG_INIT("storage.storage_backend_logical");
 
 
 static int
-virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool,
+virStorageBackendLogicalSetActive(virPoolObjPtr poolobj,
                                   int on)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret;
     virCommandPtr cmd =
         virCommandNewArgList(VGCHANGE,
                              on ? "-aly" : "-aln",
-                             pool->def->source.name,
+                             def->source.name,
                              NULL);
 
     ret = virCommandRun(cmd, NULL);
@@ -147,7 +147,7 @@ virStorageBackendLogicalInitializeDevice(const char *path)
 #define VIR_STORAGE_VOL_LOGICAL_SEGTYPE_RAID    "raid"
 
 struct virStorageBackendLogicalPoolVolData {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr poolobj;
     virStorageVolDefPtr vol;
 };
 
@@ -287,7 +287,8 @@ virStorageBackendLogicalMakeVol(char **const groups,
                                 void *opaque)
 {
     struct virStorageBackendLogicalPoolVolData *data = opaque;
-    virStoragePoolObjPtr pool = data->pool;
+    virPoolObjPtr poolobj = data->poolobj;
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(poolobj);
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef = data->vol;
     bool is_new_vol = false;
@@ -312,7 +313,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
 
     /* Or filling in more data on an existing volume */
     if (!voldef) {
-        if ((volobj = virStorageVolObjFindByName(pool, groups[0])))
+        if ((volobj = virStorageVolObjFindByName(poolobj, groups[0])))
             voldef = virPoolObjGetDef(volobj);
     }
 
@@ -330,7 +331,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
 
     if (!voldef->target.path) {
         if (virAsprintf(&voldef->target.path, "%s/%s",
-                        pool->def->target.path, voldef->name) < 0)
+                        pooldef->target.path, voldef->name) < 0)
             goto cleanup;
     }
 
@@ -355,7 +356,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
             goto cleanup;
 
         if (virAsprintf(&voldef->target.backingStore->path, "%s/%s",
-                        pool->def->target.path, groups[1]) < 0)
+                        pooldef->target.path, groups[1]) < 0)
             goto cleanup;
 
         voldef->target.backingStore->format = VIR_STORAGE_POOL_LOGICAL_LVM2;
@@ -378,10 +379,9 @@ virStorageBackendLogicalMakeVol(char **const groups,
         goto cleanup;
 
     if (is_new_vol) {
-        if (!(volobj = virStoragePoolObjAddVolume(pool, voldef)))
+        if (!(volobj = virStoragePoolObjAddVolume(poolobj, voldef)))
             goto cleanup;
         voldef = NULL;
-        virPoolObjEndAPI(&volobj);
     }
 
     ret = 0;
@@ -389,6 +389,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
  cleanup:
     if (is_new_vol)
         virStorageVolDefFree(voldef);
+    virPoolObjEndAPI(&volobj);
     return ret;
 }
 
@@ -421,7 +422,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
            VIR_STORAGE_VOL_LOGICAL_SUFFIX_REGEX
 
 static int
-virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
+virStorageBackendLogicalFindLVs(virPoolObjPtr poolobj,
                                 virStorageVolDefPtr vol)
 {
     /*
@@ -457,8 +458,9 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
     };
     int ret = -1;
     virCommandPtr cmd;
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     struct virStorageBackendLogicalPoolVolData cbdata = {
-        .pool = pool,
+        .poolobj = poolobj,
         .vol = vol,
     };
 
@@ -470,7 +472,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
                                "--nosuffix",
                                "--options",
                                "lv_name,origin,uuid,devices,segtype,stripes,seg_size,vg_extent_size,size,lv_attr",
-                               pool->def->source.name,
+                               def->source.name,
                                NULL);
     if (virCommandRunRegex(cmd,
                            1,
@@ -492,12 +494,14 @@ static int
 virStorageBackendLogicalRefreshPoolFunc(char **const groups,
                                         void *data)
 {
-    virStoragePoolObjPtr pool = data;
-    if (virStrToLong_ull(groups[0], NULL, 10, &pool->def->capacity) < 0)
+    virPoolObjPtr poolobj = data;
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
+    if (virStrToLong_ull(groups[0], NULL, 10, &def->capacity) < 0)
         return -1;
-    if (virStrToLong_ull(groups[1], NULL, 10, &pool->def->available) < 0)
+    if (virStrToLong_ull(groups[1], NULL, 10, &def->available) < 0)
         return -1;
-    pool->def->allocation = pool->def->capacity - pool->def->available;
+    def->allocation = def->capacity - def->available;
 
     return 0;
 }
@@ -640,7 +644,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 /*
  * virStorageBackendLogicalMatchPoolSource
- * @pool: Pointer to the source pool object
+ * @poolobj: Pointer to the source pool object
  *
  * Search the output generated by a 'pvs --noheadings -o pv_name,vg_name'
  * to match the 'vg_name' with the pool def->source.name and for the list
@@ -653,8 +657,9 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
  * the any device list members.
  */
 static bool
-virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
+virStorageBackendLogicalMatchPoolSource(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virStoragePoolSourceList sourceList;
     virStoragePoolSource *thisSource = NULL;
     size_t i, j;
@@ -670,14 +675,14 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
     /* Search the pvs output for this pool's source.name */
     for (i = 0; i < sourceList.nsources; i++) {
         thisSource = &sourceList.sources[i];
-        if (STREQ(thisSource->name, pool->def->source.name))
+        if (STREQ(thisSource->name, def->source.name))
             break;
     }
 
     if (i == sourceList.nsources) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("cannot find logical volume group name '%s'"),
-                       pool->def->source.name);
+                       def->source.name);
         goto cleanup;
     }
 
@@ -685,7 +690,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
      * they match as well; otherwise, matching can only occur on the
      * pool's name.
      */
-    if (!pool->def->source.ndevice) {
+    if (!def->source.ndevice) {
         ret = true;
         goto cleanup;
     }
@@ -693,9 +698,9 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
     /* Let's make sure the pool's device(s) match what the pvs output has
      * for volume group devices.
      */
-    for (i = 0; i < pool->def->source.ndevice; i++) {
+    for (i = 0; i < def->source.ndevice; i++) {
         for (j = 0; j < thisSource->ndevice; j++) {
-            if (STREQ(pool->def->source.devices[i].path,
+            if (STREQ(def->source.devices[i].path,
                       thisSource->devices[j].path))
                 matchcount++;
         }
@@ -707,7 +712,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
     if (matchcount == 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("cannot find any matching source devices for logical "
-                         "volume group '%s'"), pool->def->source.name);
+                         "volume group '%s'"), def->source.name);
         goto cleanup;
     }
 
@@ -716,7 +721,7 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
      * to 'add' to or 'remove' from the volume group outside of libvirt's
      * knowledge. Rather than fail on that, provide a warning and move on.
      */
-    if (matchcount != pool->def->source.ndevice)
+    if (matchcount != def->source.ndevice)
         VIR_WARN("pool device list count doesn't match pvs device list count");
 
     ret = true;
@@ -731,26 +736,27 @@ virStorageBackendLogicalMatchPoolSource(virStoragePoolObjPtr pool)
 
 
 static int
-virStorageBackendLogicalCheckPool(virStoragePoolObjPtr pool,
+virStorageBackendLogicalCheckPool(virPoolObjPtr poolobj,
                                   bool *isActive)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     /* If we can find the target.path as well as ensure that the
      * pool's def source
      */
-    *isActive = virFileExists(pool->def->target.path) &&
-                virStorageBackendLogicalMatchPoolSource(pool);
+    *isActive = virFileExists(def->target.path) &&
+                virStorageBackendLogicalMatchPoolSource(poolobj);
     return 0;
 }
 
 static int
 virStorageBackendLogicalStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool)
+                                  virPoolObjPtr poolobj)
 {
     /* Let's make sure that the pool's name matches the pvs output and
      * that the pool's source devices match the pvs output.
      */
-    if (!virStorageBackendLogicalMatchPoolSource(pool) ||
-        virStorageBackendLogicalSetActive(pool, 1) < 0)
+    if (!virStorageBackendLogicalMatchPoolSource(poolobj) ||
+        virStorageBackendLogicalSetActive(poolobj, 1) < 0)
         return -1;
 
     return 0;
@@ -759,9 +765,10 @@ virStorageBackendLogicalStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool,
+                                  virPoolObjPtr poolobj,
                                   unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr vgcmd = NULL;
     int ret = -1;
     size_t i = 0;
@@ -773,10 +780,10 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
                              VIR_STORAGE_POOL_BUILD_NO_OVERWRITE,
                              cleanup);
 
-    vgcmd = virCommandNewArgList(VGCREATE, pool->def->source.name, NULL);
+    vgcmd = virCommandNewArgList(VGCREATE, def->source.name, NULL);
 
-    for (i = 0; i < pool->def->source.ndevice; i++) {
-        const char *path = pool->def->source.devices[i].path;
+    for (i = 0; i < def->source.ndevice; i++) {
+        const char *path = def->source.devices[i].path;
 
         /* The blkid FS and Part probing code doesn't know "lvm2" (this
          * pool's only format type), but it does know "LVM2_member", so
@@ -806,7 +813,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     if (ret < 0) {
         size_t j;
         for (j = 0; j < i; j++)
-            virStorageBackendLogicalRemoveDevice(pool->def->source.devices[j].path);
+            virStorageBackendLogicalRemoveDevice(def->source.devices[j].path);
     }
     return ret;
 }
@@ -814,7 +821,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                    virStoragePoolObjPtr pool)
+                                    virPoolObjPtr poolobj)
 {
     /*
      *  # vgs --separator : --noheadings --units b --unbuffered --nosuffix --options "vg_size,vg_free" VGNAME
@@ -830,13 +837,14 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     int vars[] = {
         2
     };
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     int ret = -1;
 
     virFileWaitForDevices();
 
     /* Get list of all logical volumes */
-    if (virStorageBackendLogicalFindLVs(pool, NULL) < 0)
+    if (virStorageBackendLogicalFindLVs(poolobj, NULL) < 0)
         goto cleanup;
 
     cmd = virCommandNewArgList(VGS,
@@ -846,7 +854,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
                                "--unbuffered",
                                "--nosuffix",
                                "--options", "vg_size,vg_free",
-                               pool->def->source.name,
+                               def->source.name,
                                NULL);
 
     /* Now get basic volgrp metadata */
@@ -855,7 +863,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
                            regexes,
                            vars,
                            virStorageBackendLogicalRefreshPoolFunc,
-                           pool,
+                           poolobj,
                            "vgs",
                            NULL) < 0)
         goto cleanup;
@@ -865,7 +873,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
  cleanup:
     virCommandFree(cmd);
     if (ret < 0)
-        virStoragePoolObjClearVols(pool);
+        virStoragePoolObjClearVols(poolobj);
     return ret;
 }
 
@@ -876,9 +884,9 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
  */
 static int
 virStorageBackendLogicalStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                 virStoragePoolObjPtr pool)
+                                 virPoolObjPtr poolobj)
 {
-    if (virStorageBackendLogicalSetActive(pool, 0) < 0)
+    if (virStorageBackendLogicalSetActive(poolobj, 0) < 0)
         return -1;
 
     return 0;
@@ -886,9 +894,10 @@ virStorageBackendLogicalStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                   virStoragePoolObjPtr pool,
+                                   virPoolObjPtr poolobj,
                                    unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     size_t i;
     int ret = -1;
@@ -897,14 +906,14 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     /* first remove the volume group */
     cmd = virCommandNewArgList(VGREMOVE,
-                               "-f", pool->def->source.name,
+                               "-f", def->source.name,
                                NULL);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
     /* now remove the pv devices and clear them out */
-    for (i = 0; i < pool->def->source.ndevice; i++)
-        virStorageBackendLogicalRemoveDevice(pool->def->source.devices[i].path);
+    for (i = 0; i < def->source.ndevice; i++)
+        virStorageBackendLogicalRemoveDevice(def->source.devices[i].path);
 
     ret = 0;
 
@@ -916,7 +925,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                                  virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                                   virStorageVolDefPtr vol,
                                   unsigned int flags)
 {
@@ -951,9 +960,10 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendLogicalCreateVol(virConnectPtr conn,
-                                  virStoragePoolObjPtr pool,
+                                  virPoolObjPtr poolobj,
                                   virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int fd = -1;
     virCommandPtr cmd = NULL;
     virErrorPtr err;
@@ -971,7 +981,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
 
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
-                    pool->def->target.path,
+                    def->target.path,
                     vol->name) == -1)
         return -1;
 
@@ -992,7 +1002,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
     if (vol->target.backingStore)
         virCommandAddArgList(cmd, "-s", vol->target.backingStore->path, NULL);
     else
-        virCommandAddArg(cmd, pool->def->source.name);
+        virCommandAddArg(cmd, def->source.name);
 
     if (virCommandRun(cmd, NULL) < 0)
         goto error;
@@ -1031,7 +1041,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
     }
 
     /* Fill in data about this new vol */
-    if (virStorageBackendLogicalFindLVs(pool, vol) < 0) {
+    if (virStorageBackendLogicalFindLVs(poolobj, vol) < 0) {
         virReportSystemError(errno,
                              _("cannot find newly created volume '%s'"),
                              vol->target.path);
@@ -1044,7 +1054,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
     err = virSaveLastError();
     VIR_FORCE_CLOSE(fd);
     if (created)
-        virStorageBackendLogicalDeleteVol(conn, pool, vol, 0);
+        virStorageBackendLogicalDeleteVol(conn, poolobj, vol, 0);
     virCommandFree(cmd);
     virSetError(err);
     virFreeError(err);
@@ -1053,7 +1063,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
 
 static int
 virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
-                                     virStoragePoolObjPtr pool,
+                                     virPoolObjPtr poolobj,
                                      virStorageVolDefPtr vol,
                                      virStorageVolDefPtr inputvol,
                                      unsigned int flags)
@@ -1064,18 +1074,19 @@ virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
     if (!build_func)
         return -1;
 
-    return build_func(conn, pool, vol, inputvol, flags);
+    return build_func(conn, poolobj, vol, inputvol, flags);
 }
 
 static int
 virStorageBackendLogicalVolWipe(virConnectPtr conn,
-                                virStoragePoolObjPtr pool,
+                                virPoolObjPtr poolobj,
                                 virStorageVolDefPtr vol,
                                 unsigned int algorithm,
                                 unsigned int flags)
 {
     if (!vol->target.sparse)
-        return virStorageBackendVolWipeLocal(conn, pool, vol, algorithm, flags);
+        return virStorageBackendVolWipeLocal(conn, poolobj, vol,
+                                             algorithm, flags);
 
     /* The wiping algorithms will write something to the logical volume.
      * Writing to a sparse logical volume causes it to be filled resulting
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index 514b59b..eaa16e9 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -30,7 +30,6 @@
 #include <libdevmapper.h>
 
 #include "virerror.h"
-#include "storage_conf.h"
 #include "storage_backend.h"
 #include "viralloc.h"
 #include "virlog.h"
@@ -43,10 +42,11 @@
 VIR_LOG_INIT("storage.storage_backend_mpath");
 
 static int
-virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
+virStorageBackendMpathNewVol(virPoolObjPtr poolobj,
                              const int devnum,
                              const char *dev)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virStorageVolDefPtr vol;
     virPoolObjPtr volobj;
     int ret = -1;
@@ -71,14 +71,14 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
     if (VIR_STRDUP(vol->key, vol->target.path) < 0)
         goto cleanup;
 
-    if (!(volobj = virStoragePoolObjAddVolume(pool, vol)))
+    if (!(volobj = virStoragePoolObjAddVolume(poolobj, vol)))
         goto cleanup;
 
     vol = NULL;
     virPoolObjEndAPI(&volobj);
 
-    pool->def->capacity += vol->target.capacity;
-    pool->def->allocation += vol->target.allocation;
+    def->capacity += vol->target.capacity;
+    def->allocation += vol->target.allocation;
     ret = 0;
 
  cleanup:
@@ -160,7 +160,7 @@ virStorageBackendGetMinorNumber(const char *dev_name, uint32_t *minor)
 
 
 static int
-virStorageBackendCreateVols(virStoragePoolObjPtr pool,
+virStorageBackendCreateVols(virPoolObjPtr poolobj,
                             struct dm_names *names)
 {
     int retval = -1, is_mpath = 0;
@@ -186,7 +186,7 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool,
                 goto out;
             }
 
-            if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0)
+            if (virStorageBackendMpathNewVol(poolobj, minor, map_device) < 0)
                 goto out;
 
             VIR_FREE(map_device);
@@ -208,7 +208,7 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool,
 
 
 static int
-virStorageBackendGetMaps(virStoragePoolObjPtr pool)
+virStorageBackendGetMaps(virPoolObjPtr poolobj)
 {
     int retval = 0;
     struct dm_task *dmt = NULL;
@@ -236,7 +236,7 @@ virStorageBackendGetMaps(virStoragePoolObjPtr pool)
         goto out;
     }
 
-    virStorageBackendCreateVols(pool, names);
+    virStorageBackendCreateVols(poolobj, names);
 
  out:
     if (dmt != NULL)
@@ -245,7 +245,7 @@ virStorageBackendGetMaps(virStoragePoolObjPtr pool)
 }
 
 static int
-virStorageBackendMpathCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendMpathCheckPool(virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                                 bool *isActive)
 {
     *isActive = virFileExists("/dev/mapper") ||
@@ -257,17 +257,18 @@ virStorageBackendMpathCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendMpathRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool)
+                                  virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int retval = 0;
 
-    VIR_DEBUG("conn=%p, pool=%p", conn, pool);
+    VIR_DEBUG("conn=%p, obj=%p", conn, poolobj);
 
-    pool->def->allocation = pool->def->capacity = pool->def->available = 0;
+    def->allocation = def->capacity = def->available = 0;
 
     virFileWaitForDevices();
 
-    virStorageBackendGetMaps(pool);
+    virStorageBackendGetMaps(poolobj);
 
     return retval;
 }
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 5a46664..b3fec95 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -27,7 +27,6 @@
 #include "datatypes.h"
 #include "virerror.h"
 #include "storage_backend_rbd.h"
-#include "storage_conf.h"
 #include "viralloc.h"
 #include "virlog.h"
 #include "base64.h"
@@ -208,12 +207,15 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
 
 static int
 virStorageBackendRBDOpenIoCTX(virStorageBackendRBDStatePtr ptr,
-                              virStoragePoolObjPtr pool)
+                              virPoolObjPtr poolobj)
 {
-    int r = rados_ioctx_create(ptr->cluster, pool->def->source.name, &ptr->ioctx);
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
+    int r = rados_ioctx_create(ptr->cluster, def->source.name, &ptr->ioctx);
     if (r < 0) {
-        virReportSystemError(-r, _("failed to create the RBD IoCTX. Does the pool '%s' exist?"),
-                             pool->def->source.name);
+        virReportSystemError(-r, _("failed to create the RBD IoCTX. "
+                                   "Does the pool '%s' exist?"),
+                             def->source.name);
     }
     return r;
 }
@@ -252,17 +254,18 @@ virStorageBackendRBDFreeState(virStorageBackendRBDStatePtr *ptr)
 
 static virStorageBackendRBDStatePtr
 virStorageBackendRBDNewState(virConnectPtr conn,
-                             virStoragePoolObjPtr pool)
+                             virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virStorageBackendRBDStatePtr ptr;
 
     if (VIR_ALLOC(ptr) < 0)
         return NULL;
 
-    if (virStorageBackendRBDOpenRADOSConn(ptr, conn, &pool->def->source) < 0)
+    if (virStorageBackendRBDOpenRADOSConn(ptr, conn, &def->source) < 0)
         goto error;
 
-    if (virStorageBackendRBDOpenIoCTX(ptr, pool) < 0)
+    if (virStorageBackendRBDOpenIoCTX(ptr, poolobj) < 0)
         goto error;
 
     return ptr;
@@ -355,9 +358,10 @@ virStorageBackendRBDSetAllocation(virStorageVolDefPtr vol ATTRIBUTE_UNUSED,
 
 static int
 volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
-                                   virStoragePoolObjPtr pool,
+                                   virPoolObjPtr poolobj,
                                    virStorageBackendRBDStatePtr ptr)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     int r = 0;
     rbd_image_t image = NULL;
@@ -388,7 +392,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
     if (volStorageBackendRBDUseFastDiff(features)) {
         VIR_DEBUG("RBD image %s/%s has fast-diff feature enabled. "
                   "Querying for actual allocation",
-                  pool->def->source.name, vol->name);
+                  def->source.name, vol->name);
 
         if (virStorageBackendRBDSetAllocation(vol, image, &info) < 0)
             goto cleanup;
@@ -398,18 +402,18 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
 
     VIR_DEBUG("Refreshed RBD image %s/%s (capacity: %llu allocation: %llu "
                       "obj_size: %"PRIu64" num_objs: %"PRIu64")",
-              pool->def->source.name, vol->name, vol->target.capacity,
+              def->source.name, vol->name, vol->target.capacity,
               vol->target.allocation, info.obj_size, info.num_objs);
 
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
-                    pool->def->source.name,
+                    def->source.name,
                     vol->name) == -1)
         goto cleanup;
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
-                    pool->def->source.name,
+                    def->source.name,
                     vol->name) == -1)
         goto cleanup;
 
@@ -423,8 +427,9 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
 
 static int
 virStorageBackendRBDRefreshPool(virConnectPtr conn,
-                                virStoragePoolObjPtr pool)
+                                virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     size_t max_size = 1024;
     int ret = -1;
     int len = -1;
@@ -435,7 +440,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn,
     struct rados_cluster_stat_t clusterstat;
     struct rados_pool_stat_t poolstat;
 
-    if (!(ptr = virStorageBackendRBDNewState(conn, pool)))
+    if (!(ptr = virStorageBackendRBDNewState(conn, poolobj)))
         goto cleanup;
 
     if ((r = rados_cluster_stat(ptr->cluster, &clusterstat)) < 0) {
@@ -445,17 +450,17 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn,
 
     if ((r = rados_ioctx_pool_stat(ptr->ioctx, &poolstat)) < 0) {
         virReportSystemError(-r, _("failed to stat the RADOS pool '%s'"),
-                             pool->def->source.name);
+                             def->source.name);
         goto cleanup;
     }
 
-    pool->def->capacity = clusterstat.kb * 1024;
-    pool->def->available = clusterstat.kb_avail * 1024;
-    pool->def->allocation = poolstat.num_bytes;
+    def->capacity = clusterstat.kb * 1024;
+    def->available = clusterstat.kb_avail * 1024;
+    def->allocation = poolstat.num_bytes;
 
     VIR_DEBUG("Utilization of RBD pool %s: (kb: %"PRIu64" kb_avail: %"PRIu64
               " num_bytes: %"PRIu64")",
-              pool->def->source.name, clusterstat.kb, clusterstat.kb_avail,
+              def->source.name, clusterstat.kb, clusterstat.kb_avail,
               poolstat.num_bytes);
 
     while (true) {
@@ -489,7 +494,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn,
 
         name += strlen(name) + 1;
 
-        r = volStorageBackendRBDRefreshVolInfo(vol, pool, ptr);
+        r = volStorageBackendRBDRefreshVolInfo(vol, poolobj, ptr);
 
         /* It could be that a volume has been deleted through a different route
          * then libvirt and that will cause a -ENOENT to be returned.
@@ -508,9 +513,9 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn,
             goto cleanup;
         }
 
-        if (!(volobj = virStoragePoolObjAddVolume(pool, vol))) {
+        if (!(volobj = virStoragePoolObjAddVolume(poolobj, vol))) {
             virStorageVolDefFree(vol);
-            virStoragePoolObjClearVols(pool);
+            virStoragePoolObjClearVols(poolobj);
             goto cleanup;
         }
         count++;
@@ -518,7 +523,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn,
     }
 
     VIR_DEBUG("Found %d images in RBD pool %s",
-              count, pool->def->source.name);
+              count, def->source.name);
 
     ret = 0;
 
@@ -608,10 +613,11 @@ virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioctx,
 
 static int
 virStorageBackendRBDDeleteVol(virConnectPtr conn,
-                              virStoragePoolObjPtr pool,
+                              virPoolObjPtr poolobj,
                               virStorageVolDefPtr vol,
                               unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     int r = 0;
     virStorageBackendRBDStatePtr ptr = NULL;
@@ -619,26 +625,26 @@ virStorageBackendRBDDeleteVol(virConnectPtr conn,
     virCheckFlags(VIR_STORAGE_VOL_DELETE_ZEROED |
                   VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS, -1);
 
-    VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->name);
+    VIR_DEBUG("Removing RBD image %s/%s", def->source.name, vol->name);
 
     if (flags & VIR_STORAGE_VOL_DELETE_ZEROED)
         VIR_WARN("%s", "This storage backend does not support zeroed removal of volumes");
 
-    if (!(ptr = virStorageBackendRBDNewState(conn, pool)))
+    if (!(ptr = virStorageBackendRBDNewState(conn, poolobj)))
         goto cleanup;
 
     if (flags & VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS) {
-        if (virStorageBackendRBDCleanupSnapshots(ptr->ioctx, &pool->def->source,
+        if (virStorageBackendRBDCleanupSnapshots(ptr->ioctx, &def->source,
                                                  vol) < 0)
             goto cleanup;
     }
 
-    VIR_DEBUG("Removing volume %s/%s", pool->def->source.name, vol->name);
+    VIR_DEBUG("Removing volume %s/%s", def->source.name, vol->name);
 
     r = rbd_remove(ptr->ioctx, vol->name);
     if (r < 0 && (-r) != ENOENT) {
         virReportSystemError(-r, _("failed to remove volume '%s/%s'"),
-                             pool->def->source.name, vol->name);
+                             def->source.name, vol->name);
         goto cleanup;
     }
 
@@ -652,9 +658,11 @@ virStorageBackendRBDDeleteVol(virConnectPtr conn,
 
 static int
 virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool,
+                              virPoolObjPtr poolobj,
                               virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
     vol->type = VIR_STORAGE_VOL_NETWORK;
 
     if (vol->target.format != VIR_STORAGE_FILE_RAW) {
@@ -665,13 +673,13 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
-                    pool->def->source.name,
+                    def->source.name,
                     vol->name) == -1)
         return -1;
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
-                    pool->def->source.name,
+                    def->source.name,
                     vol->name) == -1)
         return -1;
 
@@ -687,16 +695,17 @@ static int virStorageBackendRBDCreateImage(rados_ioctx_t io,
 
 static int
 virStorageBackendRBDBuildVol(virConnectPtr conn,
-                             virStoragePoolObjPtr pool,
+                             virPoolObjPtr poolobj,
                              virStorageVolDefPtr vol,
                              unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virStorageBackendRBDStatePtr ptr = NULL;
     int ret = -1;
     int r = 0;
 
     VIR_DEBUG("Creating RBD image %s/%s with size %llu",
-              pool->def->source.name,
+              def->source.name,
               vol->name, vol->target.capacity);
 
     virCheckFlags(0, -1);
@@ -719,13 +728,13 @@ virStorageBackendRBDBuildVol(virConnectPtr conn,
         goto cleanup;
     }
 
-    if (!(ptr = virStorageBackendRBDNewState(conn, pool)))
+    if (!(ptr = virStorageBackendRBDNewState(conn, poolobj)))
         goto cleanup;
 
     if ((r = virStorageBackendRBDCreateImage(ptr->ioctx, vol->name,
                                              vol->target.capacity)) < 0) {
         virReportSystemError(-r, _("failed to create volume '%s/%s'"),
-                             pool->def->source.name,
+                             def->source.name,
                              vol->name);
         goto cleanup;
     }
@@ -1044,20 +1053,21 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io,
 
 static int
 virStorageBackendRBDBuildVolFrom(virConnectPtr conn,
-                                 virStoragePoolObjPtr pool,
+                                 virPoolObjPtr poolobj,
                                  virStorageVolDefPtr newvol,
                                  virStorageVolDefPtr origvol,
                                  unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virStorageBackendRBDStatePtr ptr = NULL;
     int ret = -1;
 
     VIR_DEBUG("Creating clone of RBD image %s/%s with name %s",
-              pool->def->source.name, origvol->name, newvol->name);
+              def->source.name, origvol->name, newvol->name);
 
     virCheckFlags(0, -1);
 
-    if (!(ptr = virStorageBackendRBDNewState(conn, pool)))
+    if (!(ptr = virStorageBackendRBDNewState(conn, poolobj)))
         goto cleanup;
 
     if ((virStorageBackendRBDCloneImage(ptr->ioctx, origvol->name,
@@ -1073,16 +1083,16 @@ virStorageBackendRBDBuildVolFrom(virConnectPtr conn,
 
 static int
 virStorageBackendRBDRefreshVol(virConnectPtr conn,
-                               virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                               virPoolObjPtr poolobj,
                                virStorageVolDefPtr vol)
 {
     virStorageBackendRBDStatePtr ptr = NULL;
     int ret = -1;
 
-    if (!(ptr = virStorageBackendRBDNewState(conn, pool)))
+    if (!(ptr = virStorageBackendRBDNewState(conn, poolobj)))
         goto cleanup;
 
-    if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0)
+    if (volStorageBackendRBDRefreshVolInfo(vol, poolobj, ptr) < 0)
         goto cleanup;
 
     ret = 0;
@@ -1094,7 +1104,7 @@ virStorageBackendRBDRefreshVol(virConnectPtr conn,
 
 static int
 virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                              virPoolObjPtr poolobj,
                               virStorageVolDefPtr vol,
                               unsigned long long capacity,
                               unsigned int flags)
@@ -1106,7 +1116,7 @@ virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     virCheckFlags(0, -1);
 
-    if (!(ptr = virStorageBackendRBDNewState(conn, pool)))
+    if (!(ptr = virStorageBackendRBDNewState(conn, poolobj)))
         goto cleanup;
 
     if ((r = rbd_open(ptr->ioctx, vol->name, &image, NULL)) < 0) {
@@ -1206,11 +1216,12 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image,
 
 static int
 virStorageBackendRBDVolWipe(virConnectPtr conn,
-                            virStoragePoolObjPtr pool,
+                            virPoolObjPtr poolobj,
                             virStorageVolDefPtr vol,
                             unsigned int algorithm,
                             unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virStorageBackendRBDStatePtr ptr = NULL;
     rbd_image_t image = NULL;
     rbd_image_info_t info;
@@ -1220,9 +1231,9 @@ virStorageBackendRBDVolWipe(virConnectPtr conn,
 
     virCheckFlags(0, -1);
 
-    VIR_DEBUG("Wiping RBD image %s/%s", pool->def->source.name, vol->name);
+    VIR_DEBUG("Wiping RBD image %s/%s", def->source.name, vol->name);
 
-    if (!(ptr = virStorageBackendRBDNewState(conn, pool)))
+    if (!(ptr = virStorageBackendRBDNewState(conn, poolobj)))
         goto cleanup;
 
     if ((r = rbd_open(ptr->ioctx, vol->name, &image, NULL)) < 0) {
@@ -1244,7 +1255,7 @@ virStorageBackendRBDVolWipe(virConnectPtr conn,
     }
 
     VIR_DEBUG("Need to wipe %"PRIu64" bytes from RBD image %s/%s",
-              info.size, pool->def->source.name, vol->name);
+              info.size, def->source.name, vol->name);
 
     switch ((virStorageVolWipeAlgorithm) algorithm) {
     case VIR_STORAGE_VOL_WIPE_ALG_ZERO:
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 0cc1148..46aa6ab 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -137,7 +137,8 @@ virStoragePoolFCRefreshThread(void *opaque)
     virStoragePoolFCRefreshInfoPtr cbdata = opaque;
     const char *fchost_name = cbdata->fchost_name;
     const unsigned char *pool_uuid = cbdata->pool_uuid;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr obj = NULL;
+    virStoragePoolDefPtr def = NULL;
     unsigned int host;
     int found = 0;
     int tries = 2;
@@ -146,27 +147,29 @@ virStoragePoolFCRefreshThread(void *opaque)
         sleep(5); /* Give it time */
 
         /* Let's see if the pool still exists -  */
-        if (!(pool = virStoragePoolObjFindPoolByUUID(pool_uuid)))
+        if (!(obj = virStoragePoolObjFindPoolByUUID(pool_uuid)))
             break;
 
+        def = virPoolObjGetDef(obj);
+
         /* Return with pool lock, if active, we can get the host number,
          * successfully, rescan, and find LUN's, then we are happy
          */
         VIR_DEBUG("Attempt FC Refresh for pool='%s' name='%s' tries='%d'",
-                  pool->def->name, fchost_name, tries);
+                  def->name, fchost_name, tries);
 
-        pool->def->allocation = pool->def->capacity = pool->def->available = 0;
+        def->allocation = def->capacity = def->available = 0;
 
-        if (virStoragePoolObjIsActive(pool) &&
+        if (virPoolObjIsActive(obj) &&
             virGetSCSIHostNumber(fchost_name, &host) == 0 &&
             virStorageBackendSCSITriggerRescan(host) == 0) {
-            virStoragePoolObjClearVols(pool);
-            found = virStorageBackendSCSIFindLUs(pool, host);
+            virStoragePoolObjClearVols(obj);
+            found = virStorageBackendSCSIFindLUs(obj, host);
         }
-        virStoragePoolObjUnlock(pool);
+        virPoolObjEndAPI(&obj);
     } while (!found && --tries);
 
-    if (pool && !found)
+    if (obj && !found)
         VIR_DEBUG("FC Refresh Thread failed to find LU's");
 
     virStoragePoolFCRefreshDataFree(cbdata);
@@ -246,10 +249,11 @@ checkVhbaSCSIHostParent(virConnectPtr conn,
 
 static int
 createVport(virConnectPtr conn,
-            virStoragePoolObjPtr pool)
+            virPoolObjPtr obj)
 {
-    const char *configFile = pool->configFile;
-    virStoragePoolSourceAdapterPtr adapter = &pool->def->source.adapter;
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    const char *configFile = virStoragePoolObjPrivateGetConfigFile(obj);
+    virStoragePoolSourceAdapterPtr adapter = &def->source.adapter;
     unsigned int parent_host;
     char *name = NULL;
     char *parent_hoststr = NULL;
@@ -337,7 +341,7 @@ createVport(virConnectPtr conn,
     if (adapter->data.fchost.managed != VIR_TRISTATE_BOOL_YES) {
         adapter->data.fchost.managed = VIR_TRISTATE_BOOL_YES;
         if (configFile) {
-            if (virStoragePoolSaveConfig(configFile, pool->def) < 0)
+            if (virStoragePoolSaveConfig(configFile, def) < 0)
                 goto cleanup;
         }
     }
@@ -356,7 +360,7 @@ createVport(virConnectPtr conn,
     if ((name = virGetFCHostNameByWWN(NULL, adapter->data.fchost.wwnn,
                                       adapter->data.fchost.wwpn))) {
         if (VIR_ALLOC(cbdata) == 0) {
-            memcpy(cbdata->pool_uuid, pool->def->uuid, VIR_UUID_BUFLEN);
+            memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN);
             VIR_STEAL_PTR(cbdata->fchost_name, name);
 
             if (virThreadCreate(&thread, false, virStoragePoolFCRefreshThread,
@@ -435,9 +439,10 @@ deleteVport(virConnectPtr conn,
 
 
 static int
-virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
+virStorageBackendSCSICheckPool(virPoolObjPtr obj,
                                bool *isActive)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     char *path = NULL;
     char *name = NULL;
     unsigned int host;
@@ -445,12 +450,12 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
 
     *isActive = false;
 
-    if (!(name = getAdapterName(pool->def->source.adapter))) {
+    if (!(name = getAdapterName(def->source.adapter))) {
         /* It's normal for the pool with "fc_host" type source
          * adapter fails to get the adapter name, since the vHBA
          * the adapter based on might be not created yet.
          */
-        if (pool->def->source.adapter.type ==
+        if (def->source.adapter.type ==
             VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
             virResetLastError();
             return 0;
@@ -477,15 +482,16 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
 
 static int
 virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                 virStoragePoolObjPtr pool)
+                                 virPoolObjPtr obj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     char *name = NULL;
     unsigned int host;
     int ret = -1;
 
-    pool->def->allocation = pool->def->capacity = pool->def->available = 0;
+    def->allocation = def->capacity = def->available = 0;
 
-    if (!(name = getAdapterName(pool->def->source.adapter)))
+    if (!(name = getAdapterName(def->source.adapter)))
         return -1;
 
     if (virGetSCSIHostNumber(name, &host) < 0)
@@ -496,7 +502,7 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     if (virStorageBackendSCSITriggerRescan(host) < 0)
         goto out;
 
-    if (virStorageBackendSCSIFindLUs(pool, host) < 0)
+    if (virStorageBackendSCSIFindLUs(obj, host) < 0)
         goto out;
 
     ret = 0;
@@ -507,16 +513,17 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendSCSIStartPool(virConnectPtr conn,
-                               virStoragePoolObjPtr pool)
+                               virPoolObjPtr obj)
 {
-    return createVport(conn, pool);
+    return createVport(conn, obj);
 }
 
 static int
 virStorageBackendSCSIStopPool(virConnectPtr conn,
-                              virStoragePoolObjPtr pool)
+                              virPoolObjPtr obj)
 {
-    virStoragePoolSourceAdapter adapter = pool->def->source.adapter;
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    virStoragePoolSourceAdapter adapter = def->source.adapter;
     return deleteVport(conn, adapter);
 }
 
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 04734c8..2dc9f1c 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -30,7 +30,6 @@
 #include "virerror.h"
 #include "storage_backend_sheepdog.h"
 #include "storage_backend_sheepdog_priv.h"
-#include "storage_conf.h"
 #include "vircommand.h"
 #include "viralloc.h"
 #include "virstring.h"
@@ -39,14 +38,14 @@
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
 static int virStorageBackendSheepdogRefreshVol(virConnectPtr conn,
-                                               virStoragePoolObjPtr pool,
+                                               virPoolObjPtr poolobj,
                                                virStorageVolDefPtr vol);
 
 void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
-                                         virStoragePoolObjPtr pool);
+                                         virPoolObjPtr poolobj);
 
 int
-virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
+virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr def,
                                        char *output)
 {
     /* fields:
@@ -59,7 +58,7 @@ virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
 
     const char *p, *next;
 
-    pool->allocation = pool->capacity = pool->available = 0;
+    def->allocation = def->capacity = def->available = 0;
 
     p = output;
     do {
@@ -75,16 +74,16 @@ virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
 
         p = p + 6;
 
-        if (virStrToLong_ull(p, &end, 10, &pool->capacity) < 0)
+        if (virStrToLong_ull(p, &end, 10, &def->capacity) < 0)
             break;
 
         if ((p = end + 1) > next)
             break;
 
-        if (virStrToLong_ull(p, &end, 10, &pool->allocation) < 0)
+        if (virStrToLong_ull(p, &end, 10, &def->allocation) < 0)
             break;
 
-        pool->available = pool->capacity - pool->allocation;
+        def->available = def->capacity - def->allocation;
         return 0;
 
     } while ((p = next));
@@ -94,15 +93,16 @@ virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
 
 void
 virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
-                                    virStoragePoolObjPtr pool)
+                                    virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     const char *address = "localhost";
     int port = 7000;
-    if (pool->def->source.nhost > 0) {
-        if (pool->def->source.hosts[0].name != NULL)
-            address = pool->def->source.hosts[0].name;
-        if (pool->def->source.hosts[0].port)
-            port = pool->def->source.hosts[0].port;
+    if (def->source.nhost > 0) {
+        if (def->source.hosts[0].name != NULL)
+            address = def->source.hosts[0].name;
+        if (def->source.hosts[0].port)
+            port = def->source.hosts[0].port;
     }
     virCommandAddArg(cmd, "-a");
     virCommandAddArgFormat(cmd, "%s", address);
@@ -112,10 +112,11 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
 
 static int
 virStorageBackendSheepdogAddVolume(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool, const char *diskInfo)
+                                   virPoolObjPtr poolobj,
+                                   const char *diskInfo)
 {
-    virStorageVolDefPtr vol = NULL;
-    virPoolObjPtr obj;
+    virPoolObjPtr volobj;
+    virStorageVolDefPtr voldef = NULL;
 
     if (diskInfo == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -123,29 +124,29 @@ virStorageBackendSheepdogAddVolume(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto error;
     }
 
-    if (VIR_ALLOC(vol) < 0 || VIR_STRDUP(vol->name, diskInfo) < 0)
+    if (VIR_ALLOC(voldef) < 0 || VIR_STRDUP(voldef->name, diskInfo) < 0)
         goto error;
 
-    vol->type = VIR_STORAGE_VOL_NETWORK;
+    voldef->type = VIR_STORAGE_VOL_NETWORK;
 
-    if (virStorageBackendSheepdogRefreshVol(conn, pool, vol) < 0)
+    if (virStorageBackendSheepdogRefreshVol(conn, poolobj, voldef) < 0)
         goto error;
 
-    if (!(obj = virStoragePoolObjAddVolume(pool, vol)))
+    if (!(volobj = virStoragePoolObjAddVolume(poolobj, voldef)))
         goto error;
-    vol = NULL;
+    voldef = NULL;
 
-    virPoolObjEndAPI(&obj);
+    virPoolObjEndAPI(&volobj);
     return 0;
 
  error:
-    virStorageVolDefFree(vol);
+    virStorageVolDefFree(voldef);
     return -1;
 }
 
 static int
 virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                       virStoragePoolObjPtr pool)
+                                       virPoolObjPtr poolobj)
 {
     int ret = -1;
     char *output = NULL;
@@ -154,7 +155,7 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
     size_t i;
 
     virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "list", "-r", NULL);
-    virStorageBackendSheepdogAddHostArg(cmd, pool);
+    virStorageBackendSheepdogAddHostArg(cmd, poolobj);
     virCommandSetOutputBuffer(cmd, &output);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
@@ -172,7 +173,8 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
         if (cells != NULL &&
             virStringListLength((const char * const *)cells) > 2) {
-            if (virStorageBackendSheepdogAddVolume(conn, pool, cells[1]) < 0)
+            if (virStorageBackendSheepdogAddVolume(conn, poolobj,
+                                                   cells[1]) < 0)
                 goto cleanup;
         }
 
@@ -193,22 +195,23 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                     virStoragePoolObjPtr pool)
+                                     virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     char *output = NULL;
     virCommandPtr cmd;
 
     cmd = virCommandNewArgList(SHEEPDOGCLI, "node", "info", "-r", NULL);
-    virStorageBackendSheepdogAddHostArg(cmd, pool);
+    virStorageBackendSheepdogAddHostArg(cmd, poolobj);
     virCommandSetOutputBuffer(cmd, &output);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
-    if (virStorageBackendSheepdogParseNodeInfo(pool->def, output) < 0)
+    if (virStorageBackendSheepdogParseNodeInfo(def, output) < 0)
         goto cleanup;
 
-    ret = virStorageBackendSheepdogRefreshAllVol(conn, pool);
+    ret = virStorageBackendSheepdogRefreshAllVol(conn, poolobj);
  cleanup:
     virCommandFree(cmd);
     VIR_FREE(output);
@@ -218,7 +221,7 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                   virStoragePoolObjPtr pool,
+                                   virPoolObjPtr poolobj,
                                    virStorageVolDefPtr vol,
                                    unsigned int flags)
 {
@@ -226,7 +229,7 @@ virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
     virCheckFlags(0, -1);
 
     virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "delete", vol->name, NULL);
-    virStorageBackendSheepdogAddHostArg(cmd, pool);
+    virStorageBackendSheepdogAddHostArg(cmd, poolobj);
     int ret = virCommandRun(cmd, NULL);
 
     virCommandFree(cmd);
@@ -236,9 +239,11 @@ virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                   virStoragePoolObjPtr pool,
+                                   virPoolObjPtr poolobj,
                                    virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
     if (vol->target.encryption != NULL) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        "%s", _("storage pool does not support encrypted "
@@ -250,7 +255,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
-                    pool->def->source.name, vol->name) == -1)
+                    def->source.name, vol->name) == -1)
         return -1;
 
     VIR_FREE(vol->target.path);
@@ -263,7 +268,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendSheepdogBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool,
+                                  virPoolObjPtr poolobj,
                                   virStorageVolDefPtr vol,
                                   unsigned int flags)
 {
@@ -280,7 +285,7 @@ virStorageBackendSheepdogBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "create", vol->name, NULL);
     virCommandAddArgFormat(cmd, "%llu", vol->target.capacity);
-    virStorageBackendSheepdogAddHostArg(cmd, pool);
+    virStorageBackendSheepdogAddHostArg(cmd, poolobj);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
@@ -354,14 +359,15 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
 
 static int
 virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                    virStoragePoolObjPtr pool,
+                                    virPoolObjPtr poolobj,
                                     virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret;
     char *output = NULL;
 
     virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "list", vol->name, "-r", NULL);
-    virStorageBackendSheepdogAddHostArg(cmd, pool);
+    virStorageBackendSheepdogAddHostArg(cmd, poolobj);
     virCommandSetOutputBuffer(cmd, &output);
     ret = virCommandRun(cmd, NULL);
 
@@ -375,7 +381,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
-                    pool->def->source.name, vol->name) == -1)
+                    def->source.name, vol->name) == -1)
         goto cleanup;
 
     VIR_FREE(vol->target.path);
@@ -388,7 +394,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                   virStoragePoolObjPtr pool,
+                                   virPoolObjPtr poolobj,
                                    virStorageVolDefPtr vol,
                                    unsigned long long capacity,
                                    unsigned int flags)
@@ -398,7 +404,7 @@ virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "resize", vol->name, NULL);
     virCommandAddArgFormat(cmd, "%llu", capacity);
-    virStorageBackendSheepdogAddHostArg(cmd, pool);
+    virStorageBackendSheepdogAddHostArg(cmd, poolobj);
     int ret = virCommandRun(cmd, NULL);
 
     virCommandFree(cmd);
diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_backend_vstorage.c
index ac1fa75..3ec080d 100644
--- a/src/storage/storage_backend_vstorage.c
+++ b/src/storage/storage_backend_vstorage.c
@@ -18,7 +18,7 @@ VIR_LOG_INIT("storage.storage_backend_vstorage");
 
 /**
  * @conn connection to report errors against
- * @pool storage pool to build
+ * @poolobj storage pool object to build
  * @flags controls the pool formatting behaviour
  *
  * Does not support @flags, if provided an error will occur.
@@ -27,19 +27,20 @@ VIR_LOG_INIT("storage.storage_backend_vstorage");
  */
 static int
 virStorageBackendVzPoolBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
-                             virStoragePoolObjPtr pool,
+                             virPoolObjPtr poolobj,
                              unsigned int flags)
 {
     virCheckFlags(0, -1);
 
-    return virStorageBackendBuildLocal(pool);
+    return virStorageBackendBuildLocal(poolobj);
 }
 
 
 static int
 virStorageBackendVzPoolStart(virConnectPtr conn ATTRIBUTE_UNUSED,
-                             virStoragePoolObjPtr pool)
+                             virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     virCommandPtr cmd = NULL;
     char *grp_name = NULL;
@@ -47,27 +48,27 @@ virStorageBackendVzPoolStart(virConnectPtr conn ATTRIBUTE_UNUSED,
     char *mode = NULL;
 
     /* Check the permissions */
-    if (pool->def->target.perms.mode == (mode_t) - 1)
-        pool->def->target.perms.mode = VIR_STORAGE_DEFAULT_POOL_PERM_MODE;
-    if (pool->def->target.perms.uid == (uid_t) -1)
-        pool->def->target.perms.uid = geteuid();
-    if (pool->def->target.perms.gid == (gid_t) -1)
-        pool->def->target.perms.gid = getegid();
+    if (def->target.perms.mode == (mode_t) - 1)
+        def->target.perms.mode = VIR_STORAGE_DEFAULT_POOL_PERM_MODE;
+    if (def->target.perms.uid == (uid_t) -1)
+        def->target.perms.uid = geteuid();
+    if (def->target.perms.gid == (gid_t) -1)
+        def->target.perms.gid = getegid();
 
     /* Convert ids to names because vstorage uses names */
 
-    if (!(grp_name = virGetGroupName(pool->def->target.perms.gid)))
+    if (!(grp_name = virGetGroupName(def->target.perms.gid)))
         goto cleanup;
 
-    if (!(usr_name = virGetUserName(pool->def->target.perms.uid)))
+    if (!(usr_name = virGetUserName(def->target.perms.uid)))
         goto cleanup;
 
-    if (virAsprintf(&mode, "%o", pool->def->target.perms.mode) < 0)
+    if (virAsprintf(&mode, "%o", def->target.perms.mode) < 0)
         goto cleanup;
 
     cmd = virCommandNewArgList(VSTORAGE_MOUNT,
-                               "-c", pool->def->source.name,
-                               pool->def->target.path,
+                               "-c", def->source.name,
+                               def->target.path,
                                "-m", mode,
                                "-g", grp_name, "-u", usr_name,
                                NULL);
@@ -86,8 +87,9 @@ virStorageBackendVzPoolStart(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 
 static int
-virStorageBackendVzIsMounted(virStoragePoolObjPtr pool)
+virStorageBackendVzIsMounted(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     FILE *mtab;
     struct mntent ent;
@@ -106,7 +108,7 @@ virStorageBackendVzIsMounted(virStoragePoolObjPtr pool)
 
     while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
 
-        if (STREQ(ent.mnt_dir, pool->def->target.path) &&
+        if (STREQ(ent.mnt_dir, def->target.path) &&
             STREQ(ent.mnt_fsname, cluster)) {
             ret = 1;
             goto cleanup;
@@ -124,17 +126,18 @@ virStorageBackendVzIsMounted(virStoragePoolObjPtr pool)
 
 static int
 virStorageBackendVzPoolStop(virConnectPtr conn ATTRIBUTE_UNUSED,
-                            virStoragePoolObjPtr pool)
+                            virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     int ret = -1;
     int rc;
 
     /* Short-circuit if already unmounted */
-    if ((rc = virStorageBackendVzIsMounted(pool)) != 1)
+    if ((rc = virStorageBackendVzIsMounted(poolobj)) != 1)
         return rc;
 
-    cmd = virCommandNewArgList(UMOUNT, pool->def->target.path, NULL);
+    cmd = virCommandNewArgList(UMOUNT, def->target.path, NULL);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
@@ -149,12 +152,12 @@ virStorageBackendVzPoolStop(virConnectPtr conn ATTRIBUTE_UNUSED,
  * Check whether the cluster is mounted
  */
 static int
-virStorageBackendVzCheck(virStoragePoolObjPtr pool,
+virStorageBackendVzCheck(virPoolObjPtr poolobj,
                          bool *isActive)
 {
     int ret = -1;
     *isActive = false;
-    if ((ret = virStorageBackendVzIsMounted(pool)) != 0) {
+    if ((ret = virStorageBackendVzIsMounted(poolobj)) != 0) {
         if (ret < 0)
             return -1;
         *isActive = true;
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index fab29fb..4b20086 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -83,13 +83,14 @@ virStorageBackendZFSVolModeNeeded(void)
 }
 
 static int
-virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendZFSCheckPool(virPoolObjPtr poolobj,
                               bool *isActive)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     char *devpath;
 
     if (virAsprintf(&devpath, "/dev/zvol/%s",
-                    pool->def->source.name) == -1)
+                    def->source.name) < 0)
         return -1;
     *isActive = virFileIsDir(devpath);
     VIR_FREE(devpath);
@@ -98,10 +99,11 @@ virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
 }
 
 static int
-virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
+virStorageBackendZFSParseVol(virPoolObjPtr poolobj,
                              virStorageVolDefPtr volume,
                              const char *volume_string)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef = volume;
     int ret = -1;
@@ -123,7 +125,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
     vol_name = name_tokens[1];
 
     if (!voldef) {
-        if ((volobj = virStorageVolObjFindByName(pool, vol_name)))
+        if ((volobj = virStorageVolObjFindByName(poolobj, vol_name)))
             voldef = virPoolObjGetDef(volobj);
     }
 
@@ -141,9 +143,9 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
     if (!voldef->key && VIR_STRDUP(voldef->key, tokens[0]) < 0)
         goto cleanup;
 
-    if (voldef->target.path == NULL) {
+    if (!voldef->target.path) {
         if (virAsprintf(&voldef->target.path, "%s/%s",
-                        pool->def->target.path, voldef->name) < 0)
+                        def->target.path, voldef->name) < 0)
             goto cleanup;
     }
 
@@ -163,7 +165,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
         voldef->target.sparse = true;
 
     if (is_new_vol) {
-        if (!(volobj = virStoragePoolObjAddVolume(pool, voldef)))
+        if (!(volobj = virStoragePoolObjAddVolume(poolobj, voldef)))
             goto cleanup;
 
         voldef = NULL;
@@ -173,16 +175,17 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
  cleanup:
     virStringListFree(tokens);
     virStringListFree(name_tokens);
-    virPoolObjEndAPI(&volobj);
     if (is_new_vol)
         virStorageVolDefFree(voldef);
+    virPoolObjEndAPI(&volobj);
     return ret;
 }
 
 static int
-virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
+virStorageBackendZFSFindVols(virPoolObjPtr poolobj,
                              virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     char *volumes_list = NULL;
     char **lines = NULL;
@@ -204,7 +207,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
                                "list", "-Hp",
                                "-t", "volume", "-r",
                                "-o", "name,volsize,refreservation",
-                               pool->def->source.name,
+                               def->source.name,
                                NULL);
     virCommandSetOutputBuffer(cmd, &volumes_list);
     if (virCommandRun(cmd, NULL) < 0)
@@ -217,7 +220,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
         if (STREQ(lines[i], ""))
             continue;
 
-        if (virStorageBackendZFSParseVol(pool, vol, lines[i]) < 0)
+        if (virStorageBackendZFSParseVol(poolobj, vol, lines[i]) < 0)
             continue;
     }
 
@@ -231,8 +234,9 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
 
 static int
 virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                virStoragePoolObjPtr pool ATTRIBUTE_UNUSED)
+                                virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     char *zpool_props = NULL;
     char **lines = NULL;
@@ -252,7 +256,7 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     cmd = virCommandNewArgList(ZPOOL,
                                "get", "-Hp",
                                "health,size,free,allocated",
-                               pool->def->source.name,
+                               def->source.name,
                                NULL);
     virCommandSetOutputBuffer(cmd, &zpool_props);
     if (virCommandRun(cmd, NULL) < 0)
@@ -284,16 +288,16 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
                 goto cleanup;
 
             if (STREQ(prop_name, "free"))
-                pool->def->available = value;
+                def->available = value;
             else if (STREQ(prop_name, "size"))
-                pool->def->capacity = value;
+                def->capacity = value;
             else if (STREQ(prop_name, "allocated"))
-                pool->def->allocation = value;
+                def->allocation = value;
         }
     }
 
     /* Obtain a list of volumes */
-    if (virStorageBackendZFSFindVols(pool, NULL) < 0)
+    if (virStorageBackendZFSFindVols(poolobj, NULL) < 0)
         goto cleanup;
 
  cleanup:
@@ -307,9 +311,10 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool,
+                              virPoolObjPtr poolobj,
                               virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     int ret = -1;
     int volmode_needed = -1;
@@ -325,7 +330,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
-                    pool->def->target.path, vol->name) == -1)
+                    def->target.path, vol->name) == -1)
         return -1;
 
     if (VIR_STRDUP(vol->key, vol->target.path) < 0)
@@ -362,12 +367,12 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
     virCommandAddArgFormat(cmd, "%lluK",
                            VIR_DIV_UP(vol->target.capacity, 1024));
     virCommandAddArgFormat(cmd, "%s/%s",
-                           pool->def->source.name, vol->name);
+                           def->source.name, vol->name);
 
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
-    if (virStorageBackendZFSFindVols(pool, vol) < 0)
+    if (virStorageBackendZFSFindVols(poolobj, vol) < 0)
         goto cleanup;
 
     ret = 0;
@@ -379,10 +384,11 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool,
+                              virPoolObjPtr poolobj,
                               virStorageVolDefPtr vol,
                               unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     virCommandPtr destroy_cmd = NULL;
 
@@ -391,7 +397,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
     destroy_cmd = virCommandNewArgList(ZFS, "destroy", NULL);
 
     virCommandAddArgFormat(destroy_cmd, "%s/%s",
-                           pool->def->source.name, vol->name);
+                           def->source.name, vol->name);
 
     if (virCommandRun(destroy_cmd, NULL) < 0)
         goto cleanup;
@@ -404,26 +410,27 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool,
+                              virPoolObjPtr poolobj,
                               unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     size_t i;
     int ret = -1;
 
     virCheckFlags(0, -1);
 
-    if (pool->def->source.ndevice == 0) {
+    if (def->source.ndevice == 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        "%s", _("missing source devices"));
         return -1;
     }
 
     cmd = virCommandNewArgList(ZPOOL, "create",
-                               pool->def->source.name, NULL);
+                               def->source.name, NULL);
 
-    for (i = 0; i < pool->def->source.ndevice; i++)
-        virCommandAddArg(cmd, pool->def->source.devices[i].path);
+    for (i = 0; i < def->source.ndevice; i++)
+        virCommandAddArg(cmd, def->source.devices[i].path);
 
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
@@ -437,16 +444,17 @@ virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 virStorageBackendZFSDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
-                               virStoragePoolObjPtr pool,
+                               virPoolObjPtr poolobj,
                                unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     virCommandPtr cmd = NULL;
     int ret = -1;
 
     virCheckFlags(0, -1);
 
     cmd = virCommandNewArgList(ZPOOL, "destroy",
-                               pool->def->source.name, NULL);
+                               def->source.name, NULL);
 
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 19f7a88..fe4f7aa 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -78,20 +78,21 @@ static void storageDriverUnlock(void)
 }
 
 static void
-storagePoolUpdateState(virStoragePoolObjPtr pool)
+storagePoolUpdateState(virPoolObjPtr obj,
+                       void *opaque ATTRIBUTE_UNUSED)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     bool active;
     virStorageBackendPtr backend;
     int ret = -1;
     char *stateFile;
 
-    if (!(stateFile = virFileBuildPath(driver->stateDir,
-                                       pool->def->name, ".xml")))
+    if (!(stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml")))
         goto error;
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
+    if ((backend = virStorageBackendForType(def->type)) == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Missing backend %d"), pool->def->type);
+                       _("Missing backend %d"), def->type);
         goto error;
     }
 
@@ -100,10 +101,10 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
      */
     active = false;
     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());
+                       def->name, virGetLastErrorMessage());
         goto error;
     }
 
@@ -112,18 +113,18 @@ 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());
+                           def->name, virGetLastErrorMessage());
             goto error;
         }
     }
 
-    pool->active = active;
+    virPoolObjSetActive(obj, active);
     ret = 0;
  error:
     if (ret < 0) {
@@ -135,24 +136,57 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
     return;
 }
 
+
 static void
-storagePoolUpdateAllState(void)
+storagePoolDoAutostart(virPoolObjPtr obj,
+                       void *opaque ATTRIBUTE_UNUSED)
 {
-    size_t i;
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    virConnectPtr conn = opaque;
+    virStorageBackendPtr backend;
+    bool started = false;
 
-    for (i = 0; i < driver->pools.count; i++) {
-        virStoragePoolObjPtr pool = driver->pools.objs[i];
+    if (!(backend = virStorageBackendForType(def->type)))
+        return;
 
-        virStoragePoolObjLock(pool);
-        storagePoolUpdateState(pool);
-        virStoragePoolObjUnlock(pool);
+    if (virPoolObjIsAutostart(obj) && !virPoolObjIsActive(obj)) {
+        if (backend->startPool &&
+            backend->startPool(conn, obj) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Failed to autostart storage pool '%s': %s"),
+                           def->name, virGetLastErrorMessage());
+            return;
+        }
+        started = true;
     }
+
+    if (started) {
+        char *stateFile;
+
+        virStoragePoolObjClearVols(obj);
+        stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml");
+        if (!stateFile ||
+            virStoragePoolSaveState(stateFile, def) < 0 ||
+            backend->refreshPool(conn, obj) < 0) {
+            if (stateFile)
+                unlink(stateFile);
+            if (backend->stopPool)
+                backend->stopPool(conn, obj);
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Failed to autostart storage pool '%s': %s"),
+                           def->name, virGetLastErrorMessage());
+        } else {
+            virPoolObjSetActive(obj, true);
+        }
+        VIR_FREE(stateFile);
+    }
+
 }
 
+
 static void
 storageDriverAutostart(void)
 {
-    size_t i;
     virConnectPtr conn = NULL;
 
     /* XXX Remove hardcoding of QEMU URI */
@@ -160,59 +194,14 @@ storageDriverAutostart(void)
         conn = virConnectOpen("qemu:///system");
     else
         conn = virConnectOpen("qemu:///session");
-    /* Ignoring NULL conn - let backends decide */
-
-    for (i = 0; i < driver->pools.count; i++) {
-        virStoragePoolObjPtr pool = driver->pools.objs[i];
-        virStorageBackendPtr backend;
-        bool started = false;
-
-        virStoragePoolObjLock(pool);
-        if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
-            virStoragePoolObjUnlock(pool);
-            continue;
-        }
-
-        if (pool->autostart &&
-            !virStoragePoolObjIsActive(pool)) {
-            if (backend->startPool &&
-                backend->startPool(conn, pool) < 0) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("Failed to autostart storage pool '%s': %s"),
-                               pool->def->name, virGetLastErrorMessage());
-                virStoragePoolObjUnlock(pool);
-                continue;
-            }
-            started = true;
-        }
 
-        if (started) {
-            char *stateFile;
-
-            virStoragePoolObjClearVols(pool);
-            stateFile = virFileBuildPath(driver->stateDir,
-                                         pool->def->name, ".xml");
-            if (!stateFile ||
-                virStoragePoolSaveState(stateFile, pool->def) < 0 ||
-                backend->refreshPool(conn, pool) < 0) {
-                if (stateFile)
-                    unlink(stateFile);
-                if (backend->stopPool)
-                    backend->stopPool(conn, pool);
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("Failed to autostart storage pool '%s': %s"),
-                               pool->def->name, virGetLastErrorMessage());
-            } else {
-                pool->active = true;
-            }
-            VIR_FREE(stateFile);
-        }
-        virStoragePoolObjUnlock(pool);
-    }
+    /* Ignoring NULL conn - let backends decide */
+    virPoolObjTableIterate(driver->pools, storagePoolDoAutostart, conn);
 
     virObjectUnref(conn);
 }
 
+
 /**
  * virStorageStartup:
  *
@@ -267,16 +256,21 @@ storageStateInitialize(bool privileged,
         goto error;
     }
 
-    if (virStoragePoolLoadAllState(&driver->pools,
-                                   driver->stateDir) < 0)
+    if (!(driver->pools =
+          virPoolObjTableNew(VIR_POOLOBJTABLE_BLOCK_STORAGE,
+                             VIR_POOLOBJTABLE_BLOCK_STORAGE_HASHSTART, false)))
+        goto error;
+
+    if (virStoragePoolObjLoadAllState(driver->pools,
+                                      driver->stateDir) < 0)
         goto error;
 
-    if (virStoragePoolLoadAllConfigs(&driver->pools,
-                                     driver->configDir,
-                                     driver->autostartDir) < 0)
+    if (virStoragePoolObjLoadAllConfigs(driver->pools,
+                                        driver->configDir,
+                                        driver->autostartDir) < 0)
         goto error;
 
-    storagePoolUpdateAllState();
+    virPoolObjTableIterate(driver->pools, storagePoolUpdateState, NULL);
 
     driver->storageEventState = virObjectEventStateNew();
 
@@ -323,11 +317,11 @@ storageStateReload(void)
         return -1;
 
     storageDriverLock();
-    virStoragePoolLoadAllState(&driver->pools,
-                               driver->stateDir);
-    virStoragePoolLoadAllConfigs(&driver->pools,
-                                 driver->configDir,
-                                 driver->autostartDir);
+    virStoragePoolObjLoadAllState(driver->pools,
+                                  driver->stateDir);
+    virStoragePoolObjLoadAllConfigs(driver->pools,
+                                    driver->configDir,
+                                    driver->autostartDir);
     storageDriverAutostart();
     storageDriverUnlock();
 
@@ -351,7 +345,7 @@ storageStateCleanup(void)
     virObjectUnref(driver->storageEventState);
 
     /* free inactive pools */
-    virStoragePoolObjListFree(&driver->pools);
+    virObjectUnref(driver->pools);
 
     VIR_FREE(driver->configDir);
     VIR_FREE(driver->autostartDir);
@@ -364,211 +358,173 @@ storageStateCleanup(void)
 }
 
 
+static virPoolObjPtr
+storagePoolObjFindByUUID(const unsigned char *uuid,
+                         const char *name)
+{
+    virPoolObjPtr obj;
+    char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+    if (!(obj = virPoolObjTableFindByUUIDRef(driver->pools, uuid))) {
+        virUUIDFormat(uuid, uuidstr);
+        if (name)
+            virReportError(VIR_ERR_NO_STORAGE_POOL,
+                           _("no storage pool with matching uuid '%s' (%s)"),
+                           uuidstr, name);
+        else
+            virReportError(VIR_ERR_NO_STORAGE_POOL,
+                           _("no storage pool with matching uuid '%s'"),
+                           uuidstr);
+    }
+
+    return obj;
+}
+
+
+static virPoolObjPtr
+storagePoolObjFromStoragePool(virStoragePoolPtr pool)
+{
+    return storagePoolObjFindByUUID(pool->uuid, pool->name);
+}
+
+
+static virPoolObjPtr
+storagePoolObjFindByName(const char *name)
+{
+    virPoolObjPtr obj;
+
+    if (!(obj = virPoolObjTableFindByName(driver->pools, name))) {
+        virReportError(VIR_ERR_NO_STORAGE_VOL,
+                       _("no storage vol with matching name '%s'"), name);
+    }
+
+    return obj;
+}
+
 
 static virStoragePoolPtr
 storagePoolLookupByUUID(virConnectPtr conn,
                         const unsigned char *uuid)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStoragePoolPtr ret = NULL;
 
-    storageDriverLock();
-    pool = virStoragePoolObjFindByUUID(&driver->pools, uuid);
-    storageDriverUnlock();
-
-    if (!pool) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(uuid, uuidstr);
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching uuid '%s'"), uuidstr);
+    if (!(obj = storagePoolObjFindByUUID(uuid, NULL)))
         return NULL;
-    }
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolLookupByUUIDEnsureACL(conn, pool->def) < 0)
+    if (virStoragePoolLookupByUUIDEnsureACL(conn, def) < 0)
         goto cleanup;
 
-    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static virStoragePoolPtr
 storagePoolLookupByName(virConnectPtr conn,
                         const char *name)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStoragePoolPtr ret = NULL;
 
-    storageDriverLock();
-    pool = virStoragePoolObjFindByName(&driver->pools, name);
-    storageDriverUnlock();
-
-    if (!pool) {
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching name '%s'"), name);
+    if (!(obj = storagePoolObjFindByName(name)))
         return NULL;
-    }
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolLookupByNameEnsureACL(conn, pool->def) < 0)
+    if (virStoragePoolLookupByNameEnsureACL(conn, def) < 0)
         goto cleanup;
 
-    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static virStoragePoolPtr
-storagePoolLookupByVolume(virStorageVolPtr vol)
+storagePoolLookupByVolume(virStorageVolPtr volume)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStoragePoolPtr ret = NULL;
 
-    storageDriverLock();
-    pool = virStoragePoolObjFindByName(&driver->pools, vol->pool);
-    storageDriverUnlock();
-
-    if (!pool) {
+    if (!(obj = virPoolObjTableFindByName(driver->pools, volume->pool))) {
         virReportError(VIR_ERR_NO_STORAGE_POOL,
                        _("no storage pool with matching name '%s'"),
-                       vol->pool);
+                       volume->pool);
         return NULL;
     }
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, pool->def) < 0)
+    if (virStoragePoolLookupByVolumeEnsureACL(volume->conn, def) < 0)
         goto cleanup;
 
-    ret = virGetStoragePool(vol->conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(volume->conn, def->name, def->uuid, NULL, NULL);
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
 storageConnectNumOfStoragePools(virConnectPtr conn)
 {
-    size_t i;
-    int nactive = 0;
 
     if (virConnectNumOfStoragePoolsEnsureACL(conn) < 0)
         return -1;
 
-    storageDriverLock();
-    for (i = 0; i < driver->pools.count; i++) {
-        virStoragePoolObjPtr obj = driver->pools.objs[i];
-        virStoragePoolObjLock(obj);
-        if (virConnectNumOfStoragePoolsCheckACL(conn, obj->def) &&
-            virStoragePoolObjIsActive(obj))
-            nactive++;
-        virStoragePoolObjUnlock(obj);
-    }
-    storageDriverUnlock();
-
-    return nactive;
+    return virStoragePoolObjNumOfStoragePools(driver->pools, conn, true,
+                                          virConnectNumOfStoragePoolsCheckACL);
 }
 
+
 static int
 storageConnectListStoragePools(virConnectPtr conn,
                                char **const names,
-                               int nnames)
+                               int maxnames)
 {
-    int got = 0;
-    size_t i;
-
     if (virConnectListStoragePoolsEnsureACL(conn) < 0)
         return -1;
 
-    storageDriverLock();
-    for (i = 0; i < driver->pools.count && got < nnames; i++) {
-        virStoragePoolObjPtr obj = driver->pools.objs[i];
-        virStoragePoolObjLock(obj);
-        if (virConnectListStoragePoolsCheckACL(conn, obj->def) &&
-            virStoragePoolObjIsActive(obj)) {
-            if (VIR_STRDUP(names[got], obj->def->name) < 0) {
-                virStoragePoolObjUnlock(obj);
-                goto cleanup;
-            }
-            got++;
-        }
-        virStoragePoolObjUnlock(obj);
-    }
-    storageDriverUnlock();
-    return got;
-
- cleanup:
-    storageDriverUnlock();
-    for (i = 0; i < got; i++)
-        VIR_FREE(names[i]);
-    memset(names, 0, nnames * sizeof(*names));
-    return -1;
+    return virStoragePoolObjGetNames(driver->pools, conn, true,
+                                     virConnectListStoragePoolsCheckACL,
+                                     names, maxnames);
 }
 
+
 static int
 storageConnectNumOfDefinedStoragePools(virConnectPtr conn)
 {
-    size_t i;
-    int nactive = 0;
-
     if (virConnectNumOfDefinedStoragePoolsEnsureACL(conn) < 0)
         return -1;
 
-    storageDriverLock();
-    for (i = 0; i < driver->pools.count; i++) {
-        virStoragePoolObjPtr obj = driver->pools.objs[i];
-        virStoragePoolObjLock(obj);
-        if (virConnectNumOfDefinedStoragePoolsCheckACL(conn, obj->def) &&
-            !virStoragePoolObjIsActive(obj))
-            nactive++;
-        virStoragePoolObjUnlock(obj);
-    }
-    storageDriverUnlock();
-
-    return nactive;
+    return virStoragePoolObjNumOfStoragePools(driver->pools, conn, false,
+                                   virConnectNumOfDefinedStoragePoolsCheckACL);
 }
 
+
 static int
 storageConnectListDefinedStoragePools(virConnectPtr conn,
                                       char **const names,
-                                      int nnames)
+                                      int maxnames)
 {
-    int got = 0;
-    size_t i;
-
     if (virConnectListDefinedStoragePoolsEnsureACL(conn) < 0)
         return -1;
 
-    storageDriverLock();
-    for (i = 0; i < driver->pools.count && got < nnames; i++) {
-        virStoragePoolObjPtr obj = driver->pools.objs[i];
-        virStoragePoolObjLock(obj);
-        if (virConnectListDefinedStoragePoolsCheckACL(conn, obj->def) &&
-            !virStoragePoolObjIsActive(obj)) {
-            if (VIR_STRDUP(names[got], obj->def->name) < 0) {
-                virStoragePoolObjUnlock(obj);
-                goto cleanup;
-            }
-            got++;
-        }
-        virStoragePoolObjUnlock(obj);
-    }
-    storageDriverUnlock();
-    return got;
-
- cleanup:
-    storageDriverUnlock();
-    for (i = 0; i < got; i++)
-        VIR_FREE(names[i]);
-    memset(names, 0, nnames * sizeof(*names));
-    return -1;
+    return virStoragePoolObjGetNames(driver->pools, conn, false,
+                                     virConnectListDefinedStoragePoolsCheckACL,
+                                     names, maxnames);
 }
 
+
 /* This method is required to be re-entrant / thread safe, so
    uses no driver lock */
 static char *
@@ -609,58 +565,46 @@ storageConnectFindStoragePoolSources(virConnectPtr conn,
 }
 
 
-static virStoragePoolObjPtr
-virStoragePoolObjFromStoragePool(virStoragePoolPtr pool)
-{
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virStoragePoolObjPtr ret;
-
-    storageDriverLock();
-    if (!(ret = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid))) {
-        virUUIDFormat(pool->uuid, uuidstr);
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching uuid '%s' (%s)"),
-                       uuidstr, pool->name);
-    }
-    storageDriverUnlock();
-
-    return ret;
-}
-
-
-static int storagePoolIsActive(virStoragePoolPtr pool)
+static int
+storagePoolIsActive(virStoragePoolPtr pool)
 {
-    virStoragePoolObjPtr obj;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     int ret = -1;
 
-    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolIsActiveEnsureACL(pool->conn, obj->def) < 0)
+    if (virStoragePoolIsActiveEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    ret = virStoragePoolObjIsActive(obj);
+    ret = virPoolObjIsActive(obj);
 
  cleanup:
-    virStoragePoolObjUnlock(obj);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
-static int storagePoolIsPersistent(virStoragePoolPtr pool)
+
+static int
+storagePoolIsPersistent(virStoragePoolPtr pool)
 {
-    virStoragePoolObjPtr obj;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     int ret = -1;
 
-    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolIsPersistentEnsureACL(pool->conn, obj->def) < 0)
+    if (virStoragePoolIsPersistentEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    ret = obj->configFile ? 1 : 0;
+    ret = virStoragePoolObjPrivateGetConfigFile(obj) ? 1 : 0;
 
  cleanup:
-    virStoragePoolObjUnlock(obj);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -671,7 +615,8 @@ storagePoolCreateXML(virConnectPtr conn,
                      unsigned int flags)
 {
     virStoragePoolDefPtr def;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr obj = NULL;
+    virStoragePoolDefPtr pooldef;
     virStoragePoolPtr ret = NULL;
     virStorageBackendPtr backend;
     virObjectEventPtr event = NULL;
@@ -685,25 +630,24 @@ storagePoolCreateXML(virConnectPtr conn,
     VIR_EXCLUSIVE_FLAGS_RET(VIR_STORAGE_POOL_BUILD_OVERWRITE,
                             VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, NULL);
 
-    storageDriverLock();
     if (!(def = virStoragePoolDefParseString(xml)))
-        goto cleanup;
+        return NULL;
 
     if (virStoragePoolCreateXMLEnsureACL(conn, def) < 0)
         goto cleanup;
 
-    if (virStoragePoolObjIsDuplicate(&driver->pools, def, 1) < 0)
+    if (virStoragePoolObjIsDuplicate(driver->pools, def, 1) < 0)
         goto cleanup;
 
-    if (virStoragePoolSourceFindDuplicate(conn, &driver->pools, def) < 0)
+    if (virStoragePoolObjFindDuplicate(driver->pools, conn, def))
         goto cleanup;
 
     if ((backend = virStorageBackendForType(def->type)) == NULL)
         goto cleanup;
 
-    if (!(pool = virStoragePoolObjAssignDef(&driver->pools, def)))
+    if (!(obj = virStoragePoolObjAdd(driver->pools, def)))
         goto cleanup;
-    def = NULL;
+    VIR_STEAL_PTR(pooldef, def);
 
     if (backend->buildPool) {
         if (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE)
@@ -713,73 +657,67 @@ 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) {
+                virPoolObjTableRemove(driver->pools, &obj);
                 goto cleanup;
             }
         }
     }
 
     if (backend->startPool &&
-        backend->startPool(conn, pool) < 0) {
-        virStoragePoolObjRemove(&driver->pools, pool);
-        pool = NULL;
+        backend->startPool(conn, obj) < 0) {
+        virPoolObjTableRemove(driver->pools, &obj);
         goto cleanup;
     }
 
-    stateFile = virFileBuildPath(driver->stateDir,
-                                 pool->def->name, ".xml");
+    stateFile = virFileBuildPath(driver->stateDir, pooldef->name, ".xml");
 
-    virStoragePoolObjClearVols(pool);
-    if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
-        backend->refreshPool(conn, pool) < 0) {
+    virStoragePoolObjClearVols(obj);
+    if (!stateFile || virStoragePoolSaveState(stateFile, pooldef) < 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);
+        virPoolObjTableRemove(driver->pools, &obj);
         goto cleanup;
     }
 
-    event = virStoragePoolEventLifecycleNew(pool->def->name,
-                                            pool->def->uuid,
+    event = virStoragePoolEventLifecycleNew(pooldef->name,
+                                            pooldef->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'", pooldef->name);
+    virPoolObjSetActive(obj, true);
 
-    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(conn, pooldef->name, pooldef->uuid, NULL, NULL);
 
  cleanup:
     VIR_FREE(stateFile);
     virStoragePoolDefFree(def);
     if (event)
         virObjectEventStateQueue(driver->storageEventState, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    storageDriverUnlock();
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static virStoragePoolPtr
 storagePoolDefineXML(virConnectPtr conn,
                      const char *xml,
                      unsigned int flags)
 {
     virStoragePoolDefPtr def;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr obj = NULL;
+    virStoragePoolDefPtr pooldef;
     virStoragePoolPtr ret = NULL;
     virObjectEventPtr event = NULL;
 
     virCheckFlags(0, NULL);
 
-    storageDriverLock();
     if (!(def = virStoragePoolDefParseString(xml)))
-        goto cleanup;
+        return NULL;
 
     if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
         goto cleanup;
@@ -787,117 +725,95 @@ storagePoolDefineXML(virConnectPtr conn,
     if (virStoragePoolDefineXMLEnsureACL(conn, def) < 0)
         goto cleanup;
 
-    if (virStoragePoolObjIsDuplicate(&driver->pools, def, 0) < 0)
+    if (virStoragePoolObjIsDuplicate(driver->pools, def, 0) < 0)
         goto cleanup;
 
-    if (virStoragePoolSourceFindDuplicate(conn, &driver->pools, def) < 0)
+    if (virStoragePoolObjFindDuplicate(driver->pools, conn, def))
         goto cleanup;
 
     if (virStorageBackendForType(def->type) == NULL)
         goto cleanup;
 
-    if (!(pool = virStoragePoolObjAssignDef(&driver->pools, def)))
+    if (!(obj = virStoragePoolObjAdd(driver->pools, def)))
         goto cleanup;
+    VIR_STEAL_PTR(pooldef, def);
 
-    if (virStoragePoolObjSaveDef(driver, pool, def) < 0) {
-        virStoragePoolObjRemove(&driver->pools, pool);
-        def = NULL;
-        pool = NULL;
+    if (virStoragePoolObjSaveDef(driver, obj) < 0) {
+        virPoolObjTableRemove(driver->pools, &obj);
         goto cleanup;
     }
 
-    event = virStoragePoolEventLifecycleNew(def->name, def->uuid,
+    event = virStoragePoolEventLifecycleNew(pooldef->name, pooldef->uuid,
                                             VIR_STORAGE_POOL_EVENT_DEFINED,
                                             0);
 
-    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'", pooldef->name);
+    ret = virGetStoragePool(conn, pooldef->name, pooldef->uuid, NULL, NULL);
 
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->storageEventState, event);
     virStoragePoolDefFree(def);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    storageDriverUnlock();
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
-storagePoolUndefine(virStoragePoolPtr obj)
+storagePoolUndefine(virStoragePoolPtr pool)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virObjectEventPtr event = NULL;
     int ret = -1;
 
-    storageDriverLock();
-    if (!(pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid))) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(obj->uuid, uuidstr);
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching uuid '%s' (%s)"),
-                       uuidstr, obj->name);
-        goto cleanup;
-    }
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
+        return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolUndefineEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolUndefineEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if (virStoragePoolObjIsActive(pool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is still active"),
-                       pool->def->name);
+                       def->name);
         goto cleanup;
     }
 
-    if (pool->asyncjobs > 0) {
+    if (virStoragePoolObjPrivateGetAsyncjobs(obj) > 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("pool '%s' has asynchronous jobs running."),
-                       pool->def->name);
+                       def->name);
         goto cleanup;
     }
 
-    if (virStoragePoolObjDeleteDef(pool) < 0)
+    if (virStoragePoolObjDeleteDef(obj) < 0)
         goto cleanup;
 
-    if (unlink(pool->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)));
-    }
-
-    VIR_FREE(pool->configFile);
-    VIR_FREE(pool->autostartLink);
-
-    event = virStoragePoolEventLifecycleNew(pool->def->name,
-                                            pool->def->uuid,
+    event = virStoragePoolEventLifecycleNew(def->name,
+                                            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'", def->name);
+    virPoolObjTableRemove(driver->pools, &obj);
     ret = 0;
 
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->storageEventState, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    storageDriverUnlock();
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
-storagePoolCreate(virStoragePoolPtr obj,
+storagePoolCreate(virStoragePoolPtr pool,
                   unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStorageBackendPtr backend;
     virObjectEventPtr event = NULL;
     int ret = -1;
@@ -911,19 +827,20 @@ 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 = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolCreateEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolCreateEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
+    if ((backend = virStorageBackendForType(def->type)) == NULL)
         goto cleanup;
 
-    if (virStoragePoolObjIsActive(pool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is already active"),
-                       pool->def->name);
+                       def->name);
         goto cleanup;
     }
 
@@ -935,199 +852,190 @@ 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'", 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");
+    stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml");
 
-    virStoragePoolObjClearVols(pool);
-    if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
-        backend->refreshPool(obj->conn, pool) < 0) {
+    virStoragePoolObjClearVols(obj);
+    if (!stateFile || virStoragePoolSaveState(stateFile, 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(def->name,
+                                            def->uuid,
                                             VIR_STORAGE_POOL_EVENT_STARTED,
                                             0);
 
-    pool->active = true;
+    virPoolObjSetActive(obj, true);
     ret = 0;
 
  cleanup:
     VIR_FREE(stateFile);
     if (event)
         virObjectEventStateQueue(driver->storageEventState, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
-storagePoolBuild(virStoragePoolPtr obj,
+storagePoolBuild(virStoragePoolPtr pool,
                  unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStorageBackendPtr backend;
     int ret = -1;
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolBuildEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolBuildEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
+    if ((backend = virStorageBackendForType(def->type)) == NULL)
         goto cleanup;
 
-    if (virStoragePoolObjIsActive(pool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is already active"),
-                       pool->def->name);
+                       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);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
 
 static int
-storagePoolDestroy(virStoragePoolPtr obj)
+storagePoolDestroy(virStoragePoolPtr pool)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
+    virStoragePoolDefPtr newDef;
     virStorageBackendPtr backend;
     virObjectEventPtr event = NULL;
     char *stateFile = NULL;
     int ret = -1;
 
-    storageDriverLock();
-    if (!(pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid))) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(obj->uuid, uuidstr);
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching uuid '%s' (%s)"),
-                       uuidstr, obj->name);
-        goto cleanup;
-    }
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
+        return -1;
+    def = virPoolObjGetDef(obj);
+    newDef = virPoolObjGetNewDef(obj);
 
-    if (virStoragePoolDestroyEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolDestroyEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
+    if ((backend = virStorageBackendForType(def->type)) == NULL)
         goto cleanup;
 
-    VIR_INFO("Destroying storage pool '%s'", pool->def->name);
+    VIR_INFO("Destroying storage pool '%s'", def->name);
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), pool->def->name);
+                       _("storage pool '%s' is not active"), def->name);
         goto cleanup;
     }
 
-    if (pool->asyncjobs > 0) {
+    if (virStoragePoolObjPrivateGetAsyncjobs(obj) > 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("pool '%s' has asynchronous jobs running."),
-                       pool->def->name);
+                       def->name);
         goto cleanup;
     }
 
-    if (!(stateFile = virFileBuildPath(driver->stateDir,
-                                       pool->def->name,
-                                       ".xml")))
+    if (!(stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml")))
         goto cleanup;
 
     unlink(stateFile);
     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(def->name,
+                                            def->uuid,
                                             VIR_STORAGE_POOL_EVENT_STOPPED,
                                             0);
 
-    pool->active = false;
+    virPoolObjSetActive(obj, false);
 
-    if (pool->configFile == NULL) {
-        virStoragePoolObjRemove(&driver->pools, pool);
-        pool = NULL;
-    } else if (pool->newDef) {
-        virStoragePoolDefFree(pool->def);
-        pool->def = pool->newDef;
-        pool->newDef = NULL;
-    }
+    if (!virStoragePoolObjPrivateGetConfigFile(obj))
+        virPoolObjTableRemove(driver->pools, &obj);
+    else if (newDef)
+        virPoolObjSetDef(obj, newDef);
 
     ret = 0;
 
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->storageEventState, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    storageDriverUnlock();
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
-storagePoolDelete(virStoragePoolPtr obj,
+storagePoolDelete(virStoragePoolPtr pool,
                   unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStorageBackendPtr backend;
     char *stateFile = NULL;
     int ret = -1;
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolDeleteEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolDeleteEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
+    if ((backend = virStorageBackendForType(def->type)) == NULL)
         goto cleanup;
 
-    VIR_INFO("Deleting storage pool '%s'", pool->def->name);
+    VIR_INFO("Deleting storage pool '%s'", def->name);
 
-    if (virStoragePoolObjIsActive(pool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is still active"),
-                       pool->def->name);
+                       def->name);
         goto cleanup;
     }
 
-    if (pool->asyncjobs > 0) {
+    if (virStoragePoolObjPrivateGetAsyncjobs(obj) > 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("pool '%s' has asynchronous jobs running."),
-                              pool->def->name);
+                       def->name);
         goto cleanup;
     }
 
-    if (!(stateFile = virFileBuildPath(driver->stateDir,
-                                       pool->def->name,
-                                       ".xml")))
+    if (!(stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml")))
         goto cleanup;
 
     unlink(stateFile);
@@ -1138,204 +1046,200 @@ 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);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
 
 static int
-storagePoolRefresh(virStoragePoolPtr obj,
+storagePoolRefresh(virStoragePoolPtr pool,
                    unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStorageBackendPtr backend;
     int ret = -1;
     virObjectEventPtr event = NULL;
 
     virCheckFlags(0, -1);
 
-    storageDriverLock();
-    if (!(pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid))) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(obj->uuid, uuidstr);
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching uuid '%s' (%s)"),
-                       uuidstr, obj->name);
-        goto cleanup;
-    }
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
+        return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolRefreshEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolRefreshEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
+    if ((backend = virStorageBackendForType(def->type)) == NULL)
         goto cleanup;
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), pool->def->name);
+                       _("storage pool '%s' is not active"), def->name);
         goto cleanup;
     }
 
-    if (pool->asyncjobs > 0) {
+    if (virStoragePoolObjPrivateGetAsyncjobs(obj) > 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("pool '%s' has asynchronous jobs running."),
-                       pool->def->name);
+                       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(def->name,
+                                                def->uuid,
                                                 VIR_STORAGE_POOL_EVENT_STOPPED,
                                                 0);
-        pool->active = false;
+        virPoolObjSetActive(obj, false);
 
-        if (pool->configFile == NULL) {
-            virStoragePoolObjRemove(&driver->pools, pool);
-            pool = NULL;
-        }
+        if (!virStoragePoolObjPrivateGetConfigFile(obj))
+            virPoolObjTableRemove(driver->pools, &obj);
         goto cleanup;
     }
 
-    event = virStoragePoolEventRefreshNew(pool->def->name,
-                                          pool->def->uuid);
+    event = virStoragePoolEventRefreshNew(def->name, def->uuid);
     ret = 0;
 
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->storageEventState, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    storageDriverUnlock();
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
 
 static int
-storagePoolGetInfo(virStoragePoolPtr obj,
+storagePoolGetInfo(virStoragePoolPtr pool,
                    virStoragePoolInfoPtr info)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     int ret = -1;
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolGetInfoEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolGetInfoEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if (virStorageBackendForType(pool->def->type) == NULL)
+    if (virStorageBackendForType(def->type) == NULL)
         goto cleanup;
 
     memset(info, 0, sizeof(virStoragePoolInfo));
-    if (pool->active)
+    if (virPoolObjIsActive(obj))
         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 = def->capacity;
+    info->allocation = def->allocation;
+    info->available = def->available;
     ret = 0;
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static char *
-storagePoolGetXMLDesc(virStoragePoolPtr obj,
+storagePoolGetXMLDesc(virStoragePoolPtr pool,
                       unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
     virStoragePoolDefPtr def;
+    virStoragePoolDefPtr newDef;
     char *ret = NULL;
 
     virCheckFlags(VIR_STORAGE_XML_INACTIVE, NULL);
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return NULL;
+    def = virPoolObjGetDef(obj);
+    newDef = virPoolObjGetNewDef(obj);
 
-    if (virStoragePoolGetXMLDescEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolGetXMLDescEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if ((flags & VIR_STORAGE_XML_INACTIVE) && pool->newDef)
-        def = pool->newDef;
-    else
-        def = pool->def;
+    if ((flags & VIR_STORAGE_XML_INACTIVE) && newDef)
+        def = newDef;
 
     ret = virStoragePoolDefFormat(def);
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
-storagePoolGetAutostart(virStoragePoolPtr obj,
+storagePoolGetAutostart(virStoragePoolPtr pool,
                         int *autostart)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     int ret = -1;
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (virStoragePoolGetAutostartEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolGetAutostartEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if (!pool->configFile) {
-        *autostart = 0;
-    } else {
-        *autostart = pool->autostart;
-    }
+    *autostart = 0;
+    if (virStoragePoolObjPrivateGetConfigFile(obj) &&
+        virPoolObjIsAutostart(obj))
+        *autostart = 1;
+
     ret = 0;
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
-storagePoolSetAutostart(virStoragePoolPtr obj,
-                        int autostart)
+storagePoolSetAutostart(virStoragePoolPtr pool,
+                        int new_autostart)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
+    bool autostart;
+    const char *configFile;
     int ret = -1;
 
-    storageDriverLock();
-    pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
-
-    if (!pool) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(obj->uuid, uuidstr);
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching uuid '%s' (%s)"),
-                       uuidstr, obj->name);
-        goto cleanup;
-    }
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
+        return -1;
+    def = virPoolObjGetDef(obj);
+    configFile = virStoragePoolObjPrivateGetConfigFile(obj);
 
-    if (virStoragePoolSetAutostartEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolSetAutostartEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if (!pool->configFile) {
+    if (!configFile) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("pool has no config file"));
         goto cleanup;
     }
 
-    autostart = (autostart != 0);
+    autostart = (new_autostart != 0);
 
-    if (pool->autostart != autostart) {
+    if (virPoolObjIsAutostart(obj) != autostart) {
+        const char *autostartLink =
+            virStoragePoolObjPrivateGetAutostartLink(obj);
         if (autostart) {
             if (virFileMakePath(driver->autostartDir) < 0) {
                 virReportSystemError(errno,
@@ -1344,47 +1248,50 @@ storagePoolSetAutostart(virStoragePoolPtr obj,
                 goto cleanup;
             }
 
-            if (symlink(pool->configFile, pool->autostartLink) < 0) {
+            if (symlink(configFile, autostartLink) < 0) {
                 virReportSystemError(errno,
                                      _("Failed to create symlink '%s' to '%s'"),
-                                     pool->autostartLink, pool->configFile);
+                                     autostartLink, configFile);
                 goto cleanup;
             }
         } else {
-            if (unlink(pool->autostartLink) < 0 &&
+            if (unlink(autostartLink) < 0 &&
                 errno != ENOENT && errno != ENOTDIR) {
                 virReportSystemError(errno,
                                      _("Failed to delete symlink '%s'"),
-                                     pool->autostartLink);
+                                     autostartLink);
                 goto cleanup;
             }
         }
-        pool->autostart = autostart;
+        virPoolObjSetAutostart(obj, autostart);
     }
     ret = 0;
 
  cleanup:
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    storageDriverUnlock();
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
-storagePoolNumOfVolumes(virStoragePoolPtr obj)
+storagePoolNumOfVolumes(virStoragePoolPtr pool)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
+    virPoolObjTablePtr objvolumes;
     int ret = -1;
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
+    objvolumes = virStoragePoolObjPrivateGetVolumes(obj);
 
-    if (virStoragePoolNumOfVolumesEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolNumOfVolumesEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), pool->def->name);
+                       _("storage pool '%s' is not active"), def->name);
         goto cleanup;
     }
 
@@ -1392,34 +1299,38 @@ storagePoolNumOfVolumes(virStoragePoolPtr obj)
      * function requires 3 instead of 2 params for virPoolObjACLFilter.
      * Setting up this way fulfills check-aclrules.pl's check that the
      * driver function calls the CheckACL API */
-    ret = virStoragePoolObjNumOfVolumes(pool->volumes, obj->conn, pool->def,
+    ret = virStoragePoolObjNumOfVolumes(objvolumes, pool->conn, def,
                                         virStoragePoolNumOfVolumesCheckACL);
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
 
 static int
-storagePoolListVolumes(virStoragePoolPtr obj,
+storagePoolListVolumes(virStoragePoolPtr pool,
                        char **const names,
                        int maxnames)
 {
     int ret = -1;
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
+    virPoolObjTablePtr objvolumes;
 
     memset(names, 0, maxnames * sizeof(*names));
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
+    objvolumes = virStoragePoolObjPrivateGetVolumes(obj);
 
-    if (virStoragePoolListVolumesEnsureACL(obj->conn, pool->def) < 0)
+    if (virStoragePoolListVolumesEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), pool->def->name);
+                       _("storage pool '%s' is not active"), def->name);
         goto cleanup;
     }
 
@@ -1427,12 +1338,12 @@ storagePoolListVolumes(virStoragePoolPtr obj,
      * function requires 3 instead of 2 params for virPoolObjACLFilter.
      * Setting up this way fulfills check-aclrules.pl's check that the
      * driver function calls the CheckACL API */
-    ret = virStoragePoolObjListVolumes(pool->volumes, obj->conn, pool->def,
+    ret = virStoragePoolObjListVolumes(objvolumes, pool->conn, def,
                                        virStoragePoolListVolumesCheckACL,
                                        names, maxnames);
 
  cleanup:
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -1442,7 +1353,9 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
                           virStorageVolPtr **volumes,
                           unsigned int flags)
 {
-    virStoragePoolObjPtr obj;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
+    virPoolObjTablePtr objvolumes;
     virPoolObjPtr *volobjs = NULL;
     size_t nvolobjs = 0;
     size_t i;
@@ -1452,19 +1365,21 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
 
     virCheckFlags(0, -1);
 
-    if (!(obj = virStoragePoolObjFromStoragePool(pool)))
+    if (!(obj = storagePoolObjFromStoragePool(pool)))
         return -1;
+    def = virPoolObjGetDef(obj);
+    objvolumes = virStoragePoolObjPrivateGetVolumes(obj);
 
-    if (virStoragePoolListAllVolumesEnsureACL(pool->conn, obj->def) < 0)
+    if (virStoragePoolListAllVolumesEnsureACL(pool->conn, def) < 0)
         goto cleanup;
 
-    if (!virStoragePoolObjIsActive(obj)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), obj->def->name);
+                       _("storage pool '%s' is not active"), def->name);
         goto cleanup;
     }
 
-    if (virPoolObjTableCollect(obj->volumes, pool->conn, &volobjs, &nvolobjs,
+    if (virPoolObjTableCollect(objvolumes, pool->conn, &volobjs, &nvolobjs,
                                NULL, NULL, flags) < 0)
         goto cleanup;
 
@@ -1475,16 +1390,15 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
         for (i = 0; i < nvolobjs; i++) {
             bool passacl = false;
             virPoolObjPtr volobj = volobjs[i];
-            virStorageVolDefPtr def;
+            virStorageVolDefPtr voldef;
 
             virObjectLock(volobj);
-            def = virPoolObjGetDef(volobj);
+            voldef = virPoolObjGetDef(volobj);
             /* NB: Cannot call ACL filter in Collect function since it
              * takes 3 params and the volume ACL filter requires 3 */
-            if (virStoragePoolListAllVolumesCheckACL(pool->conn, obj->def,
-                                                     obj)) {
-                vols[nvols++] = virGetStorageVol(pool->conn, obj->def->name,
-                                                 def->name, def->key,
+            if (virStoragePoolListAllVolumesCheckACL(pool->conn, def, obj)) {
+                vols[nvols++] = virGetStorageVol(pool->conn, def->name,
+                                                 voldef->name, voldef->key,
                                                  NULL, NULL);
                 passacl = true;
             }
@@ -1503,28 +1417,32 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
  cleanup:
     virObjectListFree(vols);
     virObjectListFreeCount(volobjs, nvolobjs);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static virStorageVolPtr
-storageVolLookupByName(virStoragePoolPtr obj,
+storageVolLookupByName(virStoragePoolPtr pool,
                        const char *name)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef;
     virStorageVolPtr ret = NULL;
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(poolobj = storagePoolObjFromStoragePool(pool)))
         return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), pool->def->name);
+                       _("storage pool '%s' is not active"), pooldef->name);
         goto cleanup;
     }
 
-    if (!(volobj = virStorageVolObjFindByName(pool, name))) {
+    if (!(volobj = virStorageVolObjFindByName(poolobj, name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        name);
@@ -1532,89 +1450,99 @@ storageVolLookupByName(virStoragePoolPtr obj,
     }
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolLookupByNameEnsureACL(obj->conn, pool->def, voldef) < 0)
+    if (virStorageVolLookupByNameEnsureACL(pool->conn, pooldef, voldef) < 0)
         goto cleanup;
 
-    ret = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
-                           voldef->key, NULL, NULL);
+    ret = virGetStorageVol(pool->conn, pooldef->name, voldef->name, voldef->key,
+                           NULL, NULL);
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
 
+/* NB: Cannot use the "real" name since check-aclrules.pl will get confused */
+typedef int (*ensureFilter)(virConnectPtr conn,
+                            virStoragePoolDefPtr pool,
+                            void *opaque);
+struct storageSearchData {
+    virConnectPtr conn;
+    ensureFilter aclfilter;
+    const char *key;
+    const char *path;
+    char *retname;
+    char *retkey;
+};
+
+static bool
+storageVolSearchByKey(virPoolObjPtr obj,
+                      void *opaque)
+{
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    struct storageSearchData *data = opaque;
+
+    if (virPoolObjIsActive(obj)) {
+        virPoolObjPtr volobj;
+
+        if ((volobj = virStorageVolObjFindByKey(obj, data->key))) {
+            virStorageVolDefPtr voldef = virPoolObjGetDef(volobj);
+
+            if (data->aclfilter(data->conn, def, voldef) == 0)
+                ignore_value(VIR_STRDUP(data->retname, def->name));
+            virPoolObjEndAPI(&volobj);
+        }
+
+        if (data->retname)
+            return true;
+    }
+
+    return false;
+}
+
+
 static virStorageVolPtr
 storageVolLookupByKey(virConnectPtr conn,
                       const char *key)
 {
-    size_t i;
     virStorageVolPtr ret = NULL;
+    virPoolObjPtr obj;
+    struct storageSearchData data =
+           { .conn = conn,
+             .aclfilter = virStorageVolLookupByKeyEnsureACL,
+             .key = key,
+             .retname = NULL };
 
-    storageDriverLock();
-    for (i = 0; i < driver->pools.count && !ret; i++) {
-        virStoragePoolObjLock(driver->pools.objs[i]);
-        if (virStoragePoolObjIsActive(driver->pools.objs[i])) {
-            virPoolObjPtr volobj;
-
-            if ((volobj = virStorageVolObjFindByKey(driver->pools.objs[i],
-                                                    key))) {
-                virStoragePoolDefPtr def = driver->pools.objs[i]->def;
-                virStorageVolDefPtr voldef = virPoolObjGetDef(volobj);
-
-                if (virStorageVolLookupByKeyEnsureACL(conn, def, voldef) < 0) {
-                    virPoolObjEndAPI(&volobj);
-                    virStoragePoolObjUnlock(driver->pools.objs[i]);
-                    goto cleanup;
-                }
+    if ((obj = virPoolObjTableSearchRef(driver->pools, storageVolSearchByKey,
+                                        &data))) {
+        virStoragePoolDefPtr def = virPoolObjGetDef(obj);
 
-                ret = virGetStorageVol(conn,
-                                       def->name,
-                                       voldef->name,
-                                       voldef->key,
-                                       NULL, NULL);
-                virPoolObjEndAPI(&volobj);
-            }
-        }
-        virStoragePoolObjUnlock(driver->pools.objs[i]);
+        ret = virGetStorageVol(conn, def->name, data.retname, key, NULL, NULL);
+        VIR_FREE(data.retname);
+        virPoolObjEndAPI(&obj);
     }
 
     if (!ret)
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching key %s"), key);
 
- cleanup:
-    storageDriverUnlock();
     return ret;
 }
 
-static virStorageVolPtr
-storageVolLookupByPath(virConnectPtr conn,
-                       const char *path)
-{
-    size_t i;
-    virStorageVolPtr ret = NULL;
-    char *cleanpath;
 
-    cleanpath = virFileSanitizePath(path);
-    if (!cleanpath)
-        return NULL;
+static bool
+storageVolSearchByPath(virPoolObjPtr obj,
+                       void *opaque)
+{
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(obj);
+    struct storageSearchData *data = opaque;
 
-    storageDriverLock();
-    for (i = 0; i < driver->pools.count && !ret; i++) {
-        virStoragePoolObjPtr pool = driver->pools.objs[i];
-        virPoolObjPtr volobj = NULL;
+    if (virPoolObjIsActive(obj)) {
+        virPoolObjPtr volobj;
         char *stable_path = NULL;
 
-        virStoragePoolObjLock(pool);
-
-        if (!virStoragePoolObjIsActive(pool)) {
-           virStoragePoolObjUnlock(pool);
-           continue;
-        }
-
-        switch ((virStoragePoolType) pool->def->type) {
+        switch ((virStoragePoolType) pooldef->type) {
             case VIR_STORAGE_POOL_DIR:
             case VIR_STORAGE_POOL_FS:
             case VIR_STORAGE_POOL_NETFS:
@@ -1624,17 +1552,14 @@ storageVolLookupByPath(virConnectPtr conn,
             case VIR_STORAGE_POOL_SCSI:
             case VIR_STORAGE_POOL_MPATH:
             case VIR_STORAGE_POOL_VSTORAGE:
-                stable_path = virStorageBackendStablePath(pool,
-                                                          cleanpath,
-                                                          false);
-                if (stable_path == NULL) {
+                if (!(stable_path = virStorageBackendStablePath(obj, data->path,
+                                                                false))) {
                     /* Don't break the whole lookup process if it fails on
                      * getting the stable path for some of the pools.
                      */
                     VIR_WARN("Failed to get stable path for pool '%s'",
-                             pool->def->name);
-                    virStoragePoolObjUnlock(pool);
-                    continue;
+                             pooldef->name);
+                    return false;
                 }
                 break;
 
@@ -1643,32 +1568,57 @@ storageVolLookupByPath(virConnectPtr conn,
             case VIR_STORAGE_POOL_SHEEPDOG:
             case VIR_STORAGE_POOL_ZFS:
             case VIR_STORAGE_POOL_LAST:
-                if (VIR_STRDUP(stable_path, path) < 0) {
-                     virStoragePoolObjUnlock(pool);
-                    goto cleanup;
-                }
+                if (VIR_STRDUP(stable_path, data->path) < 0)
+                    return false;
                 break;
         }
 
-        volobj = virStorageVolObjFindByPath(pool, stable_path);
-        VIR_FREE(stable_path);
-
-        if (volobj) {
+        if ((volobj = virStorageVolObjFindByPath(obj, stable_path))) {
             virStorageVolDefPtr voldef = virPoolObjGetDef(volobj);
-            if (virStorageVolLookupByPathEnsureACL(conn, pool->def,
-                                                   voldef) < 0) {
-                virPoolObjEndAPI(&volobj);
-                virStoragePoolObjUnlock(pool);
-                goto cleanup;
-            }
 
-            ret = virGetStorageVol(conn, pool->def->name,
-                                   voldef->name, voldef->key,
-                                   NULL, NULL);
+            if (data->aclfilter(data->conn, pooldef, voldef) == 0) {
+                ignore_value(VIR_STRDUP(data->retname, voldef->name));
+                ignore_value(VIR_STRDUP(data->retkey, voldef->key));
+            }
             virPoolObjEndAPI(&volobj);
         }
 
-        virStoragePoolObjUnlock(pool);
+        if (data->retname && data->retkey)
+            return true;
+
+        VIR_FREE(data->retname);
+        VIR_FREE(data->retkey);
+    }
+
+    return false;
+}
+
+
+static virStorageVolPtr
+storageVolLookupByPath(virConnectPtr conn,
+                       const char *path)
+{
+    virStorageVolPtr ret = NULL;
+    virPoolObjPtr obj;
+    struct storageSearchData data =
+           { .conn = conn,
+             .aclfilter = virStorageVolLookupByPathEnsureACL,
+             .retname = NULL,
+             .retkey = NULL };
+    char *cleanpath;
+
+    if (!(cleanpath = virFileSanitizePath(path)))
+        return NULL;
+    data.path = cleanpath;
+
+    if ((obj = virPoolObjTableSearchRef(driver->pools, storageVolSearchByPath,
+                                        &data))) {
+        virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+        ret = virGetStorageVol(conn, def->name, data.retname, data.retkey,
+                               NULL, NULL);
+        VIR_FREE(data.retname);
+        VIR_FREE(data.retkey);
+        virPoolObjEndAPI(&obj);
     }
 
     if (!ret) {
@@ -1682,43 +1632,49 @@ storageVolLookupByPath(virConnectPtr conn,
         }
     }
 
- cleanup:
     VIR_FREE(cleanpath);
-    storageDriverUnlock();
     return ret;
 }
 
+
+static bool
+storagePoolSearchByTargetPath(virPoolObjPtr obj,
+                              void *opaque)
+{
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+    struct storageSearchData *data = opaque;
+
+    if (virPoolObjIsActive(obj)) {
+        if (STREQ(data->path, def->target.path))
+            return true;
+    }
+
+    return false;
+}
+
+
 virStoragePoolPtr
 storagePoolLookupByTargetPath(virConnectPtr conn,
                               const char *path)
 {
-    size_t i;
     virStoragePoolPtr ret = NULL;
+    virPoolObjPtr obj;
+    struct storageSearchData data = { 0 };
     char *cleanpath;
 
-    cleanpath = virFileSanitizePath(path);
-    if (!cleanpath)
+    if (!(cleanpath = virFileSanitizePath(path)))
         return NULL;
+    data.path = cleanpath;
 
-    storageDriverLock();
-    for (i = 0; i < driver->pools.count && !ret; i++) {
-        virStoragePoolObjPtr pool = driver->pools.objs[i];
-
-        virStoragePoolObjLock(pool);
-
-        if (!virStoragePoolObjIsActive(pool)) {
-            virStoragePoolObjUnlock(pool);
-            continue;
-        }
+    if ((obj = virPoolObjTableSearchRef(driver->pools,
+                                        storagePoolSearchByTargetPath,
+                                        &data))) {
+        virStoragePoolDefPtr def = virPoolObjGetDef(obj);
 
-        if (STREQ(path, pool->def->target.path)) {
-            ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                                    NULL, NULL);
-        }
-
-        virStoragePoolObjUnlock(pool);
+        ret = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
+        virPoolObjEndAPI(&obj);
     }
-    storageDriverUnlock();
+
 
     if (!ret) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
@@ -1732,35 +1688,28 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
 
 
 static void
-storageVolRemoveFromPool(virStoragePoolObjPtr pool,
-                         virStorageVolDefPtr vol)
+storageVolRemoveFromPool(virPoolObjPtr poolobj,
+                         virPoolObjPtr *volobj)
 {
-    virPoolObjPtr obj;
-
-    if (!(obj = virPoolObjTableFindByName(pool->volumes, vol->name))) {
-        virReportError(VIR_ERR_NO_STORAGE_VOL,
-                       _("no storage vol with matching name '%s'"),
-                       vol->name);
-        return;
-    }
+    virStorageVolDefPtr voldef = virPoolObjGetDef(*volobj);
 
     VIR_INFO("Deleting volume '%s' from storage pool '%s'",
-              vol->name, pool->def->name);
-
-    virStoragePoolObjRemoveVolume(pool, &obj);
+              voldef->name, voldef->name);
 
-    virPoolObjEndAPI(&obj);
+    virStoragePoolObjRemoveVolume(poolobj, volobj);
 }
 
 
 static int
-storageVolDeleteInternal(virStorageVolPtr obj,
+storageVolDeleteInternal(virStorageVolPtr volume,
                          virStorageBackendPtr backend,
-                         virStoragePoolObjPtr pool,
-                         virStorageVolDefPtr vol,
+                         virPoolObjPtr poolobj,
+                         virPoolObjPtr *volobj,
                          unsigned int flags,
                          bool updateMeta)
 {
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(poolobj);
+    virStorageVolDefPtr voldef = virPoolObjGetDef(*volobj);
     int ret = -1;
 
     if (!backend->deleteVol) {
@@ -1770,7 +1719,7 @@ storageVolDeleteInternal(virStorageVolPtr obj,
         goto cleanup;
     }
 
-    if (backend->deleteVol(obj->conn, pool, vol, flags) < 0)
+    if (backend->deleteVol(volume->conn, poolobj, voldef, flags) < 0)
         goto cleanup;
 
     /* Update pool metadata - don't update meta data from error paths
@@ -1778,13 +1727,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 (pooldef->type != VIR_STORAGE_POOL_DISK) {
+            pooldef->allocation -= voldef->target.allocation;
+            pooldef->available += voldef->target.allocation;
         }
     }
 
-    storageVolRemoveFromPool(pool, vol);
+    storageVolRemoveFromPool(poolobj, volobj);
     ret = 0;
 
  cleanup:
@@ -1794,32 +1743,27 @@ storageVolDeleteInternal(virStorageVolPtr obj,
 
 static virPoolObjPtr
 virStorageVolObjFromVol(virStorageVolPtr volume,
-                        virStoragePoolObjPtr *pool,
+                        virPoolObjPtr *pool,
                         virStorageBackendPtr *backend)
 {
-    virPoolObjPtr volobj = NULL;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
+    virPoolObjPtr volobj;
 
     *pool = NULL;
 
-    storageDriverLock();
-    *pool = virStoragePoolObjFindByName(&driver->pools, volume->pool);
-    storageDriverUnlock();
-
-    if (!*pool) {
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching name '%s'"),
-                       volume->pool);
+    if (!(poolobj = storagePoolObjFindByName(volume->pool)))
         return NULL;
-    }
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (!virStoragePoolObjIsActive(*pool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"),
-                       (*pool)->def->name);
+                       pooldef->name);
         goto error;
     }
 
-    if (!(volobj = virStorageVolObjFindByName(*pool, volume->name))) {
+    if (!(volobj = virStorageVolObjFindByName(poolobj, volume->name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        volume->name);
@@ -1827,15 +1771,15 @@ virStorageVolObjFromVol(virStorageVolPtr volume,
     }
 
     if (backend) {
-        if (!(*backend = virStorageBackendForType((*pool)->def->type)))
+        if (!(*backend = virStorageBackendForType(pooldef->type)))
             goto error;
     }
 
+    *pool = poolobj;
     return volobj;
 
  error:
-    virStoragePoolObjUnlock(*pool);
-    *pool = NULL;
+    virPoolObjEndAPI(&poolobj);
 
     return NULL;
 }
@@ -1845,17 +1789,19 @@ static int
 storageVolDelete(virStorageVolPtr volume,
                  unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
     virStorageBackendPtr backend;
     int ret = -1;
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, &backend)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, &backend)))
         return -1;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolDeleteEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolDeleteEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     if (voldef->in_use) {
@@ -1872,7 +1818,7 @@ storageVolDelete(virStorageVolPtr volume,
         goto cleanup;
     }
 
-    if (storageVolDeleteInternal(volume, backend, pool, voldef,
+    if (storageVolDeleteInternal(volume, backend, poolobj, &volobj,
                                  flags, true) < 0)
         goto cleanup;
 
@@ -1880,39 +1826,41 @@ storageVolDelete(virStorageVolPtr volume,
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
 
 static virStorageVolPtr
-storageVolCreateXML(virStoragePoolPtr obj,
+storageVolCreateXML(virStoragePoolPtr pool,
                     const char *xmldesc,
                     unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virStorageBackendPtr backend;
     virStorageVolDefPtr voldef = NULL;
     virStorageVolDefPtr objvoldef;
     virPoolObjPtr volobj = NULL;
-    virStorageVolPtr vol = NULL;
+    virStorageVolPtr volume = NULL;
     virStorageVolPtr ret = NULL;
 
     virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
 
-    if (!(pool = virStoragePoolObjFromStoragePool(obj)))
+    if (!(poolobj = storagePoolObjFromStoragePool(pool)))
         return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), pool->def->name);
+                       _("storage pool '%s' is not active"), pooldef->name);
         goto cleanup;
     }
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
+    if ((backend = virStorageBackendForType(pooldef->type)) == NULL)
         goto cleanup;
 
-    if (!(voldef = virStorageVolDefParseString(pool->def, xmldesc,
+    if (!(voldef = virStorageVolDefParseString(pooldef, xmldesc,
                                                VIR_VOL_XML_PARSE_OPT_CAPACITY)))
         goto cleanup;
 
@@ -1923,10 +1871,10 @@ storageVolCreateXML(virStoragePoolPtr obj,
         goto cleanup;
     }
 
-    if (virStorageVolCreateXMLEnsureACL(obj->conn, pool->def, voldef) < 0)
+    if (virStorageVolCreateXMLEnsureACL(pool->conn, pooldef, voldef) < 0)
         goto cleanup;
 
-    if ((volobj = virStorageVolObjFindByName(pool, voldef->name))) {
+    if ((volobj = virStorageVolObjFindByName(poolobj, voldef->name))) {
         virReportError(VIR_ERR_STORAGE_VOL_EXIST,
                        _("'%s'"), voldef->name);
         goto cleanup;
@@ -1942,16 +1890,16 @@ storageVolCreateXML(virStoragePoolPtr obj,
     /* 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, poolobj, voldef) < 0)
         goto cleanup;
 
-    if (!(volobj = virStoragePoolObjAddVolume(pool, voldef)))
+    if (!(volobj = virStoragePoolObjAddVolume(poolobj, voldef)))
         goto cleanup;
     VIR_STEAL_PTR(objvoldef, voldef);
 
-    if (!(vol = virGetStorageVol(obj->conn, pool->def->name, objvoldef->name,
-                                 objvoldef->key, NULL, NULL))) {
-        virStoragePoolObjRemoveVolume(pool, &volobj);
+    if (!(volume = virGetStorageVol(pool->conn, pooldef->name, objvoldef->name,
+                                    objvoldef->key, NULL, NULL))) {
+        storageVolRemoveFromPool(poolobj, &volobj);
         goto cleanup;
     }
 
@@ -1969,32 +1917,30 @@ storageVolCreateXML(virStoragePoolPtr obj,
         memcpy(buildvoldef, objvoldef, sizeof(*objvoldef));
 
         /* Drop the pool lock during volume allocation */
-        pool->asyncjobs++;
+        virStoragePoolObjPrivateIncrAsyncjobs(poolobj);
         objvoldef->building = true;
-        virStoragePoolObjUnlock(pool);
+        virObjectUnlock(volobj);
 
-        buildret = backend->buildVol(obj->conn, pool, buildvoldef, flags);
+        buildret = backend->buildVol(pool->conn, volobj, buildvoldef, flags);
 
         VIR_FREE(buildvoldef);
 
-        storageDriverLock();
-        virStoragePoolObjLock(pool);
-        storageDriverUnlock();
+        virObjectLock(volobj);
 
         objvoldef->building = false;
-        pool->asyncjobs--;
+        virStoragePoolObjPrivateDecrAsyncjobs(poolobj);
 
         if (buildret < 0) {
             /* buildVol handles deleting volume on failure */
-            storageVolRemoveFromPool(pool, objvoldef);
+            storageVolRemoveFromPool(poolobj, &volobj);
             goto cleanup;
         }
 
     }
 
     if (backend->refreshVol &&
-        backend->refreshVol(obj->conn, pool, objvoldef) < 0) {
-        storageVolDeleteInternal(vol, backend, pool, objvoldef,
+        backend->refreshVol(pool->conn, poolobj, objvoldef) < 0) {
+        storageVolDeleteInternal(volume, backend, poolobj, &volobj,
                                  0, false);
         goto cleanup;
     }
@@ -2002,32 +1948,35 @@ 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 += objvoldef->target.allocation;
-        pool->def->available -= objvoldef->target.allocation;
+    if (pooldef->type != VIR_STORAGE_POOL_DISK) {
+        pooldef->allocation += objvoldef->target.allocation;
+        pooldef->available -= objvoldef->target.allocation;
     }
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
-             vol->name, pool->def->name);
-    ret = vol;
-    vol = NULL;
+             volume->name, pooldef->name);
+    ret = volume;
+    volume = NULL;
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virObjectUnref(vol);
+    virObjectUnref(volume);
     virStorageVolDefFree(voldef);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
+
 static virStorageVolPtr
-storageVolCreateXMLFrom(virStoragePoolPtr obj,
+storageVolCreateXMLFrom(virStoragePoolPtr pool,
                         const char *xmldesc,
                         virStorageVolPtr volume,
                         unsigned int flags)
 {
-    virStoragePoolObjPtr pool, origpool = NULL;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
+    virPoolObjPtr origpoolobj = NULL;
+    virStoragePoolDefPtr origpooldef;
     virStorageBackendPtr backend;
     virPoolObjPtr newvolobj = NULL;
     virPoolObjPtr origvolobj = NULL;
@@ -2043,48 +1992,39 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
                   VIR_STORAGE_VOL_CREATE_REFLINK,
                   NULL);
 
-    storageDriverLock();
-    pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
-    if (pool && STRNEQ(obj->name, volume->pool)) {
-        virStoragePoolObjUnlock(pool);
-        origpool = virStoragePoolObjFindByName(&driver->pools, volume->pool);
-        virStoragePoolObjLock(pool);
-    }
-    storageDriverUnlock();
-    if (!pool) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(obj->uuid, uuidstr);
-        virReportError(VIR_ERR_NO_STORAGE_POOL,
-                       _("no storage pool with matching uuid '%s' (%s)"),
-                       uuidstr, obj->name);
-        goto cleanup;
-    }
+    if (!(poolobj = storagePoolObjFromStoragePool(pool)))
+        return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (STRNEQ(obj->name, volume->pool) && !origpool) {
+    if (STRNEQ(pooldef->name, volume->pool))
+        origpoolobj = storagePoolObjFindByName(volume->pool);
+
+    if (STRNEQ(pooldef->name, volume->pool) && !origpoolobj) {
         virReportError(VIR_ERR_NO_STORAGE_POOL,
                        _("no storage pool with matching name '%s'"),
                        volume->pool);
         goto cleanup;
     }
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), pool->def->name);
+                       _("storage pool '%s' is not active"), pooldef->name);
         goto cleanup;
     }
 
-    if (origpool && !virStoragePoolObjIsActive(origpool)) {
+    if (origpoolobj && !virPoolObjIsActive(origpoolobj)) {
+        origpooldef = virPoolObjGetDef(poolobj);
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"),
-                       origpool->def->name);
+                       origpooldef->name);
         goto cleanup;
     }
 
-    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
+    if ((backend = virStorageBackendForType(pooldef->type)) == NULL)
         goto cleanup;
 
-    if (!(origvolobj = virStorageVolObjFindByName(origpool ? origpool :
-                                                  pool, volume->name))) {
+    if (!(origvolobj = virStorageVolObjFindByName(origpoolobj ? origpoolobj :
+                                                  poolobj, volume->name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        volume->name);
@@ -2093,15 +2033,14 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
     origvoldef = virPoolObjGetDef(origvolobj);
 
     if (!(newvoldef =
-          virStorageVolDefParseString(pool->def, xmldesc,
+          virStorageVolDefParseString(pooldef, xmldesc,
                                       VIR_VOL_XML_PARSE_NO_CAPACITY)))
         goto cleanup;
 
-    if (virStorageVolCreateXMLFromEnsureACL(obj->conn, pool->def,
-                                            newvoldef) < 0)
+    if (virStorageVolCreateXMLFromEnsureACL(pool->conn, pooldef, newvoldef) < 0)
         goto cleanup;
 
-    if ((newvolobj = virStorageVolObjFindByName(pool, newvoldef->name))) {
+    if (virStorageVolObjFindByName(poolobj, newvoldef->name)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("storage volume name '%s' already in use."),
                        newvoldef->name);
@@ -2135,14 +2074,14 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
     }
 
     if (backend->refreshVol &&
-        backend->refreshVol(obj->conn, pool, origvoldef) < 0)
+        backend->refreshVol(pool->conn, poolobj, origvoldef) < 0)
         goto cleanup;
 
     /* 'Define' the new volume so we get async progress reporting.
      * Wipe any key the user may have suggested, as volume creation
      * will generate the canonical key.  */
     VIR_FREE(newvoldef->key);
-    if (backend->createVol(obj->conn, pool, newvoldef) < 0)
+    if (backend->createVol(pool->conn, poolobj, newvoldef) < 0)
         goto cleanup;
 
     /* Make a shallow copy of the 'defined' volume definition, since the
@@ -2154,63 +2093,58 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
 
     memcpy(shadowvoldef, newvoldef, sizeof(*newvoldef));
 
-    if (!(newvolobj = virStoragePoolObjAddVolume(pool, newvoldef)))
+    if (!(newvolobj = virStoragePoolObjAddVolume(poolobj, newvoldef)))
         goto cleanup;
     VIR_STEAL_PTR(objnewvoldef, newvoldef);
 
-    if (!(vol = virGetStorageVol(obj->conn, pool->def->name, objnewvoldef->name,
+    if (!(vol = virGetStorageVol(pool->conn, pooldef->name, objnewvoldef->name,
                                  objnewvoldef->key, NULL, NULL))) {
-        virStoragePoolObjRemoveVolume(pool, &newvolobj);
+        virStoragePoolObjRemoveVolume(poolobj, &newvolobj);
         goto cleanup;
     }
 
     /* Drop the pool lock during volume allocation */
-    pool->asyncjobs++;
+    virStoragePoolObjPrivateIncrAsyncjobs(poolobj);
     objnewvoldef->building = true;
     origvoldef->in_use++;
-    virStoragePoolObjUnlock(pool);
+    virObjectUnlock(poolobj);
 
-    if (origpool) {
-        origpool->asyncjobs++;
-        virStoragePoolObjUnlock(origpool);
+    if (origpoolobj) {
+        virStoragePoolObjPrivateIncrAsyncjobs(origpoolobj);
+        virObjectUnlock(origpoolobj);
     }
 
-    buildret = backend->buildVolFrom(obj->conn, pool, shadowvoldef,
+    buildret = backend->buildVolFrom(pool->conn, poolobj, shadowvoldef,
                                      origvoldef, flags);
 
-    storageDriverLock();
-    virStoragePoolObjLock(pool);
-    if (origpool)
-        virStoragePoolObjLock(origpool);
-    storageDriverUnlock();
+    virObjectLock(poolobj);
+    if (origpoolobj)
+        virObjectLock(origpoolobj);
 
     origvoldef->in_use--;
     objnewvoldef->building = false;
-    pool->asyncjobs--;
+    virStoragePoolObjPrivateDecrAsyncjobs(poolobj);
 
-    if (origpool) {
-        origpool->asyncjobs--;
-        virStoragePoolObjUnlock(origpool);
-        origpool = NULL;
-    }
+    if (origpoolobj)
+        virStoragePoolObjPrivateDecrAsyncjobs(origpoolobj);
 
     if (buildret < 0 ||
         (backend->refreshVol &&
-         backend->refreshVol(obj->conn, pool, objnewvoldef) < 0)) {
-        storageVolDeleteInternal(vol, backend, pool, objnewvoldef, 0, false);
+         backend->refreshVol(pool->conn, poolobj, objnewvoldef) < 0)) {
+        storageVolDeleteInternal(vol, backend, poolobj, &newvolobj, 0, false);
         goto cleanup;
     }
 
     /* Updating pool metadata ignoring the disk backend since
      * it updates the pool values
      */
-    if (pool->def->type != VIR_STORAGE_POOL_DISK) {
-        pool->def->allocation += objnewvoldef->target.allocation;
-        pool->def->available -= objnewvoldef->target.allocation;
+    if (pooldef->type != VIR_STORAGE_POOL_DISK) {
+        pooldef->allocation += objnewvoldef->target.allocation;
+        pooldef->available -= objnewvoldef->target.allocation;
     }
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
-             vol->name, pool->def->name);
+             vol->name, pooldef->name);
     ret = vol;
     vol = NULL;
 
@@ -2220,10 +2154,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
     virObjectUnref(vol);
     virStorageVolDefFree(newvoldef);
     VIR_FREE(shadowvoldef);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    if (origpool)
-        virStoragePoolObjUnlock(origpool);
+    virPoolObjEndAPI(&origpoolobj);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
@@ -2235,19 +2167,21 @@ storageVolDownload(virStorageVolPtr volume,
                    unsigned long long length,
                    unsigned int flags)
 {
-    virStorageBackendPtr backend;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
+    virStorageBackendPtr backend;
     int ret = -1;
 
     virCheckFlags(0, -1);
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, &backend)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, &backend)))
         return -1;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolDownloadEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolDownloadEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     if (voldef->building) {
@@ -2263,13 +2197,12 @@ storageVolDownload(virStorageVolPtr volume,
         goto cleanup;
     }
 
-    ret = backend->downloadVol(volume->conn, pool, voldef, stream,
+    ret = backend->downloadVol(volume->conn, poolobj, voldef, stream,
                                offset, length, flags);
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
-
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
@@ -2341,38 +2274,38 @@ virStorageVolPoolRefreshThread(void *opaque)
 {
 
     virStorageVolStreamInfoPtr cbdata = opaque;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr poolobj = NULL;
+    virStoragePoolDefPtr pooldef;
     virStorageBackendPtr backend;
     virObjectEventPtr event = NULL;
 
-    storageDriverLock();
     if (cbdata->vol_path) {
         if (virStorageBackendPloopRestoreDesc(cbdata->vol_path) < 0)
             goto cleanup;
     }
-    if (!(pool = virStoragePoolObjFindByName(&driver->pools,
-                                             cbdata->pool_name)))
+
+    if (!(poolobj = storagePoolObjFindByName(cbdata->pool_name)))
         goto cleanup;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (!(backend = virStorageBackendForType(pool->def->type)))
+    if (!(backend = virStorageBackendForType(pooldef->type)))
         goto cleanup;
 
-    virStoragePoolObjClearVols(pool);
-    if (backend->refreshPool(NULL, pool) < 0)
+    virStoragePoolObjClearVols(poolobj);
+    if (backend->refreshPool(NULL, poolobj) < 0)
         VIR_DEBUG("Failed to refresh storage pool");
 
-    event = virStoragePoolEventRefreshNew(pool->def->name,
-                                          pool->def->uuid);
+    event = virStoragePoolEventRefreshNew(pooldef->name,
+                                          pooldef->uuid);
 
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->storageEventState, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    storageDriverUnlock();
+    virPoolObjEndAPI(&poolobj);
     virStorageVolPoolRefreshDataFree(cbdata);
 }
 
+
 /**
  * Callback being called if a FDstream is closed. Will spin off a thread
  * to perform a pool refresh.
@@ -2398,6 +2331,7 @@ virStorageVolFDStreamCloseCb(virStreamPtr st ATTRIBUTE_UNUSED,
     virStorageVolPoolRefreshDataFree(opaque);
 }
 
+
 static int
 storageVolUpload(virStorageVolPtr volume,
                  virStreamPtr stream,
@@ -2405,20 +2339,22 @@ storageVolUpload(virStorageVolPtr volume,
                  unsigned long long length,
                  unsigned int flags)
 {
-    virStorageBackendPtr backend;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
+    virStorageBackendPtr backend;
     virStorageVolStreamInfoPtr cbdata = NULL;
     int ret = -1;
 
     virCheckFlags(0, -1);
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, &backend)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, &backend)))
         return -1;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolUploadEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolUploadEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     if (voldef->in_use) {
@@ -2448,13 +2384,13 @@ storageVolUpload(virStorageVolPtr volume,
      * routine in order to call the refresh API.
      */
     if (VIR_ALLOC(cbdata) < 0 ||
-        VIR_STRDUP(cbdata->pool_name, pool->def->name) < 0)
+        VIR_STRDUP(cbdata->pool_name, pooldef->name) < 0)
         goto cleanup;
     if (voldef->type == VIR_STORAGE_VOL_PLOOP &&
         VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0)
         goto cleanup;
 
-    if ((ret = backend->uploadVol(volume->conn, pool, voldef, stream,
+    if ((ret = backend->uploadVol(volume->conn, poolobj, voldef, stream,
                                   offset, length, flags)) < 0)
         goto cleanup;
 
@@ -2468,22 +2404,24 @@ storageVolUpload(virStorageVolPtr volume,
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
     if (cbdata)
         virStorageVolPoolRefreshDataFree(cbdata);
 
     return ret;
 }
 
+
 static int
 storageVolResize(virStorageVolPtr volume,
                  unsigned long long capacity,
                  unsigned int flags)
 {
-    virStorageBackendPtr backend;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
+    virStorageBackendPtr backend;
     unsigned long long abs_capacity, delta = 0;
     int ret = -1;
 
@@ -2491,11 +2429,12 @@ storageVolResize(virStorageVolPtr volume,
                   VIR_STORAGE_VOL_RESIZE_DELTA |
                   VIR_STORAGE_VOL_RESIZE_SHRINK, -1);
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, &backend)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, &backend)))
         return -1;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolResizeEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolResizeEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     if (voldef->in_use) {
@@ -2525,23 +2464,22 @@ storageVolResize(virStorageVolPtr volume,
 
     if (abs_capacity < voldef->target.allocation) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("can't shrink capacity below "
-                         "existing allocation"));
+                       _("can't shrink capacity below existing allocation"));
         goto cleanup;
     }
 
     if (abs_capacity < voldef->target.capacity &&
         !(flags & VIR_STORAGE_VOL_RESIZE_SHRINK)) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("Can't shrink capacity below current "
-                         "capacity unless shrink flag explicitly specified"));
+                       _("Can't shrink capacity below current capacity unless "
+                         "shrink flag explicitly specified"));
         goto cleanup;
     }
 
     if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE)
         delta = abs_capacity - voldef->target.allocation;
 
-    if (delta > pool->def->available) {
+    if (delta > pooldef->available) {
         virReportError(VIR_ERR_OPERATION_FAILED, "%s",
                        _("Not enough space left in storage pool"));
         goto cleanup;
@@ -2554,7 +2492,8 @@ storageVolResize(virStorageVolPtr volume,
         goto cleanup;
     }
 
-    if (backend->resizeVol(volume->conn, pool, voldef, abs_capacity, flags) < 0)
+    if (backend->resizeVol(volume->conn, poolobj, voldef,
+                           abs_capacity, flags) < 0)
         goto cleanup;
 
     voldef->target.capacity = abs_capacity;
@@ -2564,15 +2503,15 @@ storageVolResize(virStorageVolPtr volume,
      */
     if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE) {
         voldef->target.allocation = abs_capacity;
-        pool->def->allocation += delta;
-        pool->def->available -= delta;
+        pooldef->allocation += delta;
+        pooldef->available -= delta;
     }
 
     ret = 0;
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
 
     return ret;
 }
@@ -2583,10 +2522,11 @@ storageVolWipePattern(virStorageVolPtr volume,
                       unsigned int algorithm,
                       unsigned int flags)
 {
-    virStorageBackendPtr backend;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
+    virStorageBackendPtr backend;
     int ret = -1;
 
     virCheckFlags(0, -1);
@@ -2598,11 +2538,12 @@ storageVolWipePattern(virStorageVolPtr volume,
         return -1;
     }
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, &backend)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, &backend)))
         return -1;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolWipePatternEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolWipePatternEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     if (voldef->in_use) {
@@ -2625,27 +2566,28 @@ storageVolWipePattern(virStorageVolPtr volume,
         goto cleanup;
     }
 
-    if (backend->wipeVol(volume->conn, pool, voldef, algorithm, flags) < 0)
+    if (backend->wipeVol(volume->conn, poolobj, voldef, algorithm, flags) < 0)
         goto cleanup;
 
     if (backend->refreshVol &&
-        backend->refreshVol(volume->conn, pool, voldef) < 0)
+        backend->refreshVol(volume->conn, poolobj, voldef) < 0)
         goto cleanup;
 
     ret = 0;
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
 
     return ret;
 }
 
+
 static int
-storageVolWipe(virStorageVolPtr obj,
+storageVolWipe(virStorageVolPtr volume,
                unsigned int flags)
 {
-    return storageVolWipePattern(obj, VIR_STORAGE_VOL_WIPE_ALG_ZERO, flags);
+    return storageVolWipePattern(volume, VIR_STORAGE_VOL_WIPE_ALG_ZERO, flags);
 }
 
 
@@ -2654,23 +2596,25 @@ storageVolGetInfoFlags(virStorageVolPtr volume,
                        virStorageVolInfoPtr info,
                        unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
-    virStorageBackendPtr backend;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
+    virStorageBackendPtr backend;
     int ret = -1;
 
     virCheckFlags(VIR_STORAGE_VOL_GET_PHYSICAL, -1);
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, &backend)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, &backend)))
         return -1;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolGetInfoFlagsEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolGetInfoFlagsEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     if (backend->refreshVol &&
-        backend->refreshVol(volume->conn, pool, voldef) < 0)
+        backend->refreshVol(volume->conn, poolobj, voldef) < 0)
         goto cleanup;
 
     memset(info, 0, sizeof(*info));
@@ -2684,16 +2628,16 @@ storageVolGetInfoFlags(virStorageVolPtr volume,
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
 
 static int
-storageVolGetInfo(virStorageVolPtr obj,
+storageVolGetInfo(virStorageVolPtr volume,
                   virStorageVolInfoPtr info)
 {
-    return storageVolGetInfoFlags(obj, info, 0);
+    return storageVolGetInfoFlags(volume, info, 0);
 }
 
 
@@ -2701,79 +2645,79 @@ static char *
 storageVolGetXMLDesc(virStorageVolPtr volume,
                      unsigned int flags)
 {
-    virStoragePoolObjPtr pool;
-    virStorageBackendPtr backend;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
+    virStorageBackendPtr backend;
     char *ret = NULL;
 
     virCheckFlags(0, NULL);
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, &backend)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, &backend)))
         return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolGetXMLDescEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolGetXMLDescEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     if (backend->refreshVol &&
-        backend->refreshVol(volume->conn, pool, voldef) < 0)
+        backend->refreshVol(volume->conn, poolobj, voldef) < 0)
         goto cleanup;
 
-    ret = virStorageVolDefFormat(pool->def, voldef);
+    ret = virStorageVolDefFormat(pooldef, voldef);
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
 
     return ret;
 }
 
+
 static char *
 storageVolGetPath(virStorageVolPtr volume)
 {
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj;
     virStorageVolDefPtr voldef;
     char *ret = NULL;
 
-    if (!(volobj = virStorageVolObjFromVol(volume, &pool, NULL)))
+    if (!(volobj = virStorageVolObjFromVol(volume, &poolobj, NULL)))
         return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
     voldef = virPoolObjGetDef(volobj);
 
-    if (virStorageVolGetPathEnsureACL(volume->conn, pool->def, voldef) < 0)
+    if (virStorageVolGetPathEnsureACL(volume->conn, pooldef, voldef) < 0)
         goto cleanup;
 
     ignore_value(VIR_STRDUP(ret, voldef->target.path));
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
+
 static int
 storageConnectListAllStoragePools(virConnectPtr conn,
                                   virStoragePoolPtr **pools,
                                   unsigned int flags)
 {
-    int ret = -1;
-
     virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1);
 
     if (virConnectListAllStoragePoolsEnsureACL(conn) < 0)
-        goto cleanup;
-
-    storageDriverLock();
-    ret = virStoragePoolObjListExport(conn, driver->pools, pools,
-                                      virConnectListAllStoragePoolsCheckACL,
-                                      flags);
-    storageDriverUnlock();
+        return -1;
 
- cleanup:
-    return ret;
+    return virStoragePoolObjExportList(conn, driver->pools, pools,
+                                       virConnectListAllStoragePoolsCheckACL,
+                                       flags);
 }
 
+
 static int
 storageConnectStoragePoolEventRegisterAny(virConnectPtr conn,
                                           virStoragePoolPtr pool,
@@ -3655,21 +3599,16 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
  *
  * Returns NULL if pool is not found or a locked pool object pointer
  */
-virStoragePoolObjPtr
+virPoolObjPtr
 virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
 {
-    virStoragePoolObjPtr pool;
-
-    storageDriverLock();
-    pool = virStoragePoolObjFindByUUID(&driver->pools, uuid);
-    storageDriverUnlock();
-    return pool;
+    return storagePoolObjFindByUUID(uuid, NULL);
 }
 
 
 /*
- * virStoragePoolObjBuildTempFilePath
- * @pool: pool object pointer
+ * virStoragePoolBuildTempFilePath
+ * @def: pool definition pointer
  * @vol: volume definition
  *
  * Generate a name for a temporary file using the driver stateDir
@@ -3679,13 +3618,13 @@ virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
  * Returns a string pointer on success, NULL on failure
  */
 char *
-virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr pool,
-                                   virStorageVolDefPtr vol)
+virStoragePoolBuildTempFilePath(virStoragePoolDefPtr def,
+                                virStorageVolDefPtr vol)
 
 {
     char *tmp = NULL;
 
     ignore_value(virAsprintf(&tmp, "%s/%s.%s.secret.XXXXXX",
-                             driver->stateDir, pool->def->name, vol->name));
+                             driver->stateDir, def->name, vol->name));
     return tmp;
 }
diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
index 682c9ff..c0bccb5 100644
--- a/src/storage/storage_driver.h
+++ b/src/storage/storage_driver.h
@@ -57,7 +57,7 @@ int virStorageFileGetMetadata(virStorageSourcePtr src,
 int virStorageTranslateDiskSourcePool(virConnectPtr conn,
                                       virDomainDiskDefPtr def);
 
-virStoragePoolObjPtr virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
+virPoolObjPtr virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
     ATTRIBUTE_NONNULL(1);
 
 virStoragePoolPtr
@@ -65,8 +65,8 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
                               const char *path)
     ATTRIBUTE_NONNULL(2);
 
-char *virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr pool,
-                                         virStorageVolDefPtr vol)
+char *virStoragePoolBuildTempFilePath(virStoragePoolDefPtr def,
+                                      virStorageVolDefPtr vol)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
 
 int storageRegister(void);
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 644c3e7..45f787c 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -223,7 +223,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
 
 static int
 storageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                              virPoolObjPtr obj ATTRIBUTE_UNUSED,
                               virStorageVolDefPtr vol,
                               virStorageVolDefPtr inputvol,
                               unsigned int flags)
@@ -391,11 +391,12 @@ createRawFile(int fd, virStorageVolDefPtr vol,
 
 static int
 storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
-                        virStoragePoolObjPtr pool,
-                        virStorageVolDefPtr vol,
-                        virStorageVolDefPtr inputvol,
+                        virPoolObjPtr obj,
+                        virStorageVolDefPtr voldef,
+                        virStorageVolDefPtr inputvoldef,
                         unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     int ret = -1;
     int fd = -1;
     int operation_flags;
@@ -414,7 +415,7 @@ storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (vol->target.backingStore) {
+    if (voldef->target.backingStore) {
         virReportError(VIR_ERR_NO_SUPPORT, "%s",
                        _("backing storage not supported for raw volumes"));
         goto cleanup;
@@ -424,33 +425,33 @@ storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
         reflink_copy = true;
 
 
-    if (vol->target.encryption != NULL) {
+    if (voldef->target.encryption != NULL) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("storage pool does not support encrypted volumes"));
         goto cleanup;
     }
 
     operation_flags = VIR_FILE_OPEN_FORCE_MODE | VIR_FILE_OPEN_FORCE_OWNER;
-    if (pool->def->type == VIR_STORAGE_POOL_NETFS)
+    if (def->type == VIR_STORAGE_POOL_NETFS)
         operation_flags |= VIR_FILE_OPEN_FORK;
 
-    if (vol->target.perms->mode != (mode_t) -1)
-        open_mode = vol->target.perms->mode;
+    if (voldef->target.perms->mode != (mode_t) -1)
+        open_mode = voldef->target.perms->mode;
 
-    if ((fd = virFileOpenAs(vol->target.path,
+    if ((fd = virFileOpenAs(voldef->target.path,
                             O_RDWR | O_CREAT | O_EXCL,
                             open_mode,
-                            vol->target.perms->uid,
-                            vol->target.perms->gid,
+                            voldef->target.perms->uid,
+                            voldef->target.perms->gid,
                             operation_flags)) < 0) {
         virReportSystemError(-fd,
                              _("Failed to create file '%s'"),
-                             vol->target.path);
+                             voldef->target.path);
         goto cleanup;
     }
     created = true;
 
-    if (vol->target.nocow) {
+    if (voldef->target.nocow) {
 #ifdef __linux__
         int attr;
 
@@ -470,15 +471,15 @@ storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
 #endif
     }
 
-    if ((ret = createRawFile(fd, vol, inputvol, reflink_copy)) < 0)
+    if ((ret = createRawFile(fd, voldef, inputvoldef, reflink_copy)) < 0)
         /* createRawFile already reported the exact error. */
         ret = -1;
 
  cleanup:
     if (ret < 0 && created)
-        ignore_value(virFileRemove(vol->target.path,
-                                   vol->target.perms->uid,
-                                   vol->target.perms->gid));
+        ignore_value(virFileRemove(voldef->target.path,
+                                   voldef->target.perms->uid,
+                                   voldef->target.perms->gid));
     VIR_FORCE_CLOSE(fd);
     return ret;
 }
@@ -593,10 +594,11 @@ virStorageGenerateQcowEncryption(virConnectPtr conn,
 }
 
 static int
-virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
+virStorageBackendCreateExecCommand(virPoolObjPtr obj,
                                    virStorageVolDefPtr vol,
                                    virCommandPtr cmd)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     struct stat st;
     gid_t gid;
     uid_t uid;
@@ -606,7 +608,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
     bool filecreated = false;
     int ret = -1;
 
-    if ((pool->def->type == VIR_STORAGE_POOL_NETFS)
+    if ((def->type == VIR_STORAGE_POOL_NETFS)
         && (((geteuid() == 0)
              && (vol->target.perms->uid != (uid_t) -1)
              && (vol->target.perms->uid != 0))
@@ -694,7 +696,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
  * if function fails to create image file the directory will be deleted.*/
 static int
 storageBackendCreatePloop(virConnectPtr conn ATTRIBUTE_UNUSED,
-                          virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                          virPoolObjPtr obj ATTRIBUTE_UNUSED,
                           virStorageVolDefPtr vol,
                           virStorageVolDefPtr inputvol,
                           unsigned int flags)
@@ -1022,11 +1024,12 @@ storageBackendCreateQemuImgSetInput(virStorageVolDefPtr inputvol,
 
 
 static int
-storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr pool,
+storageBackendCreateQemuImgSetBacking(virPoolObjPtr obj,
                                       virStorageVolDefPtr vol,
                                       virStorageVolDefPtr inputvol,
                                       struct _virStorageBackendQemuImgInfo *info)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     int accessRetCode = -1;
     char *absolutePath = NULL;
 
@@ -1069,7 +1072,7 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr pool,
      * validation.
      */
     if ('/' != *(info->backingPath) &&
-        virAsprintf(&absolutePath, "%s/%s", pool->def->target.path,
+        virAsprintf(&absolutePath, "%s/%s", def->target.path,
                     info->backingPath) < 0)
         return -1;
     accessRetCode = access(absolutePath ? absolutePath :
@@ -1146,7 +1149,7 @@ storageBackendCreateQemuImgSecretObject(virCommandPtr cmd,
  */
 virCommandPtr
 virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
-                                         virStoragePoolObjPtr pool,
+                                         virPoolObjPtr obj,
                                          virStorageVolDefPtr vol,
                                          virStorageVolDefPtr inputvol,
                                          unsigned int flags,
@@ -1223,7 +1226,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
         return NULL;
 
     if (vol->target.backingStore &&
-        storageBackendCreateQemuImgSetBacking(pool, vol, inputvol, &info) < 0)
+        storageBackendCreateQemuImgSetBacking(obj, vol, inputvol, &info) < 0)
         return NULL;
 
     if (info.encryption &&
@@ -1280,9 +1283,10 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
 
 static char *
 storageBackendCreateQemuImgSecretPath(virConnectPtr conn,
-                                      virStoragePoolObjPtr pool,
+                                      virPoolObjPtr obj,
                                       virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     virStorageEncryptionPtr enc = vol->target.encryption;
     char *secretPath = NULL;
     int fd = -1;
@@ -1304,7 +1308,7 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr conn,
         return NULL;
     }
 
-    if (!(secretPath = virStoragePoolObjBuildTempFilePath(pool, vol)))
+    if (!(secretPath = virStoragePoolBuildTempFilePath(def, vol)))
         goto cleanup;
 
     if ((fd = mkostemp(secretPath, O_CLOEXEC)) < 0) {
@@ -1350,7 +1354,7 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr conn,
 
 static int
 storageBackendCreateQemuImg(virConnectPtr conn,
-                            virStoragePoolObjPtr pool,
+                            virPoolObjPtr obj,
                             virStorageVolDefPtr vol,
                             virStorageVolDefPtr inputvol,
                             unsigned int flags)
@@ -1379,17 +1383,17 @@ storageBackendCreateQemuImg(virConnectPtr conn,
         vol->target.encryption &&
         vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
         if (!(secretPath =
-              storageBackendCreateQemuImgSecretPath(conn, pool, vol)))
+              storageBackendCreateQemuImgSecretPath(conn, obj, vol)))
             goto cleanup;
     }
 
-    cmd = virStorageBackendCreateQemuImgCmdFromVol(conn, pool, vol, inputvol,
+    cmd = virStorageBackendCreateQemuImgCmdFromVol(conn, obj, vol, inputvol,
                                                    flags, create_tool,
                                                    imgformat, secretPath);
     if (!cmd)
         goto cleanup;
 
-    ret = virStorageBackendCreateExecCommand(pool, vol, cmd);
+    ret = virStorageBackendCreateExecCommand(obj, vol, cmd);
 
     virCommandFree(cmd);
  cleanup:
@@ -1931,10 +1935,11 @@ virStorageBackendPoolPathIsStable(const char *path)
  * a change to appear.
  */
 char *
-virStorageBackendStablePath(virStoragePoolObjPtr pool,
+virStorageBackendStablePath(virPoolObjPtr obj,
                             const char *devpath,
                             bool loop)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     DIR *dh;
     struct dirent *dent;
     char *stablepath;
@@ -1943,8 +1948,8 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
     int direrr;
 
     /* Logical pools are under /dev but already have stable paths */
-    if (pool->def->type == VIR_STORAGE_POOL_LOGICAL ||
-        !virStorageBackendPoolPathIsStable(pool->def->target.path))
+    if (def->type == VIR_STORAGE_POOL_LOGICAL ||
+        !virStorageBackendPoolPathIsStable(def->target.path))
         goto ret_strdup;
 
     /* We loop here because /dev/disk/by-{id,path} may not have existed
@@ -1952,7 +1957,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
      * get created.
      */
  reopen:
-    if (virDirOpenQuiet(&dh, pool->def->target.path) < 0) {
+    if (virDirOpenQuiet(&dh, def->target.path) < 0) {
         opentries++;
         if (loop && errno == ENOENT && opentries < 50) {
             usleep(100 * 1000);
@@ -1960,7 +1965,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
         }
         virReportSystemError(errno,
                              _("cannot read dir '%s'"),
-                             pool->def->target.path);
+                             def->target.path);
         return NULL;
     }
 
@@ -1976,7 +1981,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
  retry:
     while ((direrr = virDirRead(dh, &dent, NULL)) > 0) {
         if (virAsprintf(&stablepath, "%s/%s",
-                        pool->def->target.path,
+                        def->target.path,
                         dent->d_name) == -1) {
             VIR_DIR_CLOSE(dh);
             return NULL;
@@ -2010,11 +2015,12 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
 /* Common/Local File System/Directory Volume API's */
 static int
 createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED,
-              virStoragePoolObjPtr pool,
+              virPoolObjPtr poolobj,
               virStorageVolDefPtr vol,
               virStorageVolDefPtr inputvol,
               unsigned int flags)
 {
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(poolobj);
     int err;
 
     virCheckFlags(0, -1);
@@ -2039,7 +2045,7 @@ createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED,
                              vol->target.perms->mode),
                             vol->target.perms->uid,
                             vol->target.perms->gid,
-                            (pool->def->type == VIR_STORAGE_POOL_NETFS
+                            (pooldef->type == VIR_STORAGE_POOL_NETFS
                              ? VIR_DIR_CREATE_AS_UID : 0))) < 0) {
         return -1;
     }
@@ -2056,9 +2062,11 @@ createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED,
  */
 int
 virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                virStoragePoolObjPtr pool,
+                                virPoolObjPtr poolobj,
                                 virStorageVolDefPtr vol)
 {
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(poolobj);
+
     if (vol->target.format == VIR_STORAGE_FILE_DIR)
         vol->type = VIR_STORAGE_VOL_DIR;
     else if (vol->target.format == VIR_STORAGE_FILE_PLOOP)
@@ -2076,7 +2084,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
-                    pool->def->target.path,
+                    pooldef->target.path,
                     vol->name) == -1)
         return -1;
 
@@ -2094,7 +2102,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 static int
 storageBackendVolBuildLocal(virConnectPtr conn,
-                            virStoragePoolObjPtr pool,
+                            virPoolObjPtr poolobj,
                             virStorageVolDefPtr vol,
                             virStorageVolDefPtr inputvol,
                             unsigned int flags)
@@ -2123,7 +2131,7 @@ storageBackendVolBuildLocal(virConnectPtr conn,
         create_func = storageBackendCreateQemuImg;
     }
 
-    if (create_func(conn, pool, vol, inputvol, flags) < 0)
+    if (create_func(conn, poolobj, vol, inputvol, flags) < 0)
         return -1;
     return 0;
 }
@@ -2136,11 +2144,11 @@ storageBackendVolBuildLocal(virConnectPtr conn,
  */
 int
 virStorageBackendVolBuildLocal(virConnectPtr conn,
-                               virStoragePoolObjPtr pool,
+                               virPoolObjPtr poolobj,
                                virStorageVolDefPtr vol,
                                unsigned int flags)
 {
-    return storageBackendVolBuildLocal(conn, pool, vol, NULL, flags);
+    return storageBackendVolBuildLocal(conn, poolobj, vol, NULL, flags);
 }
 
 
@@ -2149,12 +2157,12 @@ virStorageBackendVolBuildLocal(virConnectPtr conn,
  */
 int
 virStorageBackendVolBuildFromLocal(virConnectPtr conn,
-                                   virStoragePoolObjPtr pool,
+                                   virPoolObjPtr poolobj,
                                    virStorageVolDefPtr vol,
                                    virStorageVolDefPtr inputvol,
                                    unsigned int flags)
 {
-    return storageBackendVolBuildLocal(conn, pool, vol, inputvol, flags);
+    return storageBackendVolBuildLocal(conn, poolobj, vol, inputvol, flags);
 }
 
 
@@ -2163,7 +2171,7 @@ virStorageBackendVolBuildFromLocal(virConnectPtr conn,
  */
 int
 virStorageBackendVolDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                                virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                                 virStorageVolDefPtr vol,
                                 unsigned int flags)
 {
@@ -2260,7 +2268,7 @@ storageBackendLoadDefaultSecrets(virConnectPtr conn,
  */
 int
 virStorageBackendVolRefreshLocal(virConnectPtr conn,
-                                 virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                                 virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                                  virStorageVolDefPtr vol)
 {
     int ret;
@@ -2313,7 +2321,7 @@ storageBackendResizeQemuImg(const char *path,
  */
 int
 virStorageBackendVolResizeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                                virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                                 virStorageVolDefPtr vol,
                                 unsigned long long capacity,
                                 unsigned int flags)
@@ -2385,7 +2393,7 @@ storageBackendPloopHasSnapshots(char *path)
 
 int
 virStorageBackendVolUploadLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                                virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                                 virStorageVolDefPtr vol,
                                 virStreamPtr stream,
                                 unsigned long long offset,
@@ -2431,7 +2439,7 @@ virStorageBackendVolUploadLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 int
 virStorageBackendVolDownloadLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                                  virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                                   virStorageVolDefPtr vol,
                                   virStreamPtr stream,
                                   unsigned long long offset,
@@ -2714,7 +2722,7 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol,
 
 int
 virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                              virPoolObjPtr poolobj ATTRIBUTE_UNUSED,
                               virStorageVolDefPtr vol,
                               unsigned int algorithm,
                               unsigned int flags)
@@ -2738,16 +2746,16 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 
 /**
- * @pool: storage pool to build
- * @dir_create_flags: flags for directory creation
+ * @poolobj: storage pool to build
  *
  * Common code to build a directory based storage pool
  *
  * Returns 0 on success, -1 on failure
  */
 int
-virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
+virStorageBackendBuildLocal(virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     int ret = -1;
     char *parent = NULL;
     char *p = NULL;
@@ -2755,12 +2763,12 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
     bool needs_create_as_uid;
     unsigned int dir_create_flags;
 
-    if (VIR_STRDUP(parent, pool->def->target.path) < 0)
+    if (VIR_STRDUP(parent, def->target.path) < 0)
         goto cleanup;
     if (!(p = strrchr(parent, '/'))) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("path '%s' is not absolute"),
-                       pool->def->target.path);
+                       def->target.path);
         goto cleanup;
     }
 
@@ -2776,11 +2784,11 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
     }
 
     dir_create_flags = VIR_DIR_CREATE_ALLOW_EXIST;
-    needs_create_as_uid = (pool->def->type == VIR_STORAGE_POOL_NETFS);
-    mode = pool->def->target.perms.mode;
+    needs_create_as_uid = (def->type == VIR_STORAGE_POOL_NETFS);
+    mode = def->target.perms.mode;
 
     if (mode == (mode_t) -1 &&
-        (needs_create_as_uid || !virFileExists(pool->def->target.path)))
+        (needs_create_as_uid || !virFileExists(def->target.path)))
         mode = VIR_STORAGE_DEFAULT_POOL_PERM_MODE;
     if (needs_create_as_uid)
         dir_create_flags |= VIR_DIR_CREATE_AS_UID;
@@ -2788,10 +2796,10 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
     /* Now create the final dir in the path with the uid/gid/mode
      * requested in the config. If the dir already exists, just set
      * the perms. */
-    if (virDirCreate(pool->def->target.path,
+    if (virDirCreate(def->target.path,
                      mode,
-                     pool->def->target.perms.uid,
-                     pool->def->target.perms.gid,
+                     def->target.perms.uid,
+                     def->target.perms.gid,
                      dir_create_flags) < 0)
         goto cleanup;
 
@@ -2813,17 +2821,19 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
  */
 int
 virStorageBackendDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                             virStoragePoolObjPtr pool,
+                             virPoolObjPtr poolobj,
                              unsigned int flags)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
+
     virCheckFlags(0, -1);
 
     /* XXX delete all vols first ? */
 
-    if (rmdir(pool->def->target.path) < 0) {
+    if (rmdir(def->target.path) < 0) {
         virReportSystemError(errno,
                              _("failed to remove pool '%s'"),
-                             pool->def->target.path);
+                             def->target.path);
         return -1;
     }
 
@@ -3464,8 +3474,9 @@ storageBackendProbeTarget(virStorageSourcePtr target,
  */
 int
 virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-                              virStoragePoolObjPtr pool)
+                              virPoolObjPtr poolobj)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(poolobj);
     DIR *dir;
     struct dirent *ent;
     struct statvfs sb;
@@ -3476,15 +3487,15 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
     int direrr;
     int fd = -1, ret = -1;
 
-    if (virDirOpen(&dir, pool->def->target.path) < 0)
+    if (virDirOpen(&dir, def->target.path) < 0)
         goto cleanup;
 
-    while ((direrr = virDirRead(dir, &ent, pool->def->target.path)) > 0) {
+    while ((direrr = virDirRead(dir, &ent, def->target.path)) > 0) {
         int err;
 
         if (virStringHasControlChars(ent->d_name)) {
             VIR_WARN("Ignoring file with control characters under '%s'",
-                     pool->def->target.path);
+                     def->target.path);
             continue;
         }
 
@@ -3497,7 +3508,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
         vol->type = VIR_STORAGE_VOL_FILE;
         vol->target.format = VIR_STORAGE_FILE_RAW; /* Real value is filled in during probe */
         if (virAsprintf(&vol->target.path, "%s/%s",
-                        pool->def->target.path,
+                        def->target.path,
                         vol->name) == -1)
             goto cleanup;
 
@@ -3540,7 +3551,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
              * An error message was raised, but we just continue. */
         }
 
-        if (!(volobj = virStoragePoolObjAddVolume(pool, vol)))
+        if (!(volobj = virStoragePoolObjAddVolume(poolobj, vol)))
             goto cleanup;
 
         vol = NULL;
@@ -3554,17 +3565,17 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
     if (VIR_ALLOC(target))
         goto cleanup;
 
-    if ((fd = open(pool->def->target.path, O_RDONLY)) < 0) {
+    if ((fd = open(def->target.path, O_RDONLY)) < 0) {
         virReportSystemError(errno,
                              _("cannot open path '%s'"),
-                             pool->def->target.path);
+                             def->target.path);
         goto cleanup;
     }
 
     if (fstat(fd, &statbuf) < 0) {
         virReportSystemError(errno,
                              _("cannot stat path '%s'"),
-                             pool->def->target.path);
+                             def->target.path);
         goto cleanup;
     }
 
@@ -3572,24 +3583,24 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto cleanup;
 
     /* VolTargetInfoFD doesn't update capacity correctly for the pool case */
-    if (statvfs(pool->def->target.path, &sb) < 0) {
+    if (statvfs(def->target.path, &sb) < 0) {
         virReportSystemError(errno,
                              _("cannot statvfs path '%s'"),
-                             pool->def->target.path);
+                             def->target.path);
         goto cleanup;
     }
 
-    pool->def->capacity = ((unsigned long long)sb.f_frsize *
-                           (unsigned long long)sb.f_blocks);
-    pool->def->available = ((unsigned long long)sb.f_bfree *
-                            (unsigned long long)sb.f_frsize);
-    pool->def->allocation = pool->def->capacity - pool->def->available;
+    def->capacity = ((unsigned long long)sb.f_frsize *
+                     (unsigned long long)sb.f_blocks);
+    def->available = ((unsigned long long)sb.f_bfree *
+                      (unsigned long long)sb.f_frsize);
+    def->allocation = def->capacity - def->available;
 
-    pool->def->target.perms.mode = target->perms->mode;
-    pool->def->target.perms.uid = target->perms->uid;
-    pool->def->target.perms.gid = target->perms->gid;
-    VIR_FREE(pool->def->target.perms.label);
-    if (VIR_STRDUP(pool->def->target.perms.label, target->perms->label) < 0)
+    def->target.perms.mode = target->perms->mode;
+    def->target.perms.uid = target->perms->uid;
+    def->target.perms.gid = target->perms->gid;
+    VIR_FREE(def->target.perms.label);
+    if (VIR_STRDUP(def->target.perms.label, target->perms->label) < 0)
         goto cleanup;
 
     ret = 0;
@@ -3599,7 +3610,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
     virStorageVolDefFree(vol);
     virStorageSourceFree(target);
     if (ret < 0)
-        virStoragePoolObjClearVols(pool);
+        virStoragePoolObjClearVols(poolobj);
     return ret;
 }
 
@@ -3652,13 +3663,14 @@ virStorageBackendSCSISerial(const char *dev)
  *  -2 => Failure to find a stable path, not fatal, caller can try another
  */
 static int
-virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
+virStorageBackendSCSINewLun(virPoolObjPtr obj,
                             uint32_t host ATTRIBUTE_UNUSED,
                             uint32_t bus,
                             uint32_t target,
                             uint32_t lun,
                             const char *dev)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     virStorageVolDefPtr vol = NULL;
     virPoolObjPtr volobj;
     char *devpath = NULL;
@@ -3671,12 +3683,12 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
      * path to the device if the virDirRead loop to search the
      * target pool path for our devpath had failed.
      */
-    if (!virStorageBackendPoolPathIsStable(pool->def->target.path) &&
-        !(STREQ(pool->def->target.path, "/dev") ||
-          STREQ(pool->def->target.path, "/dev/"))) {
+    if (!virStorageBackendPoolPathIsStable(def->target.path) &&
+        !(STREQ(def->target.path, "/dev") ||
+          STREQ(def->target.path, "/dev/"))) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("unable to use target path '%s' for dev '%s'"),
-                       NULLSTR(pool->def->target.path), dev);
+                       NULLSTR(def->target.path), dev);
         goto cleanup;
     }
 
@@ -3704,17 +3716,15 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
      * dir every time its run. Should figure out a more efficient
      * way of doing this...
      */
-    if ((vol->target.path = virStorageBackendStablePath(pool,
-                                                        devpath,
-                                                        true)) == NULL)
+    if (!(vol->target.path = virStorageBackendStablePath(obj, devpath, true)))
         goto cleanup;
 
     if (STREQ(devpath, vol->target.path) &&
-        !(STREQ(pool->def->target.path, "/dev") ||
-          STREQ(pool->def->target.path, "/dev/"))) {
+        !(STREQ(def->target.path, "/dev") ||
+          STREQ(def->target.path, "/dev/"))) {
 
         VIR_DEBUG("No stable path found for '%s' in '%s'",
-                  devpath, pool->def->target.path);
+                  devpath, def->target.path);
 
         retval = -2;
         goto cleanup;
@@ -3729,10 +3739,10 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
     if (!(vol->key = virStorageBackendSCSISerial(vol->target.path)))
         goto cleanup;
 
-    pool->def->capacity += vol->target.capacity;
-    pool->def->allocation += vol->target.allocation;
+    def->capacity += vol->target.capacity;
+    def->allocation += vol->target.allocation;
 
-    if (!(volobj = virStoragePoolObjAddVolume(pool, vol)))
+    if (!(volobj = virStoragePoolObjAddVolume(obj, vol)))
         goto cleanup;
 
     vol = NULL;
@@ -3746,7 +3756,6 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
 }
 
 
-
 static int
 getNewStyleBlockDevice(const char *lun_path,
                        const char *block_name ATTRIBUTE_UNUSED,
@@ -3952,7 +3961,7 @@ getDeviceType(uint32_t host,
  *  -2 => non-fatal error or a non-disk entry
  */
 static int
-processLU(virStoragePoolObjPtr pool,
+processLU(virPoolObjPtr obj,
           uint32_t host,
           uint32_t bus,
           uint32_t target,
@@ -3987,7 +3996,7 @@ processLU(virStoragePoolObjPtr pool,
         return retval;
     }
 
-    retval = virStorageBackendSCSINewLun(pool, host, bus, target, lun,
+    retval = virStorageBackendSCSINewLun(obj, host, bus, target, lun,
                                          block_device);
     if (retval < 0) {
         VIR_DEBUG("Failed to create new storage volume for %u:%u:%u:%u",
@@ -4005,9 +4014,10 @@ processLU(virStoragePoolObjPtr pool,
 
 
 int
-virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
+virStorageBackendSCSIFindLUs(virPoolObjPtr obj,
                               uint32_t scanhost)
 {
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
     int retval = 0;
     uint32_t bus, target, lun;
     const char *device_path = "/sys/bus/scsi/devices";
@@ -4035,7 +4045,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
 
         VIR_DEBUG("Found possible LU '%s'", lun_dirent->d_name);
 
-        rc = processLU(pool, scanhost, bus, target, lun);
+        rc = processLU(obj, scanhost, bus, target, lun);
         if (rc == -1) {
             retval = -1;
             break;
@@ -4049,7 +4059,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
     if (retval < 0)
         return -1;
 
-    VIR_DEBUG("Found %d LUs for pool %s", found, pool->def->name);
+    VIR_DEBUG("Found %d LUs for pool %s", found, def->name);
 
     return found;
 }
diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
index 326d555..82a4adc 100644
--- a/src/storage/storage_util.h
+++ b/src/storage/storage_util.h
@@ -22,7 +22,6 @@
 # include <sys/stat.h>
 
 # include "internal.h"
-# include "storage_conf.h"
 # include "vircommand.h"
 # include "storage_driver.h"
 # include "storage_backend.h"
@@ -33,37 +32,37 @@ virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
                                          virStorageVolDefPtr inputvol);
 
 int virStorageBackendVolCreateLocal(virConnectPtr conn,
-                                    virStoragePoolObjPtr pool,
+                                    virPoolObjPtr obj,
                                     virStorageVolDefPtr vol);
 
 int virStorageBackendVolBuildLocal(virConnectPtr conn,
-                                   virStoragePoolObjPtr pool,
+                                   virPoolObjPtr poolobj,
                                    virStorageVolDefPtr vol,
                                    unsigned int flags);
 
 int virStorageBackendVolBuildFromLocal(virConnectPtr conn,
-                                       virStoragePoolObjPtr pool,
+                                       virPoolObjPtr poolobj,
                                        virStorageVolDefPtr vol,
                                        virStorageVolDefPtr inputvol,
                                        unsigned int flags);
 
 int virStorageBackendVolDeleteLocal(virConnectPtr conn,
-                                    virStoragePoolObjPtr pool,
+                                    virPoolObjPtr poolobj,
                                     virStorageVolDefPtr vol,
                                     unsigned int flags);
 
 int virStorageBackendVolRefreshLocal(virConnectPtr conn,
-                                     virStoragePoolObjPtr pool,
+                                     virPoolObjPtr poolobj,
                                      virStorageVolDefPtr vol);
 
 int virStorageBackendVolResizeLocal(virConnectPtr conn,
-                                    virStoragePoolObjPtr pool,
+                                    virPoolObjPtr poolobj,
                                     virStorageVolDefPtr vol,
                                     unsigned long long capacity,
                                     unsigned int flags);
 
 int virStorageBackendVolUploadLocal(virConnectPtr conn,
-                                    virStoragePoolObjPtr pool,
+                                    virPoolObjPtr obj,
                                     virStorageVolDefPtr vol,
                                     virStreamPtr stream,
                                     unsigned long long offset,
@@ -71,7 +70,7 @@ int virStorageBackendVolUploadLocal(virConnectPtr conn,
                                     unsigned int flags);
 
 int virStorageBackendVolDownloadLocal(virConnectPtr conn,
-                                      virStoragePoolObjPtr pool,
+                                      virPoolObjPtr obj,
                                       virStorageVolDefPtr vol,
                                       virStreamPtr stream,
                                       unsigned long long offset,
@@ -79,20 +78,20 @@ int virStorageBackendVolDownloadLocal(virConnectPtr conn,
                                       unsigned int flags);
 
 int virStorageBackendVolWipeLocal(virConnectPtr conn,
-                                  virStoragePoolObjPtr pool,
+                                  virPoolObjPtr obj,
                                   virStorageVolDefPtr vol,
                                   unsigned int algorithm,
                                   unsigned int flags);
 
 /* Local/Common Storage Pool Backend APIs */
-int virStorageBackendBuildLocal(virStoragePoolObjPtr pool);
+int virStorageBackendBuildLocal(virPoolObjPtr poolobj);
 
 int virStorageBackendDeleteLocal(virConnectPtr conn,
-                                 virStoragePoolObjPtr pool,
+                                 virPoolObjPtr poolobj,
                                  unsigned int flags);
 
 int virStorageBackendRefreshLocal(virConnectPtr conn,
-                                  virStoragePoolObjPtr pool);
+                                  virPoolObjPtr poolobj);
 
 int virStorageBackendFindGlusterPoolSources(const char *host,
                                             int pooltype,
@@ -147,13 +146,13 @@ int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
                                            struct stat *sb);
 
 bool virStorageBackendPoolPathIsStable(const char *path);
-char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
+char *virStorageBackendStablePath(virPoolObjPtr obj,
                                   const char *devpath,
                                   bool loop);
 
 virCommandPtr
 virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
-                                         virStoragePoolObjPtr pool,
+                                         virPoolObjPtr obj,
                                          virStorageVolDefPtr vol,
                                          virStorageVolDefPtr inputvol,
                                          unsigned int flags,
@@ -161,7 +160,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
                                          int imgformat,
                                          const char *secretPath);
 
-int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
+int virStorageBackendSCSIFindLUs(virPoolObjPtr obj,
                                  uint32_t scanhost);
 
 #endif /* __VIR_STORAGE_UTIL_H__ */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index fedf415..26924b5 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -50,6 +50,7 @@
 #include "snapshot_conf.h"
 #include "fdstream.h"
 #include "storage_conf.h"
+#include "virstorageobj.h"
 #include "storage_event.h"
 #include "node_device_conf.h"
 #include "virnodedeviceobj.h"
@@ -100,7 +101,7 @@ struct _testDriver {
     virPoolObjTablePtr ifaces;
     bool transaction_running;
     virPoolObjTablePtr backupIfaces;
-    virStoragePoolObjList pools;
+    virPoolObjTablePtr pools;
     virPoolObjTablePtr devs;
     int numCells;
     testCell cells[MAX_CELLS];
@@ -156,7 +157,7 @@ testDriverFree(testDriverPtr driver)
     virObjectUnref(driver->networks);
     virObjectUnref(driver->ifaces);
     virObjectUnref(driver->backupIfaces);
-    virStoragePoolObjListFree(&driver->pools);
+    virObjectUnref(driver->pools);
     virObjectUnref(driver->eventState);
     virMutexUnlock(&driver->lock);
     virMutexDestroy(&driver->lock);
@@ -423,6 +424,10 @@ testDriverNew(void)
         !(ret->ifaces = virPoolObjTableNew(VIR_POOLOBJTABLE_INTERFACE,
                                            VIR_POOLOBJTABLE_INTERFACE_HASHSTART,
                                            true)) ||
+        !(ret->pools =
+          virPoolObjTableNew(VIR_POOLOBJTABLE_BLOCK_STORAGE,
+                             VIR_POOLOBJTABLE_BLOCK_STORAGE_HASHSTART,
+                             false)) ||
         !(ret->domains = virDomainObjListNew()) ||
         !(ret->networks = virNetworkObjListNew()))
         goto error;
@@ -537,7 +542,7 @@ static const char *defaultPoolSourcesNetFSXML =
 static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ull);
 static const unsigned long long defaultPoolAlloc;
 
-static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool);
+static int testStoragePoolObjSetDefaults(virPoolObjPtr obj);
 static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
 
 static virDomainObjPtr
@@ -1009,9 +1014,10 @@ testParseInterfaces(testDriverPtr privconn,
 static int
 testOpenVolumesForPool(const char *file,
                        xmlXPathContextPtr ctxt,
-                       virStoragePoolObjPtr pool,
+                       virPoolObjPtr poolobj,
                        int poolidx)
 {
+    virStoragePoolDefPtr pooldef = virPoolObjGetDef(poolobj);
     char *vol_xpath;
     size_t i;
     int num, ret = -1;
@@ -1033,30 +1039,29 @@ testOpenVolumesForPool(const char *file,
         if (!(node = testParseXMLDocFromFile(nodes[i], file, "volume")))
             goto error;
 
-        if (!(def = virStorageVolDefParseNode(pool->def, ctxt->doc, node, 0)))
+        if (!(def = virStorageVolDefParseNode(pooldef, ctxt->doc, node, 0)))
             goto error;
 
         if (def->target.path == NULL) {
             if (virAsprintf(&def->target.path, "%s/%s",
-                            pool->def->target.path, def->name) < 0)
+                            pooldef->target.path, def->name) < 0)
                 goto error;
         }
 
         if (!def->key && VIR_STRDUP(def->key, def->target.path) < 0)
             goto error;
 
-        if (!(volobj = virStoragePoolObjAddVolume(pool, def)))
+        if (!(volobj = virStoragePoolObjAddVolume(poolobj, def)))
             goto error;
 
-        pool->def->allocation += def->target.allocation;
-        pool->def->available = (pool->def->capacity -
-                                pool->def->allocation);
+        pooldef->allocation += def->target.allocation;
+        pooldef->available = pooldef->capacity - pooldef->allocation;
         def = NULL;
+        virPoolObjEndAPI(&volobj);
     }
 
     ret = 0;
  error:
-    virPoolObjEndAPI(&volobj);
     virStorageVolDefFree(def);
     VIR_FREE(nodes);
     return ret;
@@ -1070,46 +1075,40 @@ testParseStorage(testDriverPtr privconn,
     int num, ret = -1;
     size_t i;
     xmlNodePtr *nodes = NULL;
-    virStoragePoolObjPtr obj;
+    xmlNodePtr node;
+    virStoragePoolDefPtr def = NULL;
+    virPoolObjPtr obj = NULL;
 
     num = virXPathNodeSet("/node/pool", ctxt, &nodes);
     if (num < 0)
         goto error;
 
     for (i = 0; i < num; i++) {
-        virStoragePoolDefPtr def;
-        xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
-                                                   "pool");
-        if (!node)
+        if (!(node = testParseXMLDocFromFile(nodes[i], file, "pool")))
             goto error;
 
-        def = virStoragePoolDefParseNode(ctxt->doc, node);
-        if (!def)
+        if (!(def = virStoragePoolDefParseNode(ctxt->doc, node)))
             goto error;
 
-        if (!(obj = virStoragePoolObjAssignDef(&privconn->pools,
-                                                def))) {
-            virStoragePoolDefFree(def);
+        if (!(obj = virStoragePoolObjAdd(privconn->pools, def)))
             goto error;
-        }
+        def = NULL;
 
-        if (testStoragePoolObjSetDefaults(obj) == -1) {
-            virStoragePoolObjUnlock(obj);
+        if (testStoragePoolObjSetDefaults(obj) == -1)
             goto error;
-        }
-        obj->active = 1;
+        virPoolObjSetActive(obj, true);
 
         /* Find storage volumes */
-        if (testOpenVolumesForPool(file, ctxt, obj, i+1) < 0) {
-            virStoragePoolObjUnlock(obj);
+        if (testOpenVolumesForPool(file, ctxt, obj, i + 1) < 0)
             goto error;
-        }
 
-        virStoragePoolObjUnlock(obj);
+        virPoolObjEndAPI(&obj);
     }
 
     ret = 0;
  error:
+    virStoragePoolDefFree(def);
+    virPoolObjEndAPI(&obj);
     VIR_FREE(nodes);
     return ret;
 }
@@ -3951,14 +3950,29 @@ testInterfaceDestroy(virInterfacePtr iface,
  */
 
 
-static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool)
+static int
+testStoragePoolObjSetDefaults(virPoolObjPtr obj)
+{
+    virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+
+    def->capacity = defaultPoolCap;
+    def->allocation = defaultPoolAlloc;
+    def->available = defaultPoolCap - defaultPoolAlloc;
+
+    return 0;
+}
+
+
+static virPoolObjPtr
+testStoragePoolObjFindByUUID(virPoolObjTablePtr pools,
+                             const unsigned char *uuid)
 {
+    virPoolObjPtr obj;
 
-    pool->def->capacity = defaultPoolCap;
-    pool->def->allocation = defaultPoolAlloc;
-    pool->def->available = defaultPoolCap - defaultPoolAlloc;
+    if (!(obj = virPoolObjTableFindByUUIDRef(pools, uuid)))
+        virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
 
-    return VIR_STRDUP(pool->configFile, "");
+    return obj;
 }
 
 
@@ -3967,156 +3981,114 @@ testStoragePoolLookupByUUID(virConnectPtr conn,
                             const unsigned char *uuid)
 {
     testDriverPtr privconn = conn->privateData;
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStoragePoolPtr ret = NULL;
 
-    testDriverLock(privconn);
-    pool = virStoragePoolObjFindByUUID(&privconn->pools, uuid);
-    testDriverUnlock(privconn);
-
-    if (pool == NULL) {
-        virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByUUID(privconn->pools, uuid)))
+        return NULL;
+    def = virPoolObjGetDef(obj);
 
-    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
 
- cleanup:
-    if (pool)
-        virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
+static virPoolObjPtr
+testStoragePoolObjFromStoragePool(virStoragePoolPtr pool)
+{
+    testDriverPtr privconn = pool->conn->privateData;
+
+    return testStoragePoolObjFindByUUID(privconn->pools, pool->uuid);
+}
+
+
+static virPoolObjPtr
+testStoragePoolObjFindByName(virPoolObjTablePtr pools,
+                             const char *name)
+{
+    virPoolObjPtr obj;
+
+    if (!(obj = virPoolObjTableFindByName(pools, name)))
+        virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
+
+    return obj;
+}
+
+
 static virStoragePoolPtr
 testStoragePoolLookupByName(virConnectPtr conn,
                             const char *name)
 {
     testDriverPtr privconn = conn->privateData;
-    virStoragePoolObjPtr pool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     virStoragePoolPtr ret = NULL;
 
-    testDriverLock(privconn);
-    pool = virStoragePoolObjFindByName(&privconn->pools, name);
-    testDriverUnlock(privconn);
-
-    if (pool == NULL) {
-        virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, name)))
+        return NULL;
+    def = virPoolObjGetDef(obj);
 
-    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
 
- cleanup:
-    if (pool)
-        virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static virStoragePoolPtr
 testStoragePoolLookupByVolume(virStorageVolPtr vol)
 {
     return testStoragePoolLookupByName(vol->conn, vol->pool);
 }
 
+
 static int
 testConnectNumOfStoragePools(virConnectPtr conn)
 {
     testDriverPtr privconn = conn->privateData;
-    int numActive = 0;
-    size_t i;
 
-    testDriverLock(privconn);
-    for (i = 0; i < privconn->pools.count; i++)
-        if (virStoragePoolObjIsActive(privconn->pools.objs[i]))
-            numActive++;
-    testDriverUnlock(privconn);
-
-    return numActive;
+    return virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
+                                              true, NULL);
 }
 
+
 static int
 testConnectListStoragePools(virConnectPtr conn,
                             char **const names,
-                            int nnames)
+                            int maxnames)
 {
     testDriverPtr privconn = conn->privateData;
-    int n = 0;
-    size_t i;
 
-    testDriverLock(privconn);
-    memset(names, 0, sizeof(*names)*nnames);
-    for (i = 0; i < privconn->pools.count && n < nnames; i++) {
-        virStoragePoolObjLock(privconn->pools.objs[i]);
-        if (virStoragePoolObjIsActive(privconn->pools.objs[i]) &&
-            VIR_STRDUP(names[n++], privconn->pools.objs[i]->def->name) < 0) {
-            virStoragePoolObjUnlock(privconn->pools.objs[i]);
-            goto error;
-        }
-        virStoragePoolObjUnlock(privconn->pools.objs[i]);
-    }
-    testDriverUnlock(privconn);
-
-    return n;
-
- error:
-    for (n = 0; n < nnames; n++)
-        VIR_FREE(names[n]);
-    testDriverUnlock(privconn);
-    return -1;
+    return virStoragePoolObjGetNames(privconn->pools, conn, true, NULL,
+                                     names, maxnames);
 }
 
+
 static int
 testConnectNumOfDefinedStoragePools(virConnectPtr conn)
 {
     testDriverPtr privconn = conn->privateData;
-    int numInactive = 0;
-    size_t i;
 
-    testDriverLock(privconn);
-    for (i = 0; i < privconn->pools.count; i++) {
-        virStoragePoolObjLock(privconn->pools.objs[i]);
-        if (!virStoragePoolObjIsActive(privconn->pools.objs[i]))
-            numInactive++;
-        virStoragePoolObjUnlock(privconn->pools.objs[i]);
-    }
-    testDriverUnlock(privconn);
-
-    return numInactive;
+    return virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
+                                              false, NULL);
 }
 
+
 static int
 testConnectListDefinedStoragePools(virConnectPtr conn,
                                    char **const names,
-                                   int nnames)
+                                   int maxnames)
 {
     testDriverPtr privconn = conn->privateData;
-    int n = 0;
-    size_t i;
-
-    testDriverLock(privconn);
-    memset(names, 0, sizeof(*names)*nnames);
-    for (i = 0; i < privconn->pools.count && n < nnames; i++) {
-        virStoragePoolObjLock(privconn->pools.objs[i]);
-        if (!virStoragePoolObjIsActive(privconn->pools.objs[i]) &&
-            VIR_STRDUP(names[n++], privconn->pools.objs[i]->def->name) < 0) {
-            virStoragePoolObjUnlock(privconn->pools.objs[i]);
-            goto error;
-        }
-        virStoragePoolObjUnlock(privconn->pools.objs[i]);
-    }
-    testDriverUnlock(privconn);
 
-    return n;
-
- error:
-    for (n = 0; n < nnames; n++)
-        VIR_FREE(names[n]);
-    testDriverUnlock(privconn);
-    return -1;
+    return virStoragePoolObjGetNames(privconn->pools, conn, false, NULL,
+                                     names, maxnames);
 }
 
+
 static int
 testConnectListAllStoragePools(virConnectPtr conn,
                                virStoragePoolPtr **pools,
@@ -4127,86 +4099,65 @@ testConnectListAllStoragePools(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1);
 
-    testDriverLock(privconn);
-    ret = virStoragePoolObjListExport(conn, privconn->pools, pools,
+    ret = virStoragePoolObjExportList(conn, privconn->pools, pools,
                                       NULL, flags);
-    testDriverUnlock(privconn);
 
     return ret;
 }
 
-static int testStoragePoolIsActive(virStoragePoolPtr pool)
+
+static int
+testStoragePoolIsActive(virStoragePoolPtr pool)
 {
-    testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr obj;
+    virPoolObjPtr obj;
     int ret = -1;
 
-    testDriverLock(privconn);
-    obj = virStoragePoolObjFindByUUID(&privconn->pools, pool->uuid);
-    testDriverUnlock(privconn);
-    if (!obj) {
-        virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
-        goto cleanup;
-    }
-    ret = virStoragePoolObjIsActive(obj);
+    if (!(obj = testStoragePoolObjFromStoragePool(pool)))
+        return -1;
 
- cleanup:
-    if (obj)
-        virStoragePoolObjUnlock(obj);
+    ret = virPoolObjIsActive(obj);
+
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
-static int testStoragePoolIsPersistent(virStoragePoolPtr pool)
+static int
+testStoragePoolIsPersistent(virStoragePoolPtr pool)
 {
-    testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr obj;
+    virPoolObjPtr obj;
     int ret = -1;
 
-    testDriverLock(privconn);
-    obj = virStoragePoolObjFindByUUID(&privconn->pools, pool->uuid);
-    testDriverUnlock(privconn);
-    if (!obj) {
-        virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
-        goto cleanup;
-    }
-    ret = obj->configFile ? 1 : 0;
+    if (!(obj = testStoragePoolObjFromStoragePool(pool)))
+        return -1;
 
- cleanup:
-    if (obj)
-        virStoragePoolObjUnlock(obj);
+    ret = virStoragePoolObjPrivateGetConfigFile(obj) ? 1 : 0;
+
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
 
-
 static int
 testStoragePoolCreate(virStoragePoolPtr pool,
                       unsigned int flags)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     int ret = -1;
     virObjectEventPtr event = NULL;
 
     virCheckFlags(0, -1);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
 
-    if (virStoragePoolObjIsActive(privpool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
     }
 
-    privpool->active = 1;
+    virPoolObjSetActive(obj, true);
 
     event = virStoragePoolEventLifecycleNew(pool->name, pool->uuid,
                                             VIR_STORAGE_POOL_EVENT_STARTED,
@@ -4215,11 +4166,11 @@ testStoragePoolCreate(virStoragePoolPtr pool,
 
  cleanup:
     testObjectEventQueue(privconn, event);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static char *
 testConnectFindStoragePoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
                                   const char *type,
@@ -4232,18 +4183,15 @@ testConnectFindStoragePoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     virCheckFlags(0, NULL);
 
-    pool_type = virStoragePoolTypeFromString(type);
-    if (!pool_type) {
+    if (!(pool_type = virStoragePoolTypeFromString(type))) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unknown storage pool type %s"), type);
         goto cleanup;
     }
 
-    if (srcSpec) {
-        source = virStoragePoolDefParseSourceString(srcSpec, pool_type);
-        if (!source)
-            goto cleanup;
-    }
+    if (srcSpec &&
+        !(source = virStoragePoolDefParseSourceString(srcSpec, pool_type)))
+        goto cleanup;
 
     switch (pool_type) {
 
@@ -4280,52 +4228,49 @@ testStoragePoolCreateXML(virConnectPtr conn,
 {
     testDriverPtr privconn = conn->privateData;
     virStoragePoolDefPtr def;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr obj = NULL;
+    virStoragePoolDefPtr pooldef;
     virStoragePoolPtr ret = NULL;
     virObjectEventPtr event = NULL;
 
     virCheckFlags(0, NULL);
 
-    testDriverLock(privconn);
     if (!(def = virStoragePoolDefParseString(xml)))
         goto cleanup;
 
-    pool = virStoragePoolObjFindByUUID(&privconn->pools, def->uuid);
-    if (!pool)
-        pool = virStoragePoolObjFindByName(&privconn->pools, def->name);
-    if (pool) {
+    if (!(obj = virPoolObjTableFindByUUIDRef(privconn->pools, def->uuid)))
+        obj = virPoolObjTableFindByName(privconn->pools, def->name);
+
+    if (obj) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("storage pool already exists"));
         goto cleanup;
     }
 
-    if (!(pool = virStoragePoolObjAssignDef(&privconn->pools, def)))
+    if (!(obj = virStoragePoolObjAdd(privconn->pools, def)))
         goto cleanup;
-    def = NULL;
+    VIR_STEAL_PTR(pooldef, def);
 
-    if (testStoragePoolObjSetDefaults(pool) == -1) {
-        virStoragePoolObjRemove(&privconn->pools, pool);
-        pool = NULL;
+    if (testStoragePoolObjSetDefaults(obj) == -1) {
+        virPoolObjTableRemove(privconn->pools, &obj);
         goto cleanup;
     }
-    pool->active = 1;
+    virPoolObjSetActive(obj, true);
 
-    event = virStoragePoolEventLifecycleNew(pool->def->name, pool->def->uuid,
+    event = virStoragePoolEventLifecycleNew(pooldef->name, pooldef->uuid,
                                             VIR_STORAGE_POOL_EVENT_STARTED,
                                             0);
 
-    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(conn, pooldef->name, pooldef->uuid, NULL, NULL);
 
  cleanup:
     virStoragePoolDefFree(def);
     testObjectEventQueue(privconn, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    testDriverUnlock(privconn);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static virStoragePoolPtr
 testStoragePoolDefineXML(virConnectPtr conn,
                          const char *xml,
@@ -4333,13 +4278,13 @@ testStoragePoolDefineXML(virConnectPtr conn,
 {
     testDriverPtr privconn = conn->privateData;
     virStoragePoolDefPtr def;
-    virStoragePoolObjPtr pool = NULL;
+    virPoolObjPtr obj = NULL;
+    virStoragePoolDefPtr pooldef;
     virStoragePoolPtr ret = NULL;
     virObjectEventPtr event = NULL;
 
     virCheckFlags(0, NULL);
 
-    testDriverLock(privconn);
     if (!(def = virStoragePoolDefParseString(xml)))
         goto cleanup;
 
@@ -4347,50 +4292,41 @@ testStoragePoolDefineXML(virConnectPtr conn,
     def->allocation = defaultPoolAlloc;
     def->available = defaultPoolCap - defaultPoolAlloc;
 
-    if (!(pool = virStoragePoolObjAssignDef(&privconn->pools, def)))
+    if (!(obj = virStoragePoolObjAdd(privconn->pools, def)))
         goto cleanup;
-    def = NULL;
+    VIR_STEAL_PTR(pooldef, def);
 
-    event = virStoragePoolEventLifecycleNew(pool->def->name, pool->def->uuid,
+    event = virStoragePoolEventLifecycleNew(pooldef->name, pooldef->uuid,
                                             VIR_STORAGE_POOL_EVENT_DEFINED,
                                             0);
 
-    if (testStoragePoolObjSetDefaults(pool) == -1) {
-        virStoragePoolObjRemove(&privconn->pools, pool);
-        pool = NULL;
+    if (testStoragePoolObjSetDefaults(obj) == -1) {
+        virPoolObjTableRemove(privconn->pools, &obj);
         goto cleanup;
     }
 
-    ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
-                            NULL, NULL);
+    ret = virGetStoragePool(conn, pooldef->name, pooldef->uuid, NULL, NULL);
 
  cleanup:
     virStoragePoolDefFree(def);
     testObjectEventQueue(privconn, event);
-    if (pool)
-        virStoragePoolObjUnlock(pool);
-    testDriverUnlock(privconn);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
 testStoragePoolUndefine(virStoragePoolPtr pool)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     int ret = -1;
     virObjectEventPtr event = NULL;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
 
-    if (virStoragePoolObjIsActive(privpool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
@@ -4400,48 +4336,39 @@ testStoragePoolUndefine(virStoragePoolPtr pool)
                                             VIR_STORAGE_POOL_EVENT_UNDEFINED,
                                             0);
 
-    virStoragePoolObjRemove(&privconn->pools, privpool);
-    privpool = NULL;
+    virPoolObjTableRemove(privconn->pools, &obj);
     ret = 0;
 
  cleanup:
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     testObjectEventQueue(privconn, event);
-    testDriverUnlock(privconn);
     return ret;
 }
 
+
 static int
 testStoragePoolBuild(virStoragePoolPtr pool,
                      unsigned int flags)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     int ret = -1;
 
     virCheckFlags(0, -1);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
 
-    if (virStoragePoolObjIsActive(privpool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
     }
+
     ret = 0;
 
  cleanup:
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -4450,41 +4377,34 @@ static int
 testStoragePoolDestroy(virStoragePoolPtr pool)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     int ret = -1;
     virObjectEventPtr event = NULL;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
+    def = virPoolObjGetDef(obj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
 
-    privpool->active = 0;
-    event = virStoragePoolEventLifecycleNew(privpool->def->name, privpool->def->uuid,
+    virPoolObjSetActive(obj, false);
+    event = virStoragePoolEventLifecycleNew(def->name, def->uuid,
                                             VIR_STORAGE_POOL_EVENT_STOPPED,
                                             0);
 
-    if (privpool->configFile == NULL) {
-        virStoragePoolObjRemove(&privconn->pools, privpool);
-        privpool = NULL;
-    }
+    if (!virStoragePoolObjPrivateGetConfigFile(obj))
+        virPoolObjTableRemove(privconn->pools, &obj);
+
     ret = 0;
 
  cleanup:
     testObjectEventQueue(privconn, event);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
-    testDriverUnlock(privconn);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -4494,22 +4414,15 @@ testStoragePoolDelete(virStoragePoolPtr pool,
                       unsigned int flags)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     int ret = -1;
 
     virCheckFlags(0, -1);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
 
-    if (virStoragePoolObjIsActive(privpool)) {
+    if (virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is already active"), pool->name);
         goto cleanup;
@@ -4518,8 +4431,7 @@ testStoragePoolDelete(virStoragePoolPtr pool,
     ret = 0;
 
  cleanup:
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -4529,23 +4441,16 @@ testStoragePoolRefresh(virStoragePoolPtr pool,
                        unsigned int flags)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     int ret = -1;
     virObjectEventPtr event = NULL;
 
     virCheckFlags(0, -1);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
@@ -4556,8 +4461,7 @@ testStoragePoolRefresh(virStoragePoolPtr pool,
 
  cleanup:
     testObjectEventQueue(privconn, event);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -4567,125 +4471,94 @@ testStoragePoolGetInfo(virStoragePoolPtr pool,
                        virStoragePoolInfoPtr info)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
+    virStoragePoolDefPtr def;
     int ret = -1;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
+    def = virPoolObjGetDef(obj);
 
     memset(info, 0, sizeof(virStoragePoolInfo));
-    if (privpool->active)
+    if (virPoolObjIsActive(obj))
         info->state = VIR_STORAGE_POOL_RUNNING;
     else
         info->state = VIR_STORAGE_POOL_INACTIVE;
-    info->capacity = privpool->def->capacity;
-    info->allocation = privpool->def->allocation;
-    info->available = privpool->def->available;
+    info->capacity = def->capacity;
+    info->allocation = def->allocation;
+    info->available = def->available;
     ret = 0;
 
- cleanup:
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static char *
 testStoragePoolGetXMLDesc(virStoragePoolPtr pool,
                           unsigned int flags)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     char *ret = NULL;
 
     virCheckFlags(0, NULL);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return NULL;
 
-    ret = virStoragePoolDefFormat(privpool->def);
+    ret = virStoragePoolDefFormat(virPoolObjGetDef(obj));
 
- cleanup:
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
 testStoragePoolGetAutostart(virStoragePoolPtr pool,
                             int *autostart)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     int ret = -1;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
 
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    *autostart = 0;
+    if (virStoragePoolObjPrivateGetConfigFile(obj) &&
+        virPoolObjIsAutostart(obj))
+        *autostart = 1;
 
-    if (!privpool->configFile) {
-        *autostart = 0;
-    } else {
-        *autostart = privpool->autostart;
-    }
     ret = 0;
 
- cleanup:
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
+
 static int
 testStoragePoolSetAutostart(virStoragePoolPtr pool,
                             int autostart)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
     int ret = -1;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return -1;
 
-    if (!privpool->configFile) {
+    if (!virStoragePoolObjPrivateGetConfigFile(obj)) {
         virReportError(VIR_ERR_INVALID_ARG,
                        "%s", _("pool has no config file"));
         goto cleanup;
     }
 
-    autostart = (autostart != 0);
-    privpool->autostart = autostart;
+    virPoolObjSetAutostart(obj, (autostart != 0));
     ret = 0;
 
  cleanup:
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -4694,20 +4567,15 @@ static int
 testStoragePoolNumOfVolumes(virStoragePoolPtr pool)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
+    virPoolObjTablePtr objvolumes;
     int ret = -1;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (!privpool) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
         return -1;
-    }
+    objvolumes = virStoragePoolObjPrivateGetVolumes(obj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
@@ -4715,11 +4583,10 @@ testStoragePoolNumOfVolumes(virStoragePoolPtr pool)
 
     /* NB: Neither pool->def nor aclfilter is being used for test purposes
      * so last two args can be NULL */
-    ret = virStoragePoolObjNumOfVolumes(privpool->volumes, pool->conn,
-                                        NULL, NULL);
+    ret = virStoragePoolObjNumOfVolumes(objvolumes, pool->conn, NULL, NULL);
 
  cleanup:
-    virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
@@ -4732,21 +4599,16 @@ testStoragePoolListVolumes(virStoragePoolPtr pool,
 {
     int ret = -1;
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr obj;
+    virPoolObjTablePtr objvolumes;
 
     memset(names, 0, maxnames * sizeof(*names));
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (!privpool) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        return -1;
-    }
+    if (!(obj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        goto cleanup;
+    objvolumes = virStoragePoolObjPrivateGetVolumes(obj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
@@ -4754,22 +4616,24 @@ testStoragePoolListVolumes(virStoragePoolPtr pool,
 
     /* NB: Neither pool->def nor aclfilter is being used for test purposes
      * so those two args can be NULL */
-    ret = virStoragePoolObjListVolumes(privpool->volumes, pool->conn,
+    ret = virStoragePoolObjListVolumes(objvolumes, pool->conn,
                                        NULL, NULL, names, maxnames);
 
  cleanup:
-    virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&obj);
     return ret;
 }
 
 
 static int
-testStoragePoolListAllVolumes(virStoragePoolPtr obj,
+testStoragePoolListAllVolumes(virStoragePoolPtr pool,
                               virStorageVolPtr **volumes,
                               unsigned int flags)
 {
-    testDriverPtr privconn = obj->conn->privateData;
-    virStoragePoolObjPtr pool;
+    testDriverPtr privconn = pool->conn->privateData;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
+    virPoolObjTablePtr poolobjvolumes;
     virPoolObjPtr *volobjs = NULL;
     size_t nvolobjs = 0;
     size_t i;
@@ -4778,23 +4642,22 @@ testStoragePoolListAllVolumes(virStoragePoolPtr obj,
 
     virCheckFlags(0, -1);
 
-    testDriverLock(privconn);
-    pool = virStoragePoolObjFindByUUID(&privconn->pools, obj->uuid);
-    testDriverUnlock(privconn);
-
-    if (!pool) {
+    if (!(poolobj = testStoragePoolObjFindByUUID(privconn->pools,
+                                                 pool->uuid))) {
         virReportError(VIR_ERR_NO_STORAGE_POOL, "%s",
                        _("no storage pool with matching uuid"));
         return -1;
     }
+    pooldef = virPoolObjGetDef(poolobj);
+    poolobjvolumes = virStoragePoolObjPrivateGetVolumes(poolobj);
 
-    if (!virStoragePoolObjIsActive(pool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("storage pool is not active"));
         goto cleanup;
     }
 
-    if (virPoolObjTableCollect(pool->volumes, obj->conn, &volobjs, &nvolobjs,
+    if (virPoolObjTableCollect(poolobjvolumes, pool->conn, &volobjs, &nvolobjs,
                                NULL, NULL, flags) < 0)
         goto cleanup;
 
@@ -4804,12 +4667,12 @@ testStoragePoolListAllVolumes(virStoragePoolPtr obj,
 
         for (i = 0; i < nvolobjs; i++) {
             virPoolObjPtr volobj = volobjs[i];
-            virStorageVolDefPtr def;
+            virStorageVolDefPtr voldef;
 
             virObjectLock(volobj);
-            def = virPoolObjGetDef(volobj);
-            vols[i] = virGetStorageVol(obj->conn, pool->def->name,
-                                       def->name, def->key, NULL, NULL);
+            voldef = virPoolObjGetDef(volobj);
+            vols[i] = virGetStorageVol(pool->conn, pooldef->name,
+                                       voldef->name, voldef->key, NULL, NULL);
             virObjectUnlock(volobj);
 
             if (!vols[i])
@@ -4825,88 +4688,99 @@ testStoragePoolListAllVolumes(virStoragePoolPtr obj,
  cleanup:
     virObjectListFree(vols);
     virObjectListFreeCount(volobjs, nvolobjs);
-
-    virStoragePoolObjUnlock(pool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
 static virStorageVolPtr
 testStorageVolLookupByName(virStoragePoolPtr pool,
-                           const char *name ATTRIBUTE_UNUSED)
+                           const char *name)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef;
     virStorageVolPtr ret = NULL;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
-
+    if (!(poolobj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
 
-    if (!(volobj = virStorageVolObjFindByName(privpool, name))) {
+    if (!(volobj = virStorageVolObjFindByName(poolobj, name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"), name);
         goto cleanup;
     }
     voldef = virPoolObjGetDef(volobj);
 
-    ret = virGetStorageVol(pool->conn, privpool->def->name,
-                           voldef->name, voldef->key,
+    ret = virGetStorageVol(pool->conn, pooldef->name, voldef->name, voldef->key,
                            NULL, NULL);
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
 
+struct storageSearchData {
+    virConnectPtr conn;
+    const char *key;
+    const char *path;
+    char *retname;
+    char *retkey;
+};
+
+static bool
+storageVolSearchByKey(virPoolObjPtr obj,
+                      void *opaque)
+{
+    struct storageSearchData *data = opaque;
+
+    if (virPoolObjIsActive(obj)) {
+        virPoolObjPtr volobj;
+
+        if ((volobj = virStorageVolObjFindByKey(obj, data->key))) {
+            virStorageVolDefPtr voldef = virPoolObjGetDef(volobj);
+
+            ignore_value(VIR_STRDUP(data->retname, voldef->name));
+            virPoolObjEndAPI(&volobj);
+        }
+
+        if (data->retname)
+            return true;
+    }
+
+    return false;
+}
+
+
 static virStorageVolPtr
 testStorageVolLookupByKey(virConnectPtr conn,
                           const char *key)
 {
     testDriverPtr privconn = conn->privateData;
-    virPoolObjPtr volobj;
-    virStorageVolDefPtr voldef;
-    size_t i;
     virStorageVolPtr ret = NULL;
+    virPoolObjPtr obj;
+    struct storageSearchData data = { .conn = conn,
+                                      .key = key,
+                                      .retname = NULL };
 
-    testDriverLock(privconn);
-    for (i = 0; i < privconn->pools.count; i++) {
-        virStoragePoolObjLock(privconn->pools.objs[i]);
-        if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
-            if (!(volobj = virStorageVolObjFindByKey(privconn->pools.objs[i],
-                                                     key)))
-                continue;
-            voldef = virPoolObjGetDef(volobj);
+    if ((obj = virPoolObjTableSearchRef(privconn->pools, storageVolSearchByKey,
+                                        &data))) {
+        virStoragePoolDefPtr def = virPoolObjGetDef(obj);
 
-            ret = virGetStorageVol(conn,
-                                   privconn->pools.objs[i]->def->name,
-                                   voldef->name,
-                                   voldef->key,
-                                   NULL, NULL);
-            virPoolObjEndAPI(&volobj);
-            virStoragePoolObjUnlock(privconn->pools.objs[i]);
-            break;
-        }
-        virStoragePoolObjUnlock(privconn->pools.objs[i]);
+        ret = virGetStorageVol(conn, def->name, data.retname, key, NULL, NULL);
+        VIR_FREE(data.retname);
+        virPoolObjEndAPI(&obj);
     }
-    testDriverUnlock(privconn);
 
     if (!ret)
         virReportError(VIR_ERR_NO_STORAGE_VOL,
@@ -4915,37 +4789,57 @@ testStorageVolLookupByKey(virConnectPtr conn,
     return ret;
 }
 
+
+static bool
+storageVolSearchByPath(virPoolObjPtr obj,
+                       void *opaque)
+{
+    struct storageSearchData *data = opaque;
+
+    if (virPoolObjIsActive(obj)) {
+        virPoolObjPtr volobj;
+
+        if ((volobj = virStorageVolObjFindByPath(obj, data->path))) {
+            virStorageVolDefPtr voldef = virPoolObjGetDef(volobj);
+
+            ignore_value(VIR_STRDUP(data->retname, voldef->name));
+            ignore_value(VIR_STRDUP(data->retkey, voldef->key));
+
+            virPoolObjEndAPI(&volobj);
+        }
+
+        if (data->retname && data->retkey)
+            return true;
+
+        VIR_FREE(data->retname);
+        VIR_FREE(data->retkey);
+    }
+
+    return false;
+}
+
+
 static virStorageVolPtr
 testStorageVolLookupByPath(virConnectPtr conn,
                            const char *path)
 {
     testDriverPtr privconn = conn->privateData;
-    virPoolObjPtr volobj;
-    virStorageVolDefPtr voldef;
-    size_t i;
     virStorageVolPtr ret = NULL;
-
-    testDriverLock(privconn);
-    for (i = 0; i < privconn->pools.count; i++) {
-        virStoragePoolObjLock(privconn->pools.objs[i]);
-        if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
-            if (!(volobj = virStorageVolObjFindByPath(privconn->pools.objs[i],
-                                                      path)))
-                continue;
-            voldef = virPoolObjGetDef(volobj);
-
-            ret = virGetStorageVol(conn,
-                                   privconn->pools.objs[i]->def->name,
-                                   voldef->name,
-                                   voldef->key,
-                                   NULL, NULL);
-            virPoolObjEndAPI(&volobj);
-            virStoragePoolObjUnlock(privconn->pools.objs[i]);
-            break;
-        }
-        virStoragePoolObjUnlock(privconn->pools.objs[i]);
+    virPoolObjPtr obj;
+    struct storageSearchData data = { .conn = conn,
+                                      .path = path,
+                                      .retname = NULL,
+                                      .retkey = NULL };
+
+    if ((obj = virPoolObjTableSearchRef(privconn->pools, storageVolSearchByPath,
+                                        &data))) {
+        virStoragePoolDefPtr def = virPoolObjGetDef(obj);
+        ret = virGetStorageVol(conn, def->name, data.retname, data.retkey,
+                               NULL, NULL);
+        VIR_FREE(data.retname);
+        VIR_FREE(data.retkey);
+        virPoolObjEndAPI(&obj);
     }
-    testDriverUnlock(privconn);
 
     if (!ret)
         virReportError(VIR_ERR_NO_STORAGE_VOL,
@@ -4954,13 +4848,15 @@ testStorageVolLookupByPath(virConnectPtr conn,
     return ret;
 }
 
+
 static virStorageVolPtr
 testStorageVolCreateXML(virStoragePoolPtr pool,
                         const char *xmldesc,
                         unsigned int flags)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virStorageVolDefPtr voldef = NULL;
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr objvoldef;
@@ -4968,34 +4864,27 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
 
     virCheckFlags(0, NULL);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(poolobj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
 
-    if (!(voldef = virStorageVolDefParseString(privpool->def, xmldesc, 0)))
+    if (!(voldef = virStorageVolDefParseString(pooldef, xmldesc, 0)))
         goto cleanup;
 
-    if ((volobj = virStorageVolObjFindByName(privpool, voldef->name))) {
+    if ((volobj = virStorageVolObjFindByName(poolobj, voldef->name))) {
         virReportError(VIR_ERR_OPERATION_FAILED,
                        "%s", _("storage vol already exists"));
         goto cleanup;
     }
 
     /* Make sure enough space */
-    if ((privpool->def->allocation + voldef->target.allocation) >
-         privpool->def->capacity) {
+    if ((pooldef->allocation + voldef->target.allocation) > pooldef->capacity) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Not enough free space in pool for volume '%s'"),
                        voldef->name);
@@ -5003,34 +4892,32 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
     }
 
     if (virAsprintf(&voldef->target.path, "%s/%s",
-                    privpool->def->target.path,
-                    voldef->name) == -1)
+                    pooldef->target.path, voldef->name) < 0)
         goto cleanup;
 
     if (VIR_STRDUP(voldef->key, voldef->target.path) < 0)
         goto cleanup;
 
-    if (!(volobj = virStoragePoolObjAddVolume(privpool, voldef)))
+    if (!(volobj = virStoragePoolObjAddVolume(poolobj, voldef)))
         goto cleanup;
     VIR_STEAL_PTR(objvoldef, voldef);
 
-    privpool->def->allocation += objvoldef->target.allocation;
-    privpool->def->available = (privpool->def->capacity -
-                                privpool->def->allocation);
+    pooldef->allocation += objvoldef->target.allocation;
+    pooldef->available = pooldef->capacity - pooldef->allocation;
 
-    if (!(ret = virGetStorageVol(pool->conn, privpool->def->name,
+    if (!(ret = virGetStorageVol(pool->conn, pooldef->name,
                                  objvoldef->name, objvoldef->key,
                                  NULL, NULL)))
-        virStoragePoolObjRemoveVolume(privpool, &volobj);
+        virStoragePoolObjRemoveVolume(poolobj, &volobj);
 
  cleanup:
     virPoolObjEndAPI(&volobj);
     virStorageVolDefFree(voldef);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
+
 static virStorageVolPtr
 testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
                             const char *xmldesc,
@@ -5038,41 +4925,36 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
                             unsigned int flags)
 {
     testDriverPtr privconn = pool->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virStorageVolDefPtr voldef = NULL;
     virPoolObjPtr volobj = NULL;
-    virStorageVolDefPtr objvoldef;
+    virStorageVolDefPtr objvoldef = NULL;
     virPoolObjPtr origvolobj = NULL;
     virStorageVolPtr ret = NULL;
 
     virCheckFlags(0, NULL);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           pool->name);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(poolobj = testStoragePoolObjFindByName(privconn->pools, pool->name)))
+        return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), pool->name);
         goto cleanup;
     }
 
-    if (!(voldef = virStorageVolDefParseString(privpool->def, xmldesc, 0)))
+    if (!(voldef = virStorageVolDefParseString(pooldef, xmldesc, 0)))
         goto cleanup;
 
-    if ((volobj = virStorageVolObjFindByName(privpool, voldef->name))) {
+    if ((volobj = virStorageVolObjFindByName(poolobj, voldef->name))) {
         virReportError(VIR_ERR_OPERATION_FAILED,
                        "%s", _("storage vol already exists"));
         goto cleanup;
     }
 
-    if (!(origvolobj = virStorageVolObjFindByName(privpool, clonevol->name))) {
+    if (!(origvolobj = virStorageVolObjFindByName(poolobj, clonevol->name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        clonevol->name);
@@ -5080,76 +4962,69 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     }
 
     /* Make sure enough space */
-    if ((privpool->def->allocation + voldef->target.allocation) >
-         privpool->def->capacity) {
+    if ((pooldef->allocation + voldef->target.allocation) > pooldef->capacity) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Not enough free space in pool for volume '%s'"),
                        voldef->name);
         goto cleanup;
     }
-    privpool->def->available = (privpool->def->capacity -
-                                privpool->def->allocation);
+    pooldef->available = pooldef->capacity - pooldef->allocation;
 
     if (virAsprintf(&voldef->target.path, "%s/%s",
-                    privpool->def->target.path,
-                    voldef->name) == -1)
+                    pooldef->target.path, voldef->name) < 0)
         goto cleanup;
 
     if (VIR_STRDUP(voldef->key, voldef->target.path) < 0)
         goto cleanup;
 
-    if (!(volobj = virStoragePoolObjAddVolume(privpool, voldef)))
+    if (!(volobj = virStoragePoolObjAddVolume(poolobj, voldef)))
         goto cleanup;
     VIR_STEAL_PTR(objvoldef, voldef);
 
-    privpool->def->allocation += objvoldef->target.allocation;
-    privpool->def->available = (privpool->def->capacity -
-                                privpool->def->allocation);
+    pooldef->allocation += objvoldef->target.allocation;
+    pooldef->available = pooldef->capacity - pooldef->allocation;
+
+    if (!(ret = virGetStorageVol(pool->conn, pooldef->name, objvoldef->name,
+                                 objvoldef->key, NULL, NULL)))
+        virStoragePoolObjRemoveVolume(poolobj, &volobj);
 
-    if (!(ret = virGetStorageVol(pool->conn, privpool->def->name,
-                                 objvoldef->name, objvoldef->key,
-                                 NULL, NULL)))
-        virStoragePoolObjRemoveVolume(privpool, &volobj);
 
  cleanup:
     virPoolObjEndAPI(&origvolobj);
     virPoolObjEndAPI(&volobj);
     virStorageVolDefFree(voldef);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
+
 static int
 testStorageVolDelete(virStorageVolPtr volume,
                      unsigned int flags)
 {
     testDriverPtr privconn = volume->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
+    virPoolObjTablePtr poolobjvolumes;
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef;
     int ret = -1;
 
     virCheckFlags(0, -1);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           volume->pool);
-    testDriverUnlock(privconn);
-
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
-        goto cleanup;
-    }
+    if (!(poolobj = testStoragePoolObjFindByName(privconn->pools,
+                                                 volume->pool)))
+        return -1;
+    pooldef = virPoolObjGetDef(poolobj);
+    poolobjvolumes = virStoragePoolObjPrivateGetVolumes(poolobj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
+    if (!virPoolObjIsActive(poolobj)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("storage pool '%s' is not active"), volume->pool);
         goto cleanup;
     }
 
-    if (!(volobj = virPoolObjTableFindByName(privpool->volumes,
-                                             volume->name))) {
+    if (!(volobj = virPoolObjTableFindByName(poolobjvolumes, volume->name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        volume->name);
@@ -5157,19 +5032,16 @@ testStorageVolDelete(virStorageVolPtr volume,
     }
     voldef = virPoolObjGetDef(volobj);
 
-    privpool->def->allocation -= voldef->target.allocation;
-    privpool->def->available = (privpool->def->capacity -
-                                privpool->def->allocation);
+    pooldef->allocation -= voldef->target.allocation;
+    pooldef->available = pooldef->capacity - pooldef->allocation;
 
-
-    virStoragePoolObjRemoveVolume(privpool, &volobj);
+    virPoolObjTableRemove(poolobjvolumes, &volobj);
 
     ret = 0;
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
@@ -5187,27 +5059,30 @@ static int testStorageVolumeTypeForPool(int pooltype)
     }
 }
 
+
 static int
 testStorageVolGetInfo(virStorageVolPtr volume,
                       virStorageVolInfoPtr info)
 {
     testDriverPtr privconn = volume->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef;
     int ret = -1;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           volume->pool);
-    testDriverUnlock(privconn);
+    if (!(poolobj = testStoragePoolObjFindByName(privconn->pools,
+                                                 volume->pool)))
+        return -1;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+    if (!virPoolObjIsActive(poolobj)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("storage pool '%s' is not active"), volume->pool);
         goto cleanup;
     }
 
-    if (!(volobj = virStorageVolObjFindByName(privpool, volume->name))) {
+    if (!(volobj = virStorageVolObjFindByName(poolobj, volume->name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        volume->name);
@@ -5215,48 +5090,44 @@ testStorageVolGetInfo(virStorageVolPtr volume,
     }
     voldef = virPoolObjGetDef(volobj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), volume->pool);
-        goto cleanup;
-    }
-
     memset(info, 0, sizeof(*info));
-    info->type = testStorageVolumeTypeForPool(privpool->def->type);
+    info->type = testStorageVolumeTypeForPool(pooldef->type);
     info->capacity = voldef->target.capacity;
     info->allocation = voldef->target.allocation;
     ret = 0;
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
+
 static char *
 testStorageVolGetXMLDesc(virStorageVolPtr volume,
                          unsigned int flags)
 {
     testDriverPtr privconn = volume->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr poolobj;
+    virStoragePoolDefPtr pooldef;
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef;
     char *ret = NULL;
 
     virCheckFlags(0, NULL);
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           volume->pool);
-    testDriverUnlock(privconn);
+    if (!(poolobj = testStoragePoolObjFindByName(privconn->pools,
+                                                 volume->pool)))
+        return NULL;
+    pooldef = virPoolObjGetDef(poolobj);
 
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+    if (!virPoolObjIsActive(poolobj)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("storage pool '%s' is not active"), volume->pool);
         goto cleanup;
     }
 
-    if (!(volobj = virStorageVolObjFindByName(privpool, volume->name))) {
+    if (!(volobj = virStorageVolObjFindByName(poolobj, volume->name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        volume->name);
@@ -5264,41 +5135,35 @@ testStorageVolGetXMLDesc(virStorageVolPtr volume,
     }
     voldef = virPoolObjGetDef(volobj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), volume->pool);
-        goto cleanup;
-    }
-
-    ret = virStorageVolDefFormat(privpool->def, voldef);
+    ret = virStorageVolDefFormat(pooldef, voldef);
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
+
 static char *
 testStorageVolGetPath(virStorageVolPtr volume)
 {
     testDriverPtr privconn = volume->conn->privateData;
-    virStoragePoolObjPtr privpool;
+    virPoolObjPtr poolobj;
     virPoolObjPtr volobj = NULL;
     virStorageVolDefPtr voldef;
     char *ret = NULL;
 
-    testDriverLock(privconn);
-    privpool = virStoragePoolObjFindByName(&privconn->pools,
-                                           volume->pool);
-    testDriverUnlock(privconn);
+    if (!(poolobj = testStoragePoolObjFindByName(privconn->pools,
+                                                 volume->pool)))
+        return NULL;
 
-    if (privpool == NULL) {
-        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+    if (!virPoolObjIsActive(poolobj)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("storage pool '%s' is not active"), volume->pool);
         goto cleanup;
     }
 
-    if (!(volobj = virStorageVolObjFindByName(privpool, volume->name))) {
+    if (!(volobj = virStorageVolObjFindByName(poolobj, volume->name))) {
         virReportError(VIR_ERR_NO_STORAGE_VOL,
                        _("no storage vol with matching name '%s'"),
                        volume->name);
@@ -5306,18 +5171,11 @@ testStorageVolGetPath(virStorageVolPtr volume)
     }
     voldef = virPoolObjGetDef(volobj);
 
-    if (!virStoragePoolObjIsActive(privpool)) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("storage pool '%s' is not active"), volume->pool);
-        goto cleanup;
-    }
-
     ignore_value(VIR_STRDUP(ret, voldef->target.path));
 
  cleanup:
     virPoolObjEndAPI(&volobj);
-    if (privpool)
-        virStoragePoolObjUnlock(privpool);
+    virPoolObjEndAPI(&poolobj);
     return ret;
 }
 
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index bf9dbe5..b2a16d3 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -5,6 +5,7 @@
 #include "datatypes.h"
 #include "storage/storage_util.h"
 #include "testutilsqemu.h"
+#include "virpoolobj.h"
 #include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
@@ -52,7 +53,8 @@ testCompareXMLToArgvFiles(bool shouldFail,
     virStorageVolDefPtr vol = NULL, inputvol = NULL;
     virStoragePoolDefPtr pool = NULL;
     virStoragePoolDefPtr inputpool = NULL;
-    virStoragePoolObj poolobj = {.def = NULL };
+    virPoolObjPtr poolobj = NULL;
+    virStoragePoolDefPtr pooldef;
 
 
     if (!(conn = virGetConnect()))
@@ -61,7 +63,10 @@ testCompareXMLToArgvFiles(bool shouldFail,
     if (!(pool = virStoragePoolDefParseFile(poolxml)))
         goto cleanup;
 
-    poolobj.def = pool;
+    if (!(poolobj = virPoolObjNew(NULL, pool, NULL, virStoragePoolDefFree)))
+        goto cleanup;
+    virObjectRef(poolobj);
+    VIR_STEAL_PTR(pooldef, pool);
 
     if (inputpoolxml) {
         if (!(inputpool = virStoragePoolDefParseFile(inputpoolxml)))
@@ -71,17 +76,17 @@ testCompareXMLToArgvFiles(bool shouldFail,
     if (inputvolxml)
         parse_flags |= VIR_VOL_XML_PARSE_NO_CAPACITY;
 
-    if (!(vol = virStorageVolDefParseFile(pool, volxml, parse_flags)))
+    if (!(vol = virStorageVolDefParseFile(pooldef, volxml, parse_flags)))
         goto cleanup;
 
     if (inputvolxml &&
         !(inputvol = virStorageVolDefParseFile(inputpool, inputvolxml, 0)))
         goto cleanup;
 
-    testSetVolumeType(vol, pool);
+    testSetVolumeType(vol, pooldef);
     testSetVolumeType(inputvol, inputpool);
 
-    cmd = virStorageBackendCreateQemuImgCmdFromVol(conn, &poolobj, vol,
+    cmd = virStorageBackendCreateQemuImgCmdFromVol(conn, poolobj, vol,
                                                    inputvol, flags,
                                                    create_tool, imgformat,
                                                    NULL);
@@ -103,6 +108,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
 
  cleanup:
     virStoragePoolDefFree(pool);
+    virObjectUnref(poolobj);
     virStoragePoolDefFree(inputpool);
     virStorageVolDefFree(vol);
     virStorageVolDefFree(inputvol);
-- 
2.7.4


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