mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
storage: Split out volume wiping as separate backend function
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
This commit is contained in:
parent
4d799b65cd
commit
11d28050c5
@ -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);
|
||||
|
@ -794,4 +794,5 @@ virStorageBackend virStorageBackendDisk = {
|
||||
.buildVolFrom = virStorageBackendDiskBuildVolFrom,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
|
@ -1301,6 +1301,7 @@ virStorageBackend virStorageBackendDirectory = {
|
||||
.resizeVol = virStorageBackendFileSystemVolResize,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
|
||||
#if WITH_STORAGE_FS
|
||||
@ -1321,6 +1322,7 @@ virStorageBackend virStorageBackendFileSystem = {
|
||||
.resizeVol = virStorageBackendFileSystemVolResize,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
virStorageBackend virStorageBackendNetFileSystem = {
|
||||
.type = VIR_STORAGE_POOL_NETFS,
|
||||
@ -1340,6 +1342,7 @@ virStorageBackend virStorageBackendNetFileSystem = {
|
||||
.resizeVol = virStorageBackendFileSystemVolResize,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
|
||||
|
||||
|
@ -476,4 +476,5 @@ virStorageBackend virStorageBackendISCSI = {
|
||||
.findPoolSources = virStorageBackendISCSIFindPoolSources,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
|
@ -846,4 +846,5 @@ virStorageBackend virStorageBackendLogical = {
|
||||
.deleteVol = virStorageBackendLogicalDeleteVol,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
|
@ -289,4 +289,5 @@ virStorageBackend virStorageBackendMpath = {
|
||||
.refreshPool = virStorageBackendMpathRefreshPool,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
|
@ -730,4 +730,5 @@ virStorageBackend virStorageBackendSCSI = {
|
||||
.stopPool = virStorageBackendSCSIStopPool,
|
||||
.uploadVol = virStorageBackendVolUploadLocal,
|
||||
.downloadVol = virStorageBackendVolDownloadLocal,
|
||||
.wipeVol = virStorageBackendVolWipeLocal,
|
||||
};
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user