|
|
5c7b2d |
From 344e624f91010b6041c22ee8a24c9305b82af969 Mon Sep 17 00:00:00 2001
|
|
|
5c7b2d |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
5c7b2d |
Date: Tue, 18 May 2021 12:54:02 +0200
|
|
|
5c7b2d |
Subject: [PATCH] Fix resolving devices with names that look like BIOS drive
|
|
|
5c7b2d |
number
|
|
|
5c7b2d |
|
|
|
5c7b2d |
A RAID array named "10" will not be resolved because we try to
|
|
|
5c7b2d |
resolve it using EDD data and after this lookup fails, we don't
|
|
|
5c7b2d |
try the name.
|
|
|
5c7b2d |
|
|
|
5c7b2d |
Resolves: rhbz#1960798
|
|
|
5c7b2d |
---
|
|
|
5c7b2d |
blivet/devicetree.py | 18 +++++++++---------
|
|
|
5c7b2d |
tests/devicetree_test.py | 4 ++++
|
|
|
5c7b2d |
2 files changed, 13 insertions(+), 9 deletions(-)
|
|
|
5c7b2d |
|
|
|
5c7b2d |
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
|
|
|
5c7b2d |
index 88e9f0e5..f4ae1968 100644
|
|
|
5c7b2d |
--- a/blivet/devicetree.py
|
|
|
5c7b2d |
+++ b/blivet/devicetree.py
|
|
|
5c7b2d |
@@ -634,20 +634,20 @@ class DeviceTreeBase(object):
|
|
|
5c7b2d |
(label.startswith("'") and label.endswith("'"))):
|
|
|
5c7b2d |
label = label[1:-1]
|
|
|
5c7b2d |
device = self.labels.get(label)
|
|
|
5c7b2d |
- elif re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec):
|
|
|
5c7b2d |
- # BIOS drive number
|
|
|
5c7b2d |
- (drive, _p, partnum) = devspec.partition("p")
|
|
|
5c7b2d |
- spec = int(drive, 16)
|
|
|
5c7b2d |
- for (edd_name, edd_number) in self.edd_dict.items():
|
|
|
5c7b2d |
- if edd_number == spec:
|
|
|
5c7b2d |
- device = self.get_device_by_name(edd_name + partnum)
|
|
|
5c7b2d |
- break
|
|
|
5c7b2d |
elif options and "nodev" in options.split(","):
|
|
|
5c7b2d |
device = self.get_device_by_name(devspec)
|
|
|
5c7b2d |
if not device:
|
|
|
5c7b2d |
device = self.get_device_by_path(devspec)
|
|
|
5c7b2d |
else:
|
|
|
5c7b2d |
- if not devspec.startswith("/dev/"):
|
|
|
5c7b2d |
+ if re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec):
|
|
|
5c7b2d |
+ # BIOS drive number
|
|
|
5c7b2d |
+ (drive, _p, partnum) = devspec.partition("p")
|
|
|
5c7b2d |
+ spec = int(drive, 16)
|
|
|
5c7b2d |
+ for (edd_name, edd_number) in self.edd_dict.items():
|
|
|
5c7b2d |
+ if edd_number == spec:
|
|
|
5c7b2d |
+ device = self.get_device_by_name(edd_name + partnum)
|
|
|
5c7b2d |
+ break
|
|
|
5c7b2d |
+ if not device and not devspec.startswith("/dev/"):
|
|
|
5c7b2d |
device = self.get_device_by_name(devspec)
|
|
|
5c7b2d |
if not device:
|
|
|
5c7b2d |
devspec = "/dev/" + devspec
|
|
|
5c7b2d |
diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py
|
|
|
5c7b2d |
index 11f8469d..b033343d 100644
|
|
|
5c7b2d |
--- a/tests/devicetree_test.py
|
|
|
5c7b2d |
+++ b/tests/devicetree_test.py
|
|
|
5c7b2d |
@@ -49,6 +49,9 @@ class DeviceTreeTestCase(unittest.TestCase):
|
|
|
5c7b2d |
dev3 = StorageDevice("sdp2", exists=True)
|
|
|
5c7b2d |
dt._add_device(dev3)
|
|
|
5c7b2d |
|
|
|
5c7b2d |
+ dev4 = StorageDevice("10", exists=True)
|
|
|
5c7b2d |
+ dt._add_device(dev4)
|
|
|
5c7b2d |
+
|
|
|
5c7b2d |
dt.edd_dict.update({"dev1": 0x81,
|
|
|
5c7b2d |
"dev2": 0x82})
|
|
|
5c7b2d |
|
|
|
5c7b2d |
@@ -62,6 +65,7 @@ class DeviceTreeTestCase(unittest.TestCase):
|
|
|
5c7b2d |
self.assertEqual(dt.resolve_device("0x82"), dev2)
|
|
|
5c7b2d |
|
|
|
5c7b2d |
self.assertEqual(dt.resolve_device(dev3.name), dev3)
|
|
|
5c7b2d |
+ self.assertEqual(dt.resolve_device(dev4.name), dev4)
|
|
|
5c7b2d |
|
|
|
5c7b2d |
def test_device_name(self):
|
|
|
5c7b2d |
# check that devicetree.names property contains all device's names
|
|
|
5c7b2d |
--
|
|
|
5c7b2d |
2.31.1
|
|
|
5c7b2d |
|