[PATCHv2 3/7] storage: Error out when attempting to vol-upload into a remote pool

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

 



Pools that are not backed by files in the filesystem cause problems with
some APIs. Error out when attempting to upload a volume in such a pool
as currently we expect a local file representation for it.
---
 src/storage/storage_driver.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 942ba35..79beb45 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2003,13 +2003,32 @@ storageVolUpload(virStorageVolPtr obj,
         goto cleanup;
     }

-    /* Not using O_CREAT because the file is required to
-     * already exist at this point */
-    if (virFDStreamOpenFile(stream,
-                            vol->target.path,
-                            offset, length,
-                            O_WRONLY) < 0)
+    switch ((enum virStoragePoolType) pool->def->type) {
+    case VIR_STORAGE_POOL_DIR:
+    case VIR_STORAGE_POOL_FS:
+    case VIR_STORAGE_POOL_NETFS:
+    case VIR_STORAGE_POOL_LOGICAL:
+    case VIR_STORAGE_POOL_DISK:
+    case VIR_STORAGE_POOL_ISCSI:
+    case VIR_STORAGE_POOL_SCSI:
+    case VIR_STORAGE_POOL_MPATH:
+        /* Not using O_CREAT because the file is required to already exist at
+         * this point */
+        if (virFDStreamOpenFile(stream, vol->target.path,
+                                offset, length, O_WRONLY) < 0)
+            goto cleanup;
+
+        break;
+
+    case VIR_STORAGE_POOL_SHEEPDOG:
+    case VIR_STORAGE_POOL_RBD:
+    case VIR_STORAGE_POOL_GLUSTER:
+    case VIR_STORAGE_POOL_LAST:
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                       _("volume upload is not supported with pools of type %s"),
+                       virStoragePoolTypeToString(pool->def->type));
         goto cleanup;
+    }

     ret = 0;

-- 
1.9.0

--
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]