[libvirt] [PATCH 3/7] storage:dir: .deleteVol callback for ploop volume

Olga Krishtal okrishtal at virtuozzo.com
Fri Feb 5 16:23:42 UTC 2016


Deletes whole directory of a ploop volume. To delete ploop image it has
to be unmounted.

Signed-off-by: Olga Krishtal <okrishtal at virtuozzo.com>
---
 src/storage/storage_backend.c    | 6 ++++++
 src/storage/storage_backend.h    | 2 ++
 src/storage/storage_backend_fs.c | 5 ++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 96bd3fc..1b4ffbc 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -861,6 +861,12 @@ int virStorageBackendCreatePloop(virConnectPtr conn ATTRIBUTE_UNUSED,
     return ret;
 }
 
+int virStorageBackendDeletePloop(virConnectPtr conn ATTRIBUTE_UNUSED,
+                           virStorageVolDefPtr vol)
+{
+    return virFileDeleteTree(vol->target.path);
+}
+
 enum {
     QEMU_IMG_BACKING_FORMAT_NONE = 0,
     QEMU_IMG_BACKING_FORMAT_FLAG,
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 852d6ed..7d354c5 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -115,6 +115,8 @@ int virStorageBackendCreatePloop(virConnectPtr conn,
                                  virStorageVolDefPtr inputvol,
                                  unsigned int flags);
 
+int virStorageBackendDeletePloop(virConnectPtr conn,
+                                 virStorageVolDefPtr vol);
 
 virStorageBackendBuildVolFrom
 virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 3487545..9926a6e 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1247,7 +1247,6 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
     switch ((virStorageVolType) vol->type) {
     case VIR_STORAGE_VOL_FILE:
     case VIR_STORAGE_VOL_DIR:
-    case VIR_STORAGE_VOL_PLOOP:
         if (virFileRemove(vol->target.path, vol->target.perms->uid,
                           vol->target.perms->gid) < 0) {
             /* Silently ignore failures where the vol has already gone away */
@@ -1264,6 +1263,10 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
             }
         }
         break;
+    case VIR_STORAGE_VOL_PLOOP:
+        if (virStorageBackendDeletePloop(conn, vol) != 0)
+            return -1;
+        break;
     case VIR_STORAGE_VOL_BLOCK:
     case VIR_STORAGE_VOL_NETWORK:
     case VIR_STORAGE_VOL_NETDIR:
-- 
1.8.3.1




More information about the libvir-list mailing list