6d3351
From 9aeaadcf7d7f33cc5208bcbc788676f27691843a Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <9aeaadcf7d7f33cc5208bcbc788676f27691843a@dist-git>
6d3351
From: John Ferlan <jferlan@redhat.com>
6d3351
Date: Wed, 26 Apr 2017 08:41:14 -0400
6d3351
Subject: [PATCH] disk: Use virStorageBackendZeroPartitionTable
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1439132
6d3351
6d3351
During 'matrix' testing of all possible combinations I found that if
6d3351
device is formated with "gpt" first, then an attempt is made to format
6d3351
using "mac", a startup will fail.
6d3351
6d3351
Deeper analysis by Peter Krempa indicates that the "mac" table fits
6d3351
into the first block on the disk. Since the GPT disklabel is stored
6d3351
at LBA address 1 it is not overwritten at all. Thus it's apparent that
6d3351
the (blkid) detection tool then prefers GPT over a older disklabel.
6d3351
6d3351
The GPT disklabel has also a secondary copy at the last LBA of the disk.
6d3351
6d3351
So, follow the same logic as the logical pool in clearing a 1MB swath
6d3351
at the beginning and end of the device to avoid potential issues with
6d3351
larger sector sizes for the device.
6d3351
6d3351
Also fixed a minor formatting nit in virStorageBackendDeviceIsEmpty call.
6d3351
6d3351
(cherry picked from commit 3c4f2e3fb725054921f855a229afc7daca7119ae)
6d3351
Signed-off-by: John Ferlan <jferlan@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/storage/storage_backend_disk.c | 6 +++++-
6d3351
 1 file changed, 5 insertions(+), 1 deletion(-)
6d3351
6d3351
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
6d3351
index 39371f2d9..e8f67bb00 100644
6d3351
--- a/src/storage/storage_backend_disk.c
6d3351
+++ b/src/storage/storage_backend_disk.c
6d3351
@@ -491,11 +491,15 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
6d3351
         ok_to_mklabel = true;
6d3351
     } else {
6d3351
         if (virStorageBackendDeviceIsEmpty(pool->def->source.devices[0].path,
6d3351
-                                              fmt, true))
6d3351
+                                           fmt, true))
6d3351
             ok_to_mklabel = true;
6d3351
     }
6d3351
 
6d3351
     if (ok_to_mklabel) {
6d3351
+        if (virStorageBackendZeroPartitionTable(pool->def->source.devices[0].path,
6d3351
+                                                1024 * 1024) < 0)
6d3351
+            goto error;
6d3351
+
6d3351
         /* eg parted /dev/sda mklabel --script msdos */
6d3351
         if (format == VIR_STORAGE_POOL_DISK_UNKNOWN)
6d3351
             format = pool->def->source.format = VIR_STORAGE_POOL_DISK_DOS;
6d3351
-- 
6d3351
2.12.2
6d3351