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