[PATCH v3 3/4] scsi: Adjust return value for virStorageBackendSCSINewLun

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

 



Use virStorageBackendPoolUseDevPath API to determine whether creation of
stable target path is possible for the volume. If not, then return failure.

This will differentiate a failed virStorageBackendStablePath which won't
need to be fatal. Thus, we'll add a -2 return value to differentiate that
the failure was a result of either the inability to find the symlink for
the device or failure to open the target path directory

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_backend_scsi.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index b96caec..d3c6470 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -146,6 +146,16 @@ virStorageBackendSCSISerial(const char *dev)
 }
 
 
+/*
+ * Attempt to create a new LUN
+ *
+ * Returns:
+ *
+ *  0  => Success
+ *  -1 => Failure due to some sort of OOM or other fatal issue found when
+ *        attempting to get/update information about a found volume
+ *  -2 => Failure to find a stable path, not fatal, caller can try another
+ */
 static int
 virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
                             uint32_t host ATTRIBUTE_UNUSED,
@@ -158,6 +168,18 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
     char *devpath = NULL;
     int retval = -1;
 
+    /* Before we get too far - let's see if the pool is using target path
+     * starting with /dev. Attempts to find a stable path not based on a
+     * pool target starting with /dev will fail and do lots of unnecessary
+     * work - so we'll short circuit here.
+     */
+    if (!virStorageBackendPoolUseDevPath(pool)) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("unable to use target path '%s' for dev '%s'"),
+                       NULLSTR(pool->def->target.path), dev);
+        goto cleanup;
+    }
+
     if (VIR_ALLOC(vol) < 0)
         goto cleanup;
 
@@ -187,13 +209,12 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
                                                         true)) == NULL)
         goto cleanup;
 
-    if (STREQ(devpath, vol->target.path) &&
-        !(STREQ(pool->def->target.path, "/dev") ||
-          STREQ(pool->def->target.path, "/dev/"))) {
+    if (STREQ(devpath, vol->target.path)) {
 
         VIR_DEBUG("No stable path found for '%s' in '%s'",
                   devpath, pool->def->target.path);
 
+        retval = -2;
         goto cleanup;
     }
 
-- 
2.1.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]