The temporary pool code will need to initialize dummy gluster volumes
which needs the createVol function of the storage backend. This patch
implements it only for that purpose. When an user will get an error
message that it is not implemented on an attempt to create a volume in a
gluster pool.
---
src/storage/storage_backend_gluster.c | 68 +++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/src/storage/storage_backend_gluster.c
b/src/storage/storage_backend_gluster.c
index c73cf8a..2d22801 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -444,10 +444,78 @@ cleanup:
}
+static int
+virStorageBackendGlusterVolCreate(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol,
+ bool internal)
+{
+ virStorageBackendGlusterStatePtr state = NULL;
+ struct stat st;
+ char *tmp;
+ int ret = -1;
+
+ if (!(state = virStorageBackendGlusterOpen(pool)))
+ goto cleanup;
+
+ vol->type = VIR_STORAGE_VOL_NETWORK;
+ vol->target.format = VIR_STORAGE_FILE_RAW;
+
+ VIR_FREE(vol->key);
+ if (virAsprintf(&vol->key, "/%s%s%s", state->volname,
state->dir,
+ vol->name) < 0)
+ goto cleanup;
+
+ tmp = state->uri->path;
+ state->uri->path = vol->key;
+ VIR_FREE(vol->target.path);
+ if (!(vol->target.path = virURIFormat(state->uri))) {
+ state->uri->path = tmp;
+ goto cleanup;
+ }
+ state->uri->path = tmp;
+
+ if (internal) {
+ if (glfs_stat(state->vol, vol->name, &st) == 0 &&
+ S_ISDIR(st.st_mode)) {
+ vol->type = VIR_STORAGE_VOL_NETDIR;
+ vol->target.format = VIR_STORAGE_FILE_DIR;
+ }
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("gluster pool backend doesn't "
+ "yet support volume creation"));
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ virStorageBackendGlusterClose(state);
+ return ret;
+}
+
+
+static int
+virStorageBackendGlusterVolBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+ virStorageVolDefPtr vol ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(0, -1);
+
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("gluster pool backend doesn't yet support volume
building"));
+ return -1;
+}
+
+
virStorageBackend virStorageBackendGluster = {
.type = VIR_STORAGE_POOL_GLUSTER,
.refreshPool = virStorageBackendGlusterRefreshPool,
+ .createVol = virStorageBackendGlusterVolCreate,
+ .buildVol = virStorageBackendGlusterVolBuild,
.deleteVol = virStorageBackendGlusterVolDelete,
};
--
1.8.5.2