diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index b24fe94eec..43f3561f8e 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4103,3 +4103,25 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, return found; } + + +/* + * @path: Path to the device to initialize + * @size: Size to be cleared + * + * Zero out possible partition table information for the specified + * bytes from the start of the @path and from the end of @path + * + * Returns 0 on success, -1 on failure with error message set + */ +int +virStorageBackendZeroPartitionTable(const char *path, + unsigned long long size) +{ + if (storageBackendVolWipeLocalFile(path, VIR_STORAGE_VOL_WIPE_ALG_ZERO, + size, false) < 0) + return -1; + + return storageBackendVolWipeLocalFile(path, VIR_STORAGE_VOL_WIPE_ALG_ZERO, + size, true); +} diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 602d3a069b..a05c35d81b 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -167,4 +167,8 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn, int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, uint32_t scanhost); +int +virStorageBackendZeroPartitionTable(const char *path, + unsigned long long size); + #endif /* __VIR_STORAGE_UTIL_H__ */