]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: backend_disk: Implement the deletePool function
authorErik Skultety <eskultet@redhat.com>
Thu, 28 Nov 2019 14:21:18 +0000 (15:21 +0100)
committerErik Skultety <eskultet@redhat.com>
Tue, 3 Dec 2019 08:31:10 +0000 (09:31 +0100)
This is a very simple and straightforward implementation of the opposite
what buildPool does for the disk backend.
The background for this change comes from an existing test case in TCK
which does use the delete method for a pool of type disk, but it
truly could not have ever worked since the implementation simply
wasn't there for the pool of type disk.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_backend_disk.c

index d971530cd848feabccf740175f0afaa6ce8fc610..45d1257f3d9598a277407fa21a74b24c14bc08bf 100644 (file)
@@ -531,6 +531,25 @@ virStorageBackendDiskBuildPool(virStoragePoolObjPtr pool,
 }
 
 
+/**
+ * Wipe the existing partition table
+ */
+static int
+virStorageBackendDiskDeletePool(virStoragePoolObjPtr pool,
+                                unsigned int flags)
+{
+    virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
+
+    virCheckFlags(0, -1);
+
+    if (virStorageBackendZeroPartitionTable(def->source.devices[0].path,
+                                            1024 * 1024) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 struct virStorageVolNumData {
     int count;
 };
@@ -954,6 +973,7 @@ virStorageBackend virStorageBackendDisk = {
     .startPool = virStorageBackendDiskStartPool,
     .buildPool = virStorageBackendDiskBuildPool,
     .refreshPool = virStorageBackendDiskRefreshPool,
+    .deletePool = virStorageBackendDiskDeletePool,
 
     .createVol = virStorageBackendDiskCreateVol,
     .deleteVol = virStorageBackendDiskDeleteVol,