[PATCH RFC 17/27] storage: Sheepdog: Separate creating of the volume from building

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/storage/storage_backend_sheepdog.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index a97af1b..a6981ce 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -154,15 +154,37 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
                                    virStoragePoolObjPtr pool,
                                    virStorageVolDefPtr vol)
 {
-
-    int ret = -1;
-
     if (vol->target.encryption != NULL) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Sheepdog does not support encrypted volumes"));
         return -1;
     }

+    vol->type = VIR_STORAGE_VOL_NETWORK;
+
+    VIR_FREE(vol->key);
+    if (virAsprintf(&vol->key, "%s/%s",
+                    pool->def->source.name, vol->name) == -1)
+        return -1;
+
+    VIR_FREE(vol->target.path);
+    if (VIR_STRDUP(vol->target.path, vol->name) < 0)
+        return -1;
+
+    return 0;
+}
+
+
+static int
+virStorageBackendSheepdogBuildVol(virConnectPtr conn,
+                                  virStoragePoolObjPtr pool,
+                                  virStorageVolDefPtr vol,
+                                  unsigned int flags)
+{
+    int ret = -1;
+
+    virCheckFlags(0, -1);
+
     virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "create", vol->name, NULL);
     virCommandAddArgFormat(cmd, "%llu", vol->capacity);
     virStorageBackendSheepdogAddHostArg(cmd, pool);
@@ -301,6 +323,7 @@ virStorageBackend virStorageBackendSheepdog = {

     .refreshPool = virStorageBackendSheepdogRefreshPool,
     .createVol = virStorageBackendSheepdogCreateVol,
+    .buildVol = virStorageBackendSheepdogBuildVol,
     .refreshVol = virStorageBackendSheepdogRefreshVol,
     .deleteVol = virStorageBackendSheepdogDeleteVol,
     .resizeVol = virStorageBackendSheepdogResizeVol,
-- 
1.8.5.1

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]