Now that we can open connections to the secondary drivers on demand,
there is no need to pass a virConnectPtr into all the backend
functions.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/storage/storage_backend.h | 45 ++++++-----------
src/storage/storage_backend_disk.c | 30 +++++-------
src/storage/storage_backend_fs.c | 15 ++----
src/storage/storage_backend_gluster.c | 9 ++--
src/storage/storage_backend_iscsi.c | 12 ++---
src/storage/storage_backend_logical.c | 36 +++++---------
src/storage/storage_backend_mpath.c | 5 +-
src/storage/storage_backend_rbd.c | 24 +++------
src/storage/storage_backend_scsi.c | 46 ++++++++++--------
src/storage/storage_backend_sheepdog.c | 33 +++++--------
src/storage/storage_backend_vstorage.c | 10 ++--
src/storage/storage_backend_zfs.c | 15 ++----
src/storage/storage_driver.c | 89 +++++++++++++++-------------------
src/storage/storage_util.c | 59 ++++++++--------------
src/storage/storage_util.h | 33 +++++--------
tests/storagevolxml2argvtest.c | 7 +--
16 files changed, 179 insertions(+), 289 deletions(-)
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 193cf134d6..8dbe344149 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -25,22 +25,16 @@
# include "virstorageobj.h"
# include "storage_driver.h"
-typedef char * (*virStorageBackendFindPoolSources)(virConnectPtr conn,
- const char *srcSpec,
+typedef char * (*virStorageBackendFindPoolSources)(const char *srcSpec,
unsigned int flags);
typedef int (*virStorageBackendCheckPool)(virStoragePoolObjPtr pool,
bool *active);
-typedef int (*virStorageBackendStartPool)(virConnectPtr conn,
- virStoragePoolObjPtr pool);
-typedef int (*virStorageBackendBuildPool)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendStartPool)(virStoragePoolObjPtr pool);
+typedef int (*virStorageBackendBuildPool)(virStoragePoolObjPtr pool,
unsigned int flags);
-typedef int (*virStorageBackendRefreshPool)(virConnectPtr conn,
- virStoragePoolObjPtr pool);
-typedef int (*virStorageBackendStopPool)(virConnectPtr conn,
- virStoragePoolObjPtr pool);
-typedef int (*virStorageBackendDeletePool)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendRefreshPool)(virStoragePoolObjPtr pool);
+typedef int (*virStorageBackendStopPool)(virStoragePoolObjPtr pool);
+typedef int (*virStorageBackendDeletePool)(virStoragePoolObjPtr pool,
unsigned int flags);
/* A 'buildVol' backend must remove any volume created on error since
@@ -52,46 +46,37 @@ typedef int (*virStorageBackendDeletePool)(virConnectPtr conn,
* was not aware of between checking the pool and the create attempt. It
* also avoids extra round trips to just delete a file.
*/
-typedef int (*virStorageBackendBuildVol)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendBuildVol)(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags);
-typedef int (*virStorageBackendCreateVol)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendCreateVol)(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol);
-typedef int (*virStorageBackendRefreshVol)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendRefreshVol)(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol);
-typedef int (*virStorageBackendDeleteVol)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendDeleteVol)(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags);
-typedef int (*virStorageBackendBuildVolFrom)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendBuildVolFrom)(virStoragePoolObjPtr pool,
virStorageVolDefPtr origvol,
virStorageVolDefPtr newvol,
unsigned int flags);
-typedef int (*virStorageBackendVolumeResize)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendVolumeResize)(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned long long capacity,
unsigned int flags);
-typedef int (*virStorageBackendVolumeDownload)(virConnectPtr conn,
- virStoragePoolObjPtr obj,
+typedef int (*virStorageBackendVolumeDownload)(virStoragePoolObjPtr obj,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
unsigned long long length,
unsigned int flags);
-typedef int (*virStorageBackendVolumeUpload)(virConnectPtr conn,
- virStoragePoolObjPtr obj,
+typedef int (*virStorageBackendVolumeUpload)(virStoragePoolObjPtr obj,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
unsigned long long len,
unsigned int flags);
-typedef int (*virStorageBackendVolumeWipe)(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+typedef int (*virStorageBackendVolumeWipe)(virStoragePoolObjPtr pool,
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 f862a896b0..7b4549c34d 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -439,8 +439,7 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
}
static int
-virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendDiskRefreshPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -464,8 +463,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
static int
-virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendDiskStartPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
const char *format;
@@ -493,8 +491,7 @@ virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
* Write a new partition table header
*/
static int
-virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendDiskBuildPool(virStoragePoolObjPtr pool,
unsigned int flags)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -751,7 +748,6 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
/* virStorageBackendDiskDeleteVol
- * @conn: Pointer to a libvirt connection
* @pool: Pointer to the storage pool
* @vol: Pointer to the volume definition
* @flags: flags (unused for now)
@@ -776,8 +772,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
* Returns 0 on success, -1 on failure with error message set.
*/
static int
-virStorageBackendDiskDeleteVol(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendDiskDeleteVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -856,7 +851,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
* here is pointless
*/
virStoragePoolObjClearVols(pool);
- if (virStorageBackendDiskRefreshPool(conn, pool) < 0)
+ if (virStorageBackendDiskRefreshPool(pool) < 0)
goto cleanup;
rc = 0;
@@ -868,8 +863,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
static int
-virStorageBackendDiskCreateVol(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendDiskCreateVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
int res = -1;
@@ -921,7 +915,7 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
* 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(pool, vol, 0));
virSetError(save_err);
virFreeError(save_err);
goto cleanup;
@@ -936,8 +930,7 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
}
static int
-virStorageBackendDiskBuildVolFrom(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendDiskBuildVolFrom(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -948,19 +941,18 @@ virStorageBackendDiskBuildVolFrom(virConnectPtr conn,
if (!build_func)
return -1;
- return build_func(conn, pool, vol, inputvol, flags);
+ return build_func(pool, vol, inputvol, flags);
}
static int
-virStorageBackendDiskVolWipe(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendDiskVolWipe(virStoragePoolObjPtr pool,
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(pool, 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 f54759983c..b3bae38437 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -145,8 +145,7 @@ virStorageBackendFileSystemNetFindNFSPoolSources(virNetfsDiscoverState
*state)
static char *
-virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
- const char *srcSpec,
+virStorageBackendFileSystemNetFindPoolSources(const char *srcSpec,
unsigned int flags)
{
virNetfsDiscoverState state = {
@@ -427,7 +426,6 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
/**
- * @conn connection to report errors against
* @pool storage pool to start
*
* Starts a directory or FS based storage pool. The underlying source
@@ -436,8 +434,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
* Returns 0 on success, -1 on error
*/
static int
-virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendFileSystemStart(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -450,7 +447,6 @@ virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
/**
- * @conn connection to report errors against
* @pool storage pool to unmount
*
* Stops a file storage pool. The underlying source device is unmounted
@@ -462,8 +458,7 @@ virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
* Returns 0 if successfully unmounted, -1 on error
*/
static int
-virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendFileSystemStop(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = NULL;
@@ -609,7 +604,6 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
/**
- * @conn connection to report errors against
* @pool storage pool to build
* @flags controls the pool formatting behaviour
*
@@ -630,8 +624,7 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
* Returns 0 on success, -1 on error
*/
static int
-virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendFileSystemBuild(virStoragePoolObjPtr pool,
unsigned int flags)
{
virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
diff --git a/src/storage/storage_backend_gluster.c
b/src/storage/storage_backend_gluster.c
index 5eea84f16e..6e4f19f76d 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -342,8 +342,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr
state,
}
static int
-virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendGlusterRefreshPool(virStoragePoolObjPtr pool)
{
int ret = -1;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -423,8 +422,7 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendGlusterVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendGlusterVolDelete(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -485,8 +483,7 @@ virStorageBackendGlusterVolDelete(virConnectPtr conn
ATTRIBUTE_UNUSED,
static char *
-virStorageBackendGlusterFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
- const char *srcSpec,
+virStorageBackendGlusterFindPoolSources(const char *srcSpec,
unsigned int flags)
{
virStoragePoolSourceList list = { .type = VIR_STORAGE_POOL_GLUSTER,
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 921215c9e9..11addec9a8 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -158,8 +158,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
static char *
-virStorageBackendISCSIFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
- const char *srcSpec,
+virStorageBackendISCSIFindPoolSources(const char *srcSpec,
unsigned int flags)
{
virStoragePoolSourcePtr source = NULL;
@@ -324,8 +323,7 @@ virStorageBackendISCSISetAuth(const char *portal,
}
static int
-virStorageBackendISCSIStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendISCSIStartPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
char *portal = NULL;
@@ -377,8 +375,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendISCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendISCSIRefreshPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
char *session = NULL;
@@ -402,8 +399,7 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendISCSIStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendISCSIStopPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
char *portal;
diff --git a/src/storage/storage_backend_logical.c
b/src/storage/storage_backend_logical.c
index 64bfc8c976..6a7d59bd57 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -588,8 +588,7 @@ virStorageBackendLogicalGetPoolSources(virStoragePoolSourceListPtr
sourceList)
static char *
-virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
- const char *srcSpec ATTRIBUTE_UNUSED,
+virStorageBackendLogicalFindPoolSources(const char *srcSpec ATTRIBUTE_UNUSED,
unsigned int flags)
{
virStoragePoolSourceList sourceList;
@@ -728,8 +727,7 @@ virStorageBackendLogicalCheckPool(virStoragePoolObjPtr pool,
}
static int
-virStorageBackendLogicalStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendLogicalStartPool(virStoragePoolObjPtr pool)
{
/* Let's make sure that the pool's name matches the pvs output and
* that the pool's source devices match the pvs output.
@@ -743,8 +741,7 @@ virStorageBackendLogicalStartPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendLogicalBuildPool(virStoragePoolObjPtr pool,
unsigned int flags)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -799,8 +796,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendLogicalRefreshPool(virStoragePoolObjPtr pool)
{
/*
* # vgs --separator : --noheadings --units b --unbuffered --nosuffix --options
"vg_size,vg_free" VGNAME
@@ -862,8 +858,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
* "Can't deactivate volume group "VolGroup00" with 3 open logical
volume(s)"
*/
static int
-virStorageBackendLogicalStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendLogicalStopPool(virStoragePoolObjPtr pool)
{
if (virStorageBackendLogicalSetActive(pool, 0) < 0)
return -1;
@@ -872,8 +867,7 @@ virStorageBackendLogicalStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendLogicalDeletePool(virStoragePoolObjPtr pool,
unsigned int flags)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -903,8 +897,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendLogicalDeleteVol(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -977,8 +970,7 @@ virStorageBackendLogicalLVCreate(virStorageVolDefPtr vol,
static int
-virStorageBackendLogicalCreateVol(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendLogicalCreateVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
int fd = -1;
@@ -1042,15 +1034,14 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
error:
err = virSaveLastError();
VIR_FORCE_CLOSE(fd);
- virStorageBackendLogicalDeleteVol(conn, pool, vol, 0);
+ virStorageBackendLogicalDeleteVol(pool, vol, 0);
virSetError(err);
virFreeError(err);
return -1;
}
static int
-virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendLogicalBuildVolFrom(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -1061,18 +1052,17 @@ virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
if (!build_func)
return -1;
- return build_func(conn, pool, vol, inputvol, flags);
+ return build_func(pool, vol, inputvol, flags);
}
static int
-virStorageBackendLogicalVolWipe(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendLogicalVolWipe(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int algorithm,
unsigned int flags)
{
if (!vol->target.sparse)
- return virStorageBackendVolWipeLocal(conn, pool, vol, algorithm, flags);
+ return virStorageBackendVolWipeLocal(pool, 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 4bc39c24eb..5dcc40f601 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -256,13 +256,12 @@ virStorageBackendMpathCheckPool(virStoragePoolObjPtr pool
ATTRIBUTE_UNUSED,
static int
-virStorageBackendMpathRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendMpathRefreshPool(virStoragePoolObjPtr pool)
{
int retval = 0;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- VIR_DEBUG("conn=%p, pool=%p", conn, pool);
+ VIR_DEBUG("pool=%p", pool);
def->allocation = def->capacity = def->available = 0;
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index e901f370d5..d646b86c73 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -420,8 +420,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
}
static int
-virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
{
size_t max_size = 1024;
int ret = -1;
@@ -602,8 +601,7 @@ virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioctx,
}
static int
-virStorageBackendRBDDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendRBDDeleteVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -647,8 +645,7 @@ virStorageBackendRBDDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
static int
-virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendRBDCreateVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -682,8 +679,7 @@ static int virStorageBackendRBDCreateImage(rados_ioctx_t io,
}
static int
-virStorageBackendRBDBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendRBDBuildVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -1038,8 +1034,7 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io,
}
static int
-virStorageBackendRBDBuildVolFrom(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendRBDBuildVolFrom(virStoragePoolObjPtr pool,
virStorageVolDefPtr newvol,
virStorageVolDefPtr origvol,
unsigned int flags)
@@ -1068,8 +1063,7 @@ virStorageBackendRBDBuildVolFrom(virConnectPtr conn
ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendRBDRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendRBDRefreshVol(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol)
{
virStorageBackendRBDStatePtr ptr = NULL;
@@ -1089,8 +1083,7 @@ virStorageBackendRBDRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendRBDResizeVol(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
unsigned long long capacity,
unsigned int flags)
@@ -1201,8 +1194,7 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image,
}
static int
-virStorageBackendRBDVolWipe(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendRBDVolWipe(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int algorithm,
unsigned int flags)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 9347d66384..115df6c847 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -245,20 +245,20 @@ checkName(const char *name)
* sysfs tree to get the parent 'scsi_host#' to ensure it matches.
*/
static bool
-checkParent(virConnectPtr conn,
- const char *name,
+checkParent(const char *name,
const char *parent_name)
{
unsigned int host_num;
char *scsi_host_name = NULL;
char *vhba_parent = NULL;
bool retval = false;
+ virConnectPtr conn = NULL;
- VIR_DEBUG("conn=%p, name=%s, parent_name=%s", conn, name, parent_name);
+ VIR_DEBUG("name=%s, parent_name=%s", name, parent_name);
- /* autostarted pool - assume we're OK */
+ conn = virConnectOpen(geteuid() == 0 ? "nodedev:///system" :
"nodedev:///session");
if (!conn)
- return true;
+ return -1;
if (virSCSIHostGetNumber(parent_name, &host_num) < 0) {
virReportError(VIR_ERR_XML_ERROR,
@@ -291,6 +291,7 @@ checkParent(virConnectPtr conn,
retval = true;
cleanup:
+ virObjectUnref(conn);
VIR_FREE(vhba_parent);
VIR_FREE(scsi_host_name);
return retval;
@@ -298,8 +299,7 @@ checkParent(virConnectPtr conn,
static int
-createVport(virConnectPtr conn,
- virStoragePoolDefPtr def,
+createVport(virStoragePoolDefPtr def,
const char *configFile,
virStorageAdapterFCHostPtr fchost)
{
@@ -308,8 +308,8 @@ createVport(virConnectPtr conn,
virThread thread;
int ret = -1;
- VIR_DEBUG("conn=%p, configFile='%s' parent='%s',
wwnn='%s' wwpn='%s'",
- conn, NULLSTR(configFile), NULLSTR(fchost->parent),
+ VIR_DEBUG("configFile='%s' parent='%s', wwnn='%s'
wwpn='%s'",
+ NULLSTR(configFile), NULLSTR(fchost->parent),
fchost->wwnn, fchost->wwpn);
/* If we find an existing HBA/vHBA within the fc_host sysfs
@@ -322,7 +322,7 @@ createVport(virConnectPtr conn,
/* If a parent was provided, let's make sure the 'name' we've
* retrieved has the same parent. If not this will cause failure. */
- if (!fchost->parent || checkParent(conn, name, fchost->parent))
+ if (!fchost->parent || checkParent(name, fchost->parent))
ret = 0;
goto cleanup;
@@ -411,8 +411,7 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
}
static int
-virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendSCSIRefreshPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
char *name = NULL;
@@ -443,14 +442,13 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendSCSIStartPool(virConnectPtr conn,
- virStoragePoolObjPtr pool)
+virStorageBackendSCSIStartPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
const char *configFile = virStoragePoolObjGetConfigFile(pool);
if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST)
- return createVport(conn, def, configFile,
+ return createVport(def, configFile,
&def->source.adapter.data.fchost);
return 0;
@@ -458,14 +456,22 @@ virStorageBackendSCSIStartPool(virConnectPtr conn,
static int
-virStorageBackendSCSIStopPool(virConnectPtr conn,
- virStoragePoolObjPtr pool)
+virStorageBackendSCSIStopPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST)
- return virNodeDeviceDeleteVport(conn,
- &def->source.adapter.data.fchost);
+ if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) {
+ virConnectPtr conn;
+ int ret;
+ conn = virConnectOpen(geteuid() == 0 ? "nodedev:///system" :
"nodedev:///session");
+ if (!conn)
+ return -1;
+
+ ret = virNodeDeviceDeleteVport(conn,
+ &def->source.adapter.data.fchost);
+ virObjectUnref(conn);
+ return ret;
+ }
return 0;
}
diff --git a/src/storage/storage_backend_sheepdog.c
b/src/storage/storage_backend_sheepdog.c
index 3d9c341a11..34c118fb32 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -38,8 +38,7 @@
#define VIR_FROM_THIS VIR_FROM_STORAGE
-static int virStorageBackendSheepdogRefreshVol(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+static int virStorageBackendSheepdogRefreshVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol);
void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
@@ -112,8 +111,7 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
}
static int
-virStorageBackendSheepdogAddVolume(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool, const char *diskInfo)
+virStorageBackendSheepdogAddVolume(virStoragePoolObjPtr pool, const char *diskInfo)
{
virStorageVolDefPtr vol = NULL;
@@ -128,7 +126,7 @@ virStorageBackendSheepdogAddVolume(virConnectPtr conn
ATTRIBUTE_UNUSED,
vol->type = VIR_STORAGE_VOL_NETWORK;
- if (virStorageBackendSheepdogRefreshVol(conn, pool, vol) < 0)
+ if (virStorageBackendSheepdogRefreshVol(pool, vol) < 0)
goto error;
if (virStoragePoolObjAddVol(pool, vol) < 0)
@@ -142,8 +140,7 @@ virStorageBackendSheepdogAddVolume(virConnectPtr conn
ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool)
{
int ret = -1;
char *output = NULL;
@@ -170,7 +167,7 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn
ATTRIBUTE_UNUSED,
if (cells != NULL &&
virStringListLength((const char * const *)cells) > 2) {
- if (virStorageBackendSheepdogAddVolume(conn, pool, cells[1]) < 0)
+ if (virStorageBackendSheepdogAddVolume(pool, cells[1]) < 0)
goto cleanup;
}
@@ -190,8 +187,7 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendSheepdogRefreshPool(virStoragePoolObjPtr pool)
{
int ret = -1;
char *output = NULL;
@@ -207,7 +203,7 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
output) < 0)
goto cleanup;
- ret = virStorageBackendSheepdogRefreshAllVol(conn, pool);
+ ret = virStorageBackendSheepdogRefreshAllVol(pool);
cleanup:
virCommandFree(cmd);
VIR_FREE(output);
@@ -216,8 +212,7 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendSheepdogDeleteVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -234,8 +229,7 @@ virStorageBackendSheepdogDeleteVol(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendSheepdogCreateVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -263,8 +257,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendSheepdogBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendSheepdogBuildVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -354,8 +347,7 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
}
static int
-virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendSheepdogRefreshVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
int ret;
@@ -389,8 +381,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendSheepdogResizeVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned long long capacity,
unsigned int flags)
diff --git a/src/storage/storage_backend_vstorage.c
b/src/storage/storage_backend_vstorage.c
index 2dc26af387..076617aeb6 100644
--- a/src/storage/storage_backend_vstorage.c
+++ b/src/storage/storage_backend_vstorage.c
@@ -17,7 +17,6 @@ VIR_LOG_INIT("storage.storage_backend_vstorage");
/**
- * @conn connection to report errors against
* @pool storage pool to build
* @flags controls the pool formatting behaviour
*
@@ -26,8 +25,7 @@ VIR_LOG_INIT("storage.storage_backend_vstorage");
* Returns 0 on success, -1 on error
*/
static int
-virStorageBackendVzPoolBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendVzPoolBuild(virStoragePoolObjPtr pool,
unsigned int flags)
{
virCheckFlags(0, -1);
@@ -37,8 +35,7 @@ virStorageBackendVzPoolBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
static int
-virStorageBackendVzPoolStart(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendVzPoolStart(virStoragePoolObjPtr pool)
{
int ret = -1;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -125,8 +122,7 @@ virStorageBackendVzIsMounted(virStoragePoolObjPtr pool)
static int
-virStorageBackendVzPoolStop(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendVzPoolStop(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = NULL;
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 198c788aca..ec39d9403b 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -228,8 +228,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
}
static int
-virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED)
+virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = NULL;
@@ -305,8 +304,7 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -377,8 +375,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendZFSDeleteVol(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -403,8 +400,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendZFSBuildPool(virStoragePoolObjPtr pool,
unsigned int flags)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -437,8 +433,7 @@ virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
-virStorageBackendZFSDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendZFSDeletePool(virStoragePoolObjPtr pool,
unsigned int flags)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 5d21007edb..ca5ed3d970 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -136,9 +136,9 @@ storagePoolUpdateStateCallback(virStoragePoolObjPtr obj,
*/
if (active) {
virStoragePoolObjClearVols(obj);
- if (backend->refreshPool(NULL, obj) < 0) {
+ if (backend->refreshPool(obj) < 0) {
if (backend->stopPool)
- backend->stopPool(NULL, obj);
+ backend->stopPool(obj);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restart storage pool '%s':
%s"),
def->name, virGetLastErrorMessage());
@@ -171,10 +171,9 @@ storagePoolUpdateAllState(void)
static void
storageDriverAutostartCallback(virStoragePoolObjPtr obj,
- const void *opaque)
+ const void *opaque ATTRIBUTE_UNUSED)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
- virConnectPtr conn = (virConnectPtr) opaque;
virStorageBackendPtr backend;
bool started = false;
@@ -184,7 +183,7 @@ storageDriverAutostartCallback(virStoragePoolObjPtr obj,
if (virStoragePoolObjIsAutostart(obj) &&
!virStoragePoolObjIsActive(obj)) {
if (backend->startPool &&
- backend->startPool(conn, obj) < 0) {
+ backend->startPool(obj) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to autostart storage pool '%s':
%s"),
def->name, virGetLastErrorMessage());
@@ -200,11 +199,11 @@ storageDriverAutostartCallback(virStoragePoolObjPtr obj,
stateFile = virFileBuildPath(driver->stateDir, def->name,
".xml");
if (!stateFile ||
virStoragePoolSaveState(stateFile, def) < 0 ||
- backend->refreshPool(conn, obj) < 0) {
+ backend->refreshPool(obj) < 0) {
if (stateFile)
unlink(stateFile);
if (backend->stopPool)
- backend->stopPool(conn, obj);
+ backend->stopPool(obj);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to autostart storage pool '%s':
%s"),
def->name, virGetLastErrorMessage());
@@ -221,16 +220,9 @@ storageDriverAutostart(void)
{
virConnectPtr conn = NULL;
- /* XXX Remove hardcoding of QEMU URI */
- if (driver->privileged)
- conn = virConnectOpen("qemu:///system");
- else
- conn = virConnectOpen("qemu:///session");
- /* Ignoring NULL conn - let backends decide */
-
virStoragePoolObjListForEach(driver->pools,
storageDriverAutostartCallback,
- conn);
+ NULL);
virObjectUnref(conn);
}
@@ -651,7 +643,7 @@ storageConnectFindStoragePoolSources(virConnectPtr conn,
goto cleanup;
}
- ret = backend->findPoolSources(conn, srcSpec, flags);
+ ret = backend->findPoolSources(srcSpec, flags);
cleanup:
return ret;
@@ -751,7 +743,7 @@ storagePoolCreateXML(virConnectPtr conn,
if (build_flags ||
(flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) {
- if (backend->buildPool(conn, obj, build_flags) < 0) {
+ if (backend->buildPool(obj, build_flags) < 0) {
virStoragePoolObjRemove(driver->pools, obj);
virObjectUnref(obj);
obj = NULL;
@@ -761,7 +753,7 @@ storagePoolCreateXML(virConnectPtr conn,
}
if (backend->startPool &&
- backend->startPool(conn, obj) < 0) {
+ backend->startPool(obj) < 0) {
virStoragePoolObjRemove(driver->pools, obj);
virObjectUnref(obj);
obj = NULL;
@@ -772,11 +764,11 @@ storagePoolCreateXML(virConnectPtr conn,
virStoragePoolObjClearVols(obj);
if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 ||
- backend->refreshPool(conn, obj) < 0) {
+ backend->refreshPool(obj) < 0) {
if (stateFile)
unlink(stateFile);
if (backend->stopPool)
- backend->stopPool(conn, obj);
+ backend->stopPool(obj);
virStoragePoolObjRemove(driver->pools, obj);
virObjectUnref(obj);
obj = NULL;
@@ -963,25 +955,25 @@ storagePoolCreate(virStoragePoolPtr pool,
if (build_flags ||
(flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) {
- if (backend->buildPool(pool->conn, obj, build_flags) < 0)
+ if (backend->buildPool(obj, build_flags) < 0)
goto cleanup;
}
}
VIR_INFO("Starting up storage pool '%s'", def->name);
if (backend->startPool &&
- backend->startPool(pool->conn, obj) < 0)
+ backend->startPool(obj) < 0)
goto cleanup;
stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml");
virStoragePoolObjClearVols(obj);
if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 ||
- backend->refreshPool(pool->conn, obj) < 0) {
+ backend->refreshPool(obj) < 0) {
if (stateFile)
unlink(stateFile);
if (backend->stopPool)
- backend->stopPool(pool->conn, obj);
+ backend->stopPool(obj);
goto cleanup;
}
@@ -1029,7 +1021,7 @@ storagePoolBuild(virStoragePoolPtr pool,
}
if (backend->buildPool &&
- backend->buildPool(pool->conn, obj, flags) < 0)
+ backend->buildPool(obj, flags) < 0)
goto cleanup;
event = virStoragePoolEventLifecycleNew(def->name,
@@ -1089,7 +1081,7 @@ storagePoolDestroy(virStoragePoolPtr pool)
VIR_FREE(stateFile);
if (backend->stopPool &&
- backend->stopPool(pool->conn, obj) < 0)
+ backend->stopPool(obj) < 0)
goto cleanup;
virStoragePoolObjClearVols(obj);
@@ -1160,7 +1152,7 @@ storagePoolDelete(virStoragePoolPtr pool,
"%s", _("pool does not support pool
deletion"));
goto cleanup;
}
- if (backend->deletePool(pool->conn, obj, flags) < 0)
+ if (backend->deletePool(obj, flags) < 0)
goto cleanup;
event = virStoragePoolEventLifecycleNew(def->name,
@@ -1214,9 +1206,9 @@ storagePoolRefresh(virStoragePoolPtr pool,
}
virStoragePoolObjClearVols(obj);
- if (backend->refreshPool(pool->conn, obj) < 0) {
+ if (backend->refreshPool(obj) < 0) {
if (backend->stopPool)
- backend->stopPool(pool->conn, obj);
+ backend->stopPool(obj);
event = virStoragePoolEventLifecycleNew(def->name,
def->uuid,
@@ -1723,8 +1715,7 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
static int
-storageVolDeleteInternal(virStorageVolPtr vol,
- virStorageBackendPtr backend,
+storageVolDeleteInternal(virStorageBackendPtr backend,
virStoragePoolObjPtr obj,
virStorageVolDefPtr voldef,
unsigned int flags,
@@ -1740,7 +1731,7 @@ storageVolDeleteInternal(virStorageVolPtr vol,
goto cleanup;
}
- if (backend->deleteVol(vol->conn, obj, voldef, flags) < 0)
+ if (backend->deleteVol(obj, voldef, flags) < 0)
goto cleanup;
/* The disk backend updated the pool data including removing the
@@ -1838,7 +1829,7 @@ storageVolDelete(virStorageVolPtr vol,
goto cleanup;
}
- if (storageVolDeleteInternal(vol, backend, obj, voldef, flags, true) < 0)
+ if (storageVolDeleteInternal(backend, obj, voldef, flags, true) < 0)
goto cleanup;
ret = 0;
@@ -1906,7 +1897,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
/* Wipe any key the user may have suggested, as volume creation
* will generate the canonical key. */
VIR_FREE(voldef->key);
- if (backend->createVol(pool->conn, obj, voldef) < 0)
+ if (backend->createVol(obj, voldef) < 0)
goto cleanup;
if (!(newvol = virGetStorageVol(pool->conn, def->name, voldef->name,
@@ -1937,7 +1928,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
voldef->building = true;
virObjectUnlock(obj);
- buildret = backend->buildVol(pool->conn, obj, buildvoldef, flags);
+ buildret = backend->buildVol(obj, buildvoldef, flags);
VIR_FREE(buildvoldef);
@@ -1956,8 +1947,8 @@ storageVolCreateXML(virStoragePoolPtr pool,
}
if (backend->refreshVol &&
- backend->refreshVol(pool->conn, obj, voldef) < 0) {
- storageVolDeleteInternal(newvol, backend, obj, voldef,
+ backend->refreshVol(obj, voldef) < 0) {
+ storageVolDeleteInternal(backend, obj, voldef,
0, false);
voldef = NULL;
goto cleanup;
@@ -2096,14 +2087,14 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if (backend->refreshVol &&
- backend->refreshVol(pool->conn, obj, voldefsrc) < 0)
+ backend->refreshVol(obj, voldefsrc) < 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(voldef->key);
- if (backend->createVol(pool->conn, obj, voldef) < 0)
+ if (backend->createVol(obj, voldef) < 0)
goto cleanup;
/* Make a shallow copy of the 'defined' volume definition, since the
@@ -2134,7 +2125,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
virObjectUnlock(objsrc);
}
- buildret = backend->buildVolFrom(pool->conn, obj, shadowvol, voldefsrc,
flags);
+ buildret = backend->buildVolFrom(obj, shadowvol, voldefsrc, flags);
virObjectLock(obj);
if (objsrc)
@@ -2151,8 +2142,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
if (buildret < 0 ||
(backend->refreshVol &&
- backend->refreshVol(pool->conn, obj, voldef) < 0)) {
- storageVolDeleteInternal(newvol, backend, obj, voldef, 0, false);
+ backend->refreshVol(obj, voldef) < 0)) {
+ storageVolDeleteInternal(backend, obj, voldef, 0, false);
voldef = NULL;
goto cleanup;
}
@@ -2215,7 +2206,7 @@ storageVolDownload(virStorageVolPtr vol,
goto cleanup;
}
- ret = backend->downloadVol(vol->conn, obj, voldef, stream,
+ ret = backend->downloadVol(obj, voldef, stream,
offset, length, flags);
cleanup:
@@ -2317,7 +2308,7 @@ virStorageVolPoolRefreshThread(void *opaque)
goto cleanup;
virStoragePoolObjClearVols(obj);
- if (backend->refreshPool(NULL, obj) < 0)
+ if (backend->refreshPool(obj) < 0)
VIR_DEBUG("Failed to refresh storage pool");
event = virStoragePoolEventRefreshNew(def->name, def->uuid);
@@ -2410,7 +2401,7 @@ storageVolUpload(virStorageVolPtr vol,
VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0)
goto cleanup;
- if ((ret = backend->uploadVol(vol->conn, obj, voldef, stream,
+ if ((ret = backend->uploadVol(obj, voldef, stream,
offset, length, flags)) < 0)
goto cleanup;
@@ -2508,7 +2499,7 @@ storageVolResize(virStorageVolPtr vol,
goto cleanup;
}
- if (backend->resizeVol(vol->conn, obj, voldef, abs_capacity, flags) < 0)
+ if (backend->resizeVol(obj, voldef, abs_capacity, flags) < 0)
goto cleanup;
voldef->target.capacity = abs_capacity;
@@ -2578,7 +2569,7 @@ storageVolWipePattern(virStorageVolPtr vol,
goto cleanup;
}
- if (backend->wipeVol(vol->conn, obj, voldef, algorithm, flags) < 0)
+ if (backend->wipeVol(obj, voldef, algorithm, flags) < 0)
goto cleanup;
/* Instead of using the refreshVol, since much changes on the target
@@ -2625,7 +2616,7 @@ storageVolGetInfoFlags(virStorageVolPtr vol,
goto cleanup;
if (backend->refreshVol &&
- backend->refreshVol(vol->conn, obj, voldef) < 0)
+ backend->refreshVol(obj, voldef) < 0)
goto cleanup;
memset(info, 0, sizeof(*info));
@@ -2671,7 +2662,7 @@ storageVolGetXMLDesc(virStorageVolPtr vol,
goto cleanup;
if (backend->refreshVol &&
- backend->refreshVol(vol->conn, obj, voldef) < 0)
+ backend->refreshVol(obj, voldef) < 0)
goto cleanup;
ret = virStorageVolDefFormat(def, voldef);
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 5995921570..7fb4a7733e 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -222,8 +222,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
}
static int
-storageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+storageBackendCreateBlockFrom(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -390,8 +389,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
}
static int
-storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+storageBackendCreateRaw(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -690,8 +688,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
/* Create ploop directory with ploop image and DiskDescriptor.xml
* if function fails to create image file the directory will be deleted.*/
static int
-storageBackendCreatePloop(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+storageBackendCreatePloop(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -1376,8 +1373,7 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolObjPtr pool,
static int
-storageBackendCreateQemuImg(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -1459,7 +1455,7 @@ virStorageBackendCreateVolUsingQemuImg(virStoragePoolObjPtr pool,
changeFormat = true;
}
- ret = storageBackendCreateQemuImg(NULL, pool, vol, inputvol, flags);
+ ret = storageBackendCreateQemuImg(pool, vol, inputvol, flags);
if (changeFormat)
vol->target.format = VIR_STORAGE_FILE_NONE;
@@ -2078,8 +2074,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
/* Common/Local File System/Directory Volume API's */
static int
-createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+createFileDir(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -2125,8 +2120,7 @@ createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED,
* function), and can drop the parent pool lock during the (slow) allocation.
*/
int
-virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendVolCreateLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -2164,8 +2158,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn
ATTRIBUTE_UNUSED,
static int
-storageBackendVolBuildLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+storageBackendVolBuildLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
@@ -2194,7 +2187,7 @@ storageBackendVolBuildLocal(virConnectPtr conn,
create_func = storageBackendCreateQemuImg;
}
- if (create_func(conn, pool, vol, inputvol, flags) < 0)
+ if (create_func(pool, vol, inputvol, flags) < 0)
return -1;
return 0;
}
@@ -2206,12 +2199,11 @@ storageBackendVolBuildLocal(virConnectPtr conn,
* special kinds of files
*/
int
-virStorageBackendVolBuildLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendVolBuildLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{
- return storageBackendVolBuildLocal(conn, pool, vol, NULL, flags);
+ return storageBackendVolBuildLocal(pool, vol, NULL, flags);
}
@@ -2219,13 +2211,12 @@ virStorageBackendVolBuildLocal(virConnectPtr conn,
* Create a storage vol using 'inputvol' as input
*/
int
-virStorageBackendVolBuildFromLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendVolBuildFromLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags)
{
- return storageBackendVolBuildLocal(conn, pool, vol, inputvol, flags);
+ return storageBackendVolBuildLocal(pool, vol, inputvol, flags);
}
@@ -2233,8 +2224,7 @@ virStorageBackendVolBuildFromLocal(virConnectPtr conn,
* Remove a volume - no support for BLOCK and NETWORK yet
*/
int
-virStorageBackendVolDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendVolDeleteLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
unsigned int flags)
{
@@ -2335,8 +2325,7 @@ storageBackendLoadDefaultSecrets(virStorageVolDefPtr vol)
* Update info about a volume's capacity/allocation
*/
int
-virStorageBackendVolRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendVolRefreshLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol)
{
int ret;
@@ -2429,8 +2418,7 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool,
* Resize a volume
*/
int
-virStorageBackendVolResizeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendVolResizeLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned long long capacity,
unsigned int flags)
@@ -2509,8 +2497,7 @@ storageBackendPloopHasSnapshots(char *path)
int
-virStorageBackendVolUploadLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendVolUploadLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
@@ -2556,8 +2543,7 @@ virStorageBackendVolUploadLocal(virConnectPtr conn
ATTRIBUTE_UNUSED,
}
int
-virStorageBackendVolDownloadLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendVolDownloadLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
@@ -2854,8 +2840,7 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol,
int
-virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+virStorageBackendVolWipeLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
unsigned int algorithm,
unsigned int flags)
@@ -2954,8 +2939,7 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
* Returns 0 on success, -1 on error
*/
int
-virStorageBackendDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool,
+virStorageBackendDeleteLocal(virStoragePoolObjPtr pool,
unsigned int flags)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
@@ -3696,8 +3680,7 @@ virStorageBackendRefreshVolTargetUpdate(virStorageVolDefPtr vol)
* within it. This is non-recursive.
*/
int
-virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool)
+virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
DIR *dir;
diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
index ffc83c60ab..e9cb982115 100644
--- a/src/storage/storage_util.h
+++ b/src/storage/storage_util.h
@@ -38,54 +38,45 @@ virStorageBackendBuildVolFrom
virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol);
-int virStorageBackendVolCreateLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolCreateLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol);
-int virStorageBackendVolBuildLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolBuildLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags);
-int virStorageBackendVolBuildFromLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolBuildFromLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
unsigned int flags);
-int virStorageBackendVolDeleteLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolDeleteLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags);
-int virStorageBackendVolRefreshLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolRefreshLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol);
-int virStorageBackendVolResizeLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolResizeLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned long long capacity,
unsigned int flags);
-int virStorageBackendVolUploadLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolUploadLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
unsigned long long len,
unsigned int flags);
-int virStorageBackendVolDownloadLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolDownloadLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
unsigned long long len,
unsigned int flags);
-int virStorageBackendVolWipeLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendVolWipeLocal(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int algorithm,
unsigned int flags);
@@ -93,15 +84,13 @@ int virStorageBackendVolWipeLocal(virConnectPtr conn,
/* Local/Common Storage Pool Backend APIs */
int virStorageBackendBuildLocal(virStoragePoolObjPtr pool);
-int virStorageBackendDeleteLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+int virStorageBackendDeleteLocal(virStoragePoolObjPtr pool,
unsigned int flags);
int
virStorageBackendRefreshVolTargetUpdate(virStorageVolDefPtr vol);
-int virStorageBackendRefreshLocal(virConnectPtr conn,
- virStoragePoolObjPtr pool);
+int virStorageBackendRefreshLocal(virStoragePoolObjPtr pool);
int virStorageUtilGlusterExtractPoolSources(const char *host,
const char *xml,
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 1cd083766a..5857d5e350 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -47,16 +47,12 @@ testCompareXMLToArgvFiles(bool shouldFail,
int ret = -1;
virCommandPtr cmd = NULL;
- virConnectPtr conn;
virStorageVolDefPtr vol = NULL, inputvol = NULL;
virStoragePoolDefPtr def = NULL;
virStoragePoolDefPtr inputpool = NULL;
virStoragePoolObjPtr obj = NULL;
- if (!(conn = virGetConnect()))
- goto cleanup;
-
if (!(def = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
@@ -84,7 +80,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
testSetVolumeType(vol, def);
testSetVolumeType(inputvol, inputpool);
- cmd = virStorageBackendCreateQemuImgCmdFromVol(conn, obj, vol,
+ cmd = virStorageBackendCreateQemuImgCmdFromVol(obj, vol,
inputvol, flags,
create_tool, imgformat,
NULL);
@@ -111,7 +107,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
virCommandFree(cmd);
VIR_FREE(actualCmdline);
virStoragePoolObjEndAPI(&obj);
- virObjectUnref(conn);
return ret;
}
--
2.14.3