提交 11d28050 编写于 作者: P Peter Krempa

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
上级 4d799b65
...@@ -87,6 +87,11 @@ typedef int (*virStorageBackendVolumeUpload)(virConnectPtr conn, ...@@ -87,6 +87,11 @@ typedef int (*virStorageBackendVolumeUpload)(virConnectPtr conn,
unsigned long long offset, unsigned long long offset,
unsigned long long len, unsigned long long len,
unsigned int flags); 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 */ /* File creation/cloning functions used for cloning between backends */
int virStorageBackendCreateRaw(virConnectPtr conn, int virStorageBackendCreateRaw(virConnectPtr conn,
...@@ -150,6 +155,7 @@ struct _virStorageBackend { ...@@ -150,6 +155,7 @@ struct _virStorageBackend {
virStorageBackendVolumeResize resizeVol; virStorageBackendVolumeResize resizeVol;
virStorageBackendVolumeUpload uploadVol; virStorageBackendVolumeUpload uploadVol;
virStorageBackendVolumeDownload downloadVol; virStorageBackendVolumeDownload downloadVol;
virStorageBackendVolumeWipe wipeVol;
}; };
virStorageBackendPtr virStorageBackendForType(int type); virStorageBackendPtr virStorageBackendForType(int type);
......
...@@ -794,4 +794,5 @@ virStorageBackend virStorageBackendDisk = { ...@@ -794,4 +794,5 @@ virStorageBackend virStorageBackendDisk = {
.buildVolFrom = virStorageBackendDiskBuildVolFrom, .buildVolFrom = virStorageBackendDiskBuildVolFrom,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
...@@ -1301,6 +1301,7 @@ virStorageBackend virStorageBackendDirectory = { ...@@ -1301,6 +1301,7 @@ virStorageBackend virStorageBackendDirectory = {
.resizeVol = virStorageBackendFileSystemVolResize, .resizeVol = virStorageBackendFileSystemVolResize,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
#if WITH_STORAGE_FS #if WITH_STORAGE_FS
...@@ -1321,6 +1322,7 @@ virStorageBackend virStorageBackendFileSystem = { ...@@ -1321,6 +1322,7 @@ virStorageBackend virStorageBackendFileSystem = {
.resizeVol = virStorageBackendFileSystemVolResize, .resizeVol = virStorageBackendFileSystemVolResize,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
virStorageBackend virStorageBackendNetFileSystem = { virStorageBackend virStorageBackendNetFileSystem = {
.type = VIR_STORAGE_POOL_NETFS, .type = VIR_STORAGE_POOL_NETFS,
...@@ -1340,6 +1342,7 @@ virStorageBackend virStorageBackendNetFileSystem = { ...@@ -1340,6 +1342,7 @@ virStorageBackend virStorageBackendNetFileSystem = {
.resizeVol = virStorageBackendFileSystemVolResize, .resizeVol = virStorageBackendFileSystemVolResize,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
......
...@@ -476,4 +476,5 @@ virStorageBackend virStorageBackendISCSI = { ...@@ -476,4 +476,5 @@ virStorageBackend virStorageBackendISCSI = {
.findPoolSources = virStorageBackendISCSIFindPoolSources, .findPoolSources = virStorageBackendISCSIFindPoolSources,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
...@@ -846,4 +846,5 @@ virStorageBackend virStorageBackendLogical = { ...@@ -846,4 +846,5 @@ virStorageBackend virStorageBackendLogical = {
.deleteVol = virStorageBackendLogicalDeleteVol, .deleteVol = virStorageBackendLogicalDeleteVol,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
...@@ -289,4 +289,5 @@ virStorageBackend virStorageBackendMpath = { ...@@ -289,4 +289,5 @@ virStorageBackend virStorageBackendMpath = {
.refreshPool = virStorageBackendMpathRefreshPool, .refreshPool = virStorageBackendMpathRefreshPool,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
...@@ -730,4 +730,5 @@ virStorageBackend virStorageBackendSCSI = { ...@@ -730,4 +730,5 @@ virStorageBackend virStorageBackendSCSI = {
.stopPool = virStorageBackendSCSIStopPool, .stopPool = virStorageBackendSCSIStopPool,
.uploadVol = virStorageBackendVolUploadLocal, .uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal, .downloadVol = virStorageBackendVolDownloadLocal,
.wipeVol = virStorageBackendVolWipeLocal,
}; };
...@@ -2100,6 +2100,7 @@ storageVolWipePattern(virStorageVolPtr obj, ...@@ -2100,6 +2100,7 @@ storageVolWipePattern(virStorageVolPtr obj,
unsigned int algorithm, unsigned int algorithm,
unsigned int flags) unsigned int flags)
{ {
virStorageBackendPtr backend;
virStoragePoolObjPtr pool = NULL; virStoragePoolObjPtr pool = NULL;
virStorageVolDefPtr vol = NULL; virStorageVolDefPtr vol = NULL;
int ret = -1; int ret = -1;
...@@ -2113,7 +2114,7 @@ storageVolWipePattern(virStorageVolPtr obj, ...@@ -2113,7 +2114,7 @@ storageVolWipePattern(virStorageVolPtr obj,
return -1; return -1;
} }
if (!(vol = virStorageVolDefFromVol(obj, &pool, NULL))) if (!(vol = virStorageVolDefFromVol(obj, &pool, &backend)))
return -1; return -1;
...@@ -2134,10 +2135,13 @@ storageVolWipePattern(virStorageVolPtr obj, ...@@ -2134,10 +2135,13 @@ storageVolWipePattern(virStorageVolPtr obj,
goto cleanup; 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; goto cleanup;
}
ret = 0; ret = backend->wipeVol(obj->conn, pool, vol, algorithm, flags);
cleanup: cleanup:
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(pool);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册