render / rpms / libvirt

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