]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Revert "storage: lvm: Separate creating of the volume from building"
authorJán Tomko <jtomko@redhat.com>
Wed, 12 Feb 2014 13:23:30 +0000 (14:23 +0100)
committerJán Tomko <jtomko@redhat.com>
Wed, 12 Feb 2014 13:51:05 +0000 (14:51 +0100)
This reverts commit af1fb38f55d4fb87e0fcaee1e973fa9c6713b1e6.
With it, creating new logical volumes fails:
https://www.redhat.com/archives/libvir-list/2014-February/msg00658.html

In the storage driver, we expect CreateVol to fill out the volume key,
but the LVM backend fills the key with the uuid reported by lvs after the
logical volume is created.

src/storage/storage_backend_logical.c

index 039d962a9fa7ed39dd8edc679cc0b76e97e25ec7..15b86dc8a21a9c8c871609c4a4723dd8cec1670d 100644 (file)
@@ -702,16 +702,32 @@ cleanup:
 
 
 static int
-virStorageBackendLogicalBuildVol(virConnectPtr conn,
-                                 virStoragePoolObjPtr pool,
-                                 virStorageVolDefPtr vol,
-                                 unsigned int flags)
+virStorageBackendLogicalCreateVol(virConnectPtr conn,
+                                  virStoragePoolObjPtr pool,
+                                  virStorageVolDefPtr vol)
 {
     int fd = -1;
     virCommandPtr cmd = NULL;
     virErrorPtr err;
 
-    virCheckFlags(0, -1);
+    if (vol->target.encryption != NULL) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       "%s", _("storage pool does not support encrypted "
+                               "volumes"));
+        return -1;
+    }
+
+    vol->type = VIR_STORAGE_VOL_BLOCK;
+
+    if (vol->target.path != NULL) {
+        /* A target path passed to CreateVol has no meaning */
+        VIR_FREE(vol->target.path);
+    }
+
+    if (virAsprintf(&vol->target.path, "%s/%s",
+                    pool->def->target.path,
+                    vol->name) == -1)
+        return -1;
 
     cmd = virCommandNewArgList(LVCREATE,
                                "--name", vol->name,
@@ -770,7 +786,7 @@ virStorageBackendLogicalBuildVol(virConnectPtr conn,
 
     return 0;
 
-error:
+ error:
     err = virSaveLastError();
     VIR_FORCE_CLOSE(fd);
     virStorageBackendLogicalDeleteVol(conn, pool, vol, 0);
@@ -780,36 +796,6 @@ error:
     return -1;
 }
 
-
-static int
-virStorageBackendLogicalCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                  virStoragePoolObjPtr pool,
-                                  virStorageVolDefPtr vol)
-{
-    if (vol->target.encryption != NULL) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("storage pool does not support encrypted volumes"));
-        return -1;
-    }
-
-    vol->type = VIR_STORAGE_VOL_BLOCK;
-
-    VIR_FREE(vol->target.path);
-    if (virAsprintf(&vol->target.path, "%s/%s",
-                    pool->def->target.path,
-                    vol->name) == -1)
-        return -1;
-
-    if (virFileExists(vol->target.path)) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("volume target path '%s' already exists"),
-                       vol->target.path);
-        return -1;
-    }
-
-    return 0;
-}
-
 static int
 virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
                                      virStoragePoolObjPtr pool,
@@ -837,7 +823,7 @@ virStorageBackend virStorageBackendLogical = {
     .refreshPool = virStorageBackendLogicalRefreshPool,
     .stopPool = virStorageBackendLogicalStopPool,
     .deletePool = virStorageBackendLogicalDeletePool,
-    .buildVol = virStorageBackendLogicalBuildVol,
+    .buildVol = NULL,
     .buildVolFrom = virStorageBackendLogicalBuildVolFrom,
     .createVol = virStorageBackendLogicalCreateVol,
     .deleteVol = virStorageBackendLogicalDeleteVol,