|
|
c401cc |
From 097365c3599033f6dfa234005a78c238856f0dd6 Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <097365c3599033f6dfa234005a78c238856f0dd6@dist-git>
|
|
|
c401cc |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
c401cc |
Date: Wed, 26 Feb 2014 14:55:18 +0100
|
|
|
c401cc |
Subject: [PATCH] storage: Support deletion of volumes on gluster pools
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
|
|
|
c401cc |
|
|
|
c401cc |
Implement the "deleteVol" storage backend function for gluster volumes.
|
|
|
c401cc |
|
|
|
c401cc |
(cherry picked from commit 7de048829ace1e03cbfebadb7cdb42cf036f6c00)
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/storage/storage_backend_gluster.c | 64 +++++++++++++++++++++++++++++++++++
|
|
|
c401cc |
1 file changed, 64 insertions(+)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
index 2ec2424..c73cf8a 100644
|
|
|
c401cc |
--- a/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
+++ b/src/storage/storage_backend_gluster.c
|
|
|
c401cc |
@@ -382,8 +382,72 @@ cleanup:
|
|
|
c401cc |
return ret;
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
+
|
|
|
c401cc |
+static int
|
|
|
c401cc |
+virStorageBackendGlusterVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
c401cc |
+ virStoragePoolObjPtr pool,
|
|
|
c401cc |
+ virStorageVolDefPtr vol,
|
|
|
c401cc |
+ unsigned int flags)
|
|
|
c401cc |
+{
|
|
|
c401cc |
+ virStorageBackendGlusterStatePtr state = NULL;
|
|
|
c401cc |
+ int ret = -1;
|
|
|
c401cc |
+
|
|
|
c401cc |
+ virCheckFlags(0, -1);
|
|
|
c401cc |
+
|
|
|
c401cc |
+ switch ((virStorageVolType) vol->type) {
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_FILE:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_DIR:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_BLOCK:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_LAST:
|
|
|
c401cc |
+ virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
c401cc |
+ _("removing of '%s' volumes is not supported "
|
|
|
c401cc |
+ "by the gluster backend: %s"),
|
|
|
c401cc |
+ virStorageVolTypeToString(vol->type),
|
|
|
c401cc |
+ vol->target.path);
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ break;
|
|
|
c401cc |
+
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_NETWORK:
|
|
|
c401cc |
+ if (!(state = virStorageBackendGlusterOpen(pool)))
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+
|
|
|
c401cc |
+ if (glfs_unlink(state->vol, vol->name) < 0) {
|
|
|
c401cc |
+ if (errno != ENOENT) {
|
|
|
c401cc |
+ virReportSystemError(errno,
|
|
|
c401cc |
+ _("cannot remove gluster volume file '%s'"),
|
|
|
c401cc |
+ vol->target.path);
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+ break;
|
|
|
c401cc |
+
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_NETDIR:
|
|
|
c401cc |
+ if (!(state = virStorageBackendGlusterOpen(pool)))
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+
|
|
|
c401cc |
+ if (glfs_rmdir(state->vol, vol->target.path) < 0) {
|
|
|
c401cc |
+ if (errno != ENOENT) {
|
|
|
c401cc |
+ virReportSystemError(errno,
|
|
|
c401cc |
+ _("cannot remove gluster volume dir '%s'"),
|
|
|
c401cc |
+ vol->target.path);
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+ break;
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+
|
|
|
c401cc |
+ ret = 0;
|
|
|
c401cc |
+
|
|
|
c401cc |
+cleanup:
|
|
|
c401cc |
+ virStorageBackendGlusterClose(state);
|
|
|
c401cc |
+ return ret;
|
|
|
c401cc |
+}
|
|
|
c401cc |
+
|
|
|
c401cc |
+
|
|
|
c401cc |
virStorageBackend virStorageBackendGluster = {
|
|
|
c401cc |
.type = VIR_STORAGE_POOL_GLUSTER,
|
|
|
c401cc |
|
|
|
c401cc |
.refreshPool = virStorageBackendGlusterRefreshPool,
|
|
|
c401cc |
+
|
|
|
c401cc |
+ .deleteVol = virStorageBackendGlusterVolDelete,
|
|
|
c401cc |
};
|
|
|
c401cc |
--
|
|
|
c401cc |
1.9.0
|
|
|
c401cc |
|