[master 1/3] Use partially corrupt gpt disklabels.
dwlehman
installerbot-noreply at redhat.com
Fri Apr 10 19:58:22 UTC 2015
From: David Lehman <dlehman at redhat.com>
Tell pyparted to answer "yes" when libparted asks if we want to proceed
using the secondary gpt disklabel in the event of a corrupt primary (or
use the primary in spite of a corrupt secondary label). We only do this
while populating the devicetree.
We only do this if udev/blkid has identified the disk as containing a
disklabel. This means we are going with the system's consensus as to
which formatting to acknowledge in the event there are multiple
signatures on the disk.
Related: rhbz#1157657
---
blivet/populator.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/blivet/populator.py b/blivet/populator.py
index 1db7938..b3a3822 100644
--- a/blivet/populator.py
+++ b/blivet/populator.py
@@ -25,6 +25,7 @@
import shutil
import pprint
import copy
+import parted
from gi.repository import BlockDev as blockdev
from gi.repository import GLib
@@ -54,6 +55,18 @@
import logging
log = logging.getLogger("blivet")
+def parted_exn_handler(exn_type, exn_options, exn_msg):
+ """ Answer any of parted's yes/no questions in the affirmative.
+
+ This allows us to proceed with partially corrupt gpt disklabels.
+ """
+ log.info("parted exception: %s", exn_msg)
+ ret = parted.EXCEPTION_RESOLVE_UNHANDLED
+ if exn_type == parted.EXCEPTION_TYPE_ERROR and \
+ exn_options == parted.EXCEPTION_OPT_YES_NO:
+ ret = parted.EXCEPTION_RESOLVE_YES
+ return ret
+
class Populator(object):
def __init__(self, devicetree=None, conf=None, passphrase=None,
luksDict=None, iscsi=None, dasd=None):
@@ -1511,11 +1524,13 @@ def populate(self, cleanupOnly=False):
if cleanupOnly:
self._cleanup = True
+ parted.register_exn_handler(parted_exn_handler)
try:
self._populate()
except Exception:
raise
finally:
+ parted.clear_exn_handler()
self.restoreConfigs()
def _populate(self):
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/1dcba8bc3d2396f6ef417cea00444ac39d08d237
More information about the anaconda-patches
mailing list