]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: RBD: Separate creating of the volume from building
authorPeter Krempa <pkrempa@redhat.com>
Wed, 11 Dec 2013 16:04:24 +0000 (17:04 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 16 Jan 2014 10:39:53 +0000 (11:39 +0100)
Separate the steps to create libvirt's volume metadata from the actual
volume building process.

src/storage/storage_backend_rbd.c

index 4b6f18c58ded1e6abc16bb8495864b641a5bb3eb..c5f0bc564e9a38bbb5a2d15c7001479903543ac0 100644 (file)
@@ -435,9 +435,35 @@ cleanup:
     return ret;
 }
 
-static int virStorageBackendRBDCreateVol(virConnectPtr conn,
-                                         virStoragePoolObjPtr pool,
-                                         virStorageVolDefPtr vol)
+
+static int
+virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
+                              virStoragePoolObjPtr pool,
+                              virStorageVolDefPtr vol)
+{
+    vol->type = VIR_STORAGE_VOL_NETWORK;
+
+    VIR_FREE(vol->target.path);
+    if (virAsprintf(&vol->target.path, "%s/%s",
+                    pool->def->source.name,
+                    vol->name) == -1)
+        return -1;
+
+    VIR_FREE(vol->key);
+    if (virAsprintf(&vol->key, "%s/%s",
+                    pool->def->source.name,
+                    vol->name) == -1)
+        return -1;
+
+    return 0;
+}
+
+
+static int
+virStorageBackendRBDBuildVol(virConnectPtr conn,
+                             virStoragePoolObjPtr pool,
+                             virStorageVolDefPtr vol,
+                             unsigned int flags)
 {
     virStorageBackendRBDState ptr;
     ptr.cluster = NULL;
@@ -449,9 +475,10 @@ static int virStorageBackendRBDCreateVol(virConnectPtr conn,
               pool->def->source.name,
               vol->name, vol->capacity);
 
-    if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, pool) < 0) {
+    virCheckFlags(0, -1);
+
+    if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, pool) < 0)
         goto cleanup;
-    }
 
     if (rados_ioctx_create(ptr.cluster,
                            pool->def->source.name, &ptr.ioctx) < 0) {
@@ -475,9 +502,8 @@ static int virStorageBackendRBDCreateVol(virConnectPtr conn,
         goto cleanup;
     }
 
-    if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0) {
+    if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0)
         goto cleanup;
-    }
 
     ret = 0;
 
@@ -572,6 +598,7 @@ virStorageBackend virStorageBackendRBD = {
 
     .refreshPool = virStorageBackendRBDRefreshPool,
     .createVol = virStorageBackendRBDCreateVol,
+    .buildVol = virStorageBackendRBDBuildVol,
     .refreshVol = virStorageBackendRBDRefreshVol,
     .deleteVol = virStorageBackendRBDDeleteVol,
     .resizeVol = virStorageBackendRBDResizeVol,