[PATCH] Report an clear error when try to build lvm2 type pool

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

 



STORAGE_POOL_DISK_LVM2 can't be created by "parted mklabel", so
report an error when build such type pool

Signed-off-by: Shanzhi Yu <shyu@xxxxxxxxxx>
---
 src/storage/storage_backend_disk.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 8e12974..5b5a1fa 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -414,13 +414,21 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto error;
     }
 
-    if (flags & VIR_STORAGE_POOL_BUILD_OVERWRITE)
+    if (flags & VIR_STORAGE_POOL_BUILD_OVERWRITE &&
+                    pool->def->source.format != VIR_STORAGE_POOL_DISK_LVM2)
         ok_to_mklabel = true;
     else {
         int check;
 
         check = virStorageBackendDiskFindLabel(
                     pool->def->source.devices[0].path);
+
+        if (pool->def->source.format == VIR_STORAGE_POOL_DISK_LVM2){
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                            _("Invalid disk label: lvm2"));
+            goto error;
+        }
+
         if (check > 0) {
             ok_to_mklabel = true;
         } else if (check < 0) {
-- 
1.9.3

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