[libvirt] [PATCH] storage: backend_disk: Implement the deletePool function

Erik Skultety posted 1 patch 1 week ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/bd1864eccc4432b07382cf7ea2daa20abe1aaf4e.1574952482.git.eskultet@redhat.com
src/storage/storage_backend_disk.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

[libvirt] [PATCH] storage: backend_disk: Implement the deletePool function

Posted by Erik Skultety 1 week ago
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>
---
 src/storage/storage_backend_disk.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index d971530cd8..45d1257f3d 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -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,
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] storage: backend_disk: Implement the deletePool function

Posted by Michal Privoznik 1 week ago
On 11/28/19 3:48 PM, Erik Skultety wrote:
> 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>
> ---
>   src/storage/storage_backend_disk.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list