For non-local storage drivers we can't expect to use the "scrub" tool to
wipe the volume. Split the code into a separate backend function so that
we can add protocol specific code later.
Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1118710
---
src/storage/storage_backend.h | 6 ++++++
src/storage/storage_backend_disk.c | 1 +
src/storage/storage_backend_fs.c | 3 +++
src/storage/storage_backend_iscsi.c | 1 +
src/storage/storage_backend_logical.c | 1 +
src/storage/storage_backend_mpath.c | 1 +
src/storage/storage_backend_scsi.c | 1 +
src/storage/storage_driver.c | 10 +++++++---
8 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 5e251d7..e48da5b 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -87,6 +87,11 @@ typedef int (*virStorageBackendVolumeUpload)(virConnectPtr conn,
unsigned long long offset,
unsigned long long len,
unsigned int flags);
+typedef int (*virStorageBackendVolumeWipe)(virConnectPtr conn,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol,
+ unsigned int algorithm,
+ unsigned int flags);
/* File creation/cloning functions used for cloning between backends */
int virStorageBackendCreateRaw(virConnectPtr conn,
@@ -150,6 +155,7 @@ struct _virStorageBackend {
virStorageBackendVolumeResize resizeVol;
virStorageBackendVolumeUpload uploadVol;
virStorageBackendVolumeDownload downloadVol;
+ virStorageBackendVolumeWipe wipeVol;
};
virStorageBackendPtr virStorageBackendForType(int type);
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index f900dee..d85f13f 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -794,4 +794,5 @@ virStorageBackend virStorageBackendDisk = {
.buildVolFrom = virStorageBackendDiskBuildVolFrom,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 1615c12..58e849f 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1291,6 +1291,7 @@ virStorageBackend virStorageBackendDirectory = {
.resizeVol = virStorageBackendFileSystemVolResize,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
#if WITH_STORAGE_FS
@@ -1311,6 +1312,7 @@ virStorageBackend virStorageBackendFileSystem = {
.resizeVol = virStorageBackendFileSystemVolResize,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
virStorageBackend virStorageBackendNetFileSystem = {
.type = VIR_STORAGE_POOL_NETFS,
@@ -1330,6 +1332,7 @@ virStorageBackend virStorageBackendNetFileSystem = {
.resizeVol = virStorageBackendFileSystemVolResize,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 7345571..1d0cf73 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -476,4 +476,5 @@ virStorageBackend virStorageBackendISCSI = {
.findPoolSources = virStorageBackendISCSIFindPoolSources,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
diff --git a/src/storage/storage_backend_logical.c
b/src/storage/storage_backend_logical.c
index faa9a4b..562f019 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -843,4 +843,5 @@ virStorageBackend virStorageBackendLogical = {
.deleteVol = virStorageBackendLogicalDeleteVol,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index 402faa0..f21ae4c 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -289,4 +289,5 @@ virStorageBackend virStorageBackendMpath = {
.refreshPool = virStorageBackendMpathRefreshPool,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 0b44f71..dfb663b 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -730,4 +730,5 @@ virStorageBackend virStorageBackendSCSI = {
.stopPool = virStorageBackendSCSIStopPool,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
+ .wipeVol = virStorageBackendVolWipeLocal,
};
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 97571e8..441da21 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2100,6 +2100,7 @@ storageVolWipePattern(virStorageVolPtr obj,
unsigned int algorithm,
unsigned int flags)
{
+ virStorageBackendPtr backend;
virStoragePoolObjPtr pool = NULL;
virStorageVolDefPtr vol = NULL;
int ret = -1;
@@ -2113,7 +2114,7 @@ storageVolWipePattern(virStorageVolPtr obj,
return -1;
}
- if (!(vol = virStorageVolDefFromVol(obj, &pool, NULL)))
+ if (!(vol = virStorageVolDefFromVol(obj, &pool, &backend)))
return -1;
@@ -2134,10 +2135,13 @@ storageVolWipePattern(virStorageVolPtr obj,
goto cleanup;
}
- if (virStorageBackendVolWipeLocal(obj->conn, pool, vol, algorithm, flags) < 0)
+ if (!backend->wipeVol) {
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ _("storage pool doesn't support volume wiping"));
goto cleanup;
+ }
- ret = 0;
+ ret = backend->wipeVol(obj->conn, pool, vol, algorithm, flags);
cleanup:
virStoragePoolObjUnlock(pool);
--
2.0.0