[PATCH 3/3] storage: Resolve issues with disk partition build/start checks

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

 



https://bugzilla.redhat.com/show_bug.cgi?id=1439132

Fix some issues discovered when building between multiple different
supported disk partition types.

1. The "dvh" and "pc98" were specifically checked during the blkid
partition processing in commit id 'a48c674fb', but commit id 'a4cb4a74f'
really messed things up by missing an else condition causing PARTEDFindLabel
to always return DIFFERENT.

2. Add the "bsd" to the list of format types to not checked during
blkid processing even though it supposedly knows the format - for some
(now unknown) reason it's returning partiion not found. So let's just
let PARTED handle that too.

3.  During 'matrix' testing of all possible combinations I found that if
device is formated with "gpt" first, then an attempt is made to format
using "mac", a startup will fail.  By adding a clearing of the first
2048 bytes of the device (similar to the logical pool code), the issue
is resolved.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_backend_disk.c |  4 ++++
 src/storage/storage_util.c         | 10 ++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 39371f2..ce40ddd 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -496,6 +496,10 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     }
 
     if (ok_to_mklabel) {
+        if (virStorageBackendZeroDeviceHeader(pool->def->source.devices[0].path,
+                                              4 * SECTOR_SIZE) < 0)
+            goto error;
+
         /* eg parted /dev/sda mklabel --script msdos */
         if (format == VIR_STORAGE_POOL_DISK_UNKNOWN)
             format = pool->def->source.format = VIR_STORAGE_POOL_DISK_DOS;
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 784df7a..812429e 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -3034,10 +3034,12 @@ virStorageBackendBLKIDFindPart(blkid_probe probe,
 
     /* A blkid_known_pttype on "dvh" and "pc98" returns a failure;
      * however, the blkid_do_probe for "dvh" returns "sgi" and
-     * for "pc98" it returns "dos". So since those will cause problems
+     * for "pc98" it returns "dos". Although "bsd" is recognized,
+     * it seems that the parted created partition table is not being
+     * properly recogized. Since each of these will cause problems
      * with startup comparison, let's just treat them as UNKNOWN causing
      * the caller to fallback to using PARTED */
-    if (STREQ(format, "dvh") || STREQ(format, "pc98"))
+    if (STREQ(format, "dvh") || STREQ(format, "pc98") || STREQ(format, "bsd"))
         return VIR_STORAGE_BLKID_PROBE_UNKNOWN;
 
     /* Make sure we're doing a partitions probe from the start */
@@ -3245,8 +3247,8 @@ virStorageBackendPARTEDFindLabel(const char *device,
     /*  Does the on disk match what the pool desired? */
     if (STREQ(start, format))
         ret = VIR_STORAGE_PARTED_MATCH;
-
-    ret = VIR_STORAGE_PARTED_DIFFERENT;
+    else
+        ret = VIR_STORAGE_PARTED_DIFFERENT;
 
  cleanup:
     virCommandFree(cmd);
-- 
2.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]
  Powered by Linux