]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Introduce virStorageBackendZeroPartitionTable
authorJohn Ferlan <jferlan@redhat.com>
Thu, 6 Apr 2017 17:18:16 +0000 (13:18 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 26 Apr 2017 11:28:08 +0000 (07:28 -0400)
Create a wrapper/helper that can be used to call the storage backend
wipe helper - storageBackendVolWipeLocalFile for future use by logical
and disk backends to clear out the partition table rather than having
each open code the same algorithm.

src/storage/storage_util.c
src/storage/storage_util.h

index b24fe94eec08c7b2a5dcaa3249db79737ff98e9c..43f3561f8e24ada7f447c2f8200324090c46c183 100644 (file)
@@ -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);
+}
index 602d3a069b4f9c4b55faa026caab97d9a5fe2c66..a05c35d81b3ed2450259c560b903972f83228003 100644 (file)
@@ -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__ */