[PATCH 1/3] storage: Alter logic when both BLKID and PARTED unavailable

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

 



If neither BLKID or PARTED is available and we're not writing, then
just return 0 which allows the underlying storage pool to generate
a failur. If both are unavailable and we're writing, then generate
a more generic error message.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_backend.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 18433e9..6bdfbf1 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -2842,9 +2842,6 @@ virStorageBackendBLKIDFindEmpty(const char *device ATTRIBUTE_UNUSED,
                                 const char *format ATTRIBUTE_UNUSED,
                                 bool writelabel ATTRIBUTE_UNUSED)
 {
-    virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                   _("probing for filesystems is unsupported "
-                     "by this build"));
     return -2;
 }
 
@@ -2868,11 +2865,10 @@ virStorageBackendPARTEDValidLabel(const char *device ATTRIBUTE_UNUSED,
                                   const char *format ATTRIBUTE_UNUSED,
                                   bool writelabel ATTRIBUTE_UNUSED)
 {
-    virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                   _("PARTED is unsupported by this build"));
-    return -1;
+    return -2;
 }
 
+
 #endif /* #if WITH_STORAGE_DISK */
 
 
@@ -2898,5 +2894,17 @@ virStorageBackendDeviceIsEmpty(const char *devpath,
                                                writelabel)) == -2)
         ret = virStorageBackendPARTEDValidLabel(devpath, format, writelabel);
 
+    /* Neither BLKID nor PARTED available, but we're not writing,
+     * so no mechanism to check, so allow a lower layer to reject. */
+    if (ret == -2 && !writelabel)
+        return 0;
+
+    if (ret == -2) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("Unable to probe '%s' for existing data, "
+                         "requires create/build using overwrite"),
+                       devpath);
+    }
+
     return ret == 0;
 }
-- 
2.7.4

--
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]
  Powered by Linux