Fix resolving devices with names that look like BIOS drive number
Resolves: rhbz#1960798
This commit is contained in:
parent
b688eafcbf
commit
a366c6f46d
@ -0,0 +1,75 @@
|
|||||||
|
From 344e624f91010b6041c22ee8a24c9305b82af969 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Tue, 18 May 2021 12:54:02 +0200
|
||||||
|
Subject: [PATCH] Fix resolving devices with names that look like BIOS drive
|
||||||
|
number
|
||||||
|
|
||||||
|
A RAID array named "10" will not be resolved because we try to
|
||||||
|
resolve it using EDD data and after this lookup fails, we don't
|
||||||
|
try the name.
|
||||||
|
|
||||||
|
Resolves: rhbz#1960798
|
||||||
|
---
|
||||||
|
blivet/devicetree.py | 18 +++++++++---------
|
||||||
|
tests/devicetree_test.py | 4 ++++
|
||||||
|
2 files changed, 13 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
|
||||||
|
index 88e9f0e5..f4ae1968 100644
|
||||||
|
--- a/blivet/devicetree.py
|
||||||
|
+++ b/blivet/devicetree.py
|
||||||
|
@@ -634,20 +634,20 @@ class DeviceTreeBase(object):
|
||||||
|
(label.startswith("'") and label.endswith("'"))):
|
||||||
|
label = label[1:-1]
|
||||||
|
device = self.labels.get(label)
|
||||||
|
- elif re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec):
|
||||||
|
- # BIOS drive number
|
||||||
|
- (drive, _p, partnum) = devspec.partition("p")
|
||||||
|
- spec = int(drive, 16)
|
||||||
|
- for (edd_name, edd_number) in self.edd_dict.items():
|
||||||
|
- if edd_number == spec:
|
||||||
|
- device = self.get_device_by_name(edd_name + partnum)
|
||||||
|
- break
|
||||||
|
elif options and "nodev" in options.split(","):
|
||||||
|
device = self.get_device_by_name(devspec)
|
||||||
|
if not device:
|
||||||
|
device = self.get_device_by_path(devspec)
|
||||||
|
else:
|
||||||
|
- if not devspec.startswith("/dev/"):
|
||||||
|
+ if re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec):
|
||||||
|
+ # BIOS drive number
|
||||||
|
+ (drive, _p, partnum) = devspec.partition("p")
|
||||||
|
+ spec = int(drive, 16)
|
||||||
|
+ for (edd_name, edd_number) in self.edd_dict.items():
|
||||||
|
+ if edd_number == spec:
|
||||||
|
+ device = self.get_device_by_name(edd_name + partnum)
|
||||||
|
+ break
|
||||||
|
+ if not device and not devspec.startswith("/dev/"):
|
||||||
|
device = self.get_device_by_name(devspec)
|
||||||
|
if not device:
|
||||||
|
devspec = "/dev/" + devspec
|
||||||
|
diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py
|
||||||
|
index 11f8469d..b033343d 100644
|
||||||
|
--- a/tests/devicetree_test.py
|
||||||
|
+++ b/tests/devicetree_test.py
|
||||||
|
@@ -49,6 +49,9 @@ class DeviceTreeTestCase(unittest.TestCase):
|
||||||
|
dev3 = StorageDevice("sdp2", exists=True)
|
||||||
|
dt._add_device(dev3)
|
||||||
|
|
||||||
|
+ dev4 = StorageDevice("10", exists=True)
|
||||||
|
+ dt._add_device(dev4)
|
||||||
|
+
|
||||||
|
dt.edd_dict.update({"dev1": 0x81,
|
||||||
|
"dev2": 0x82})
|
||||||
|
|
||||||
|
@@ -62,6 +65,7 @@ class DeviceTreeTestCase(unittest.TestCase):
|
||||||
|
self.assertEqual(dt.resolve_device("0x82"), dev2)
|
||||||
|
|
||||||
|
self.assertEqual(dt.resolve_device(dev3.name), dev3)
|
||||||
|
+ self.assertEqual(dt.resolve_device(dev4.name), dev4)
|
||||||
|
|
||||||
|
def test_device_name(self):
|
||||||
|
# check that devicetree.names property contains all device's names
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -23,7 +23,7 @@ Version: 3.4.0
|
|||||||
|
|
||||||
#%%global prerelease .b2
|
#%%global prerelease .b2
|
||||||
# prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2
|
# prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2
|
||||||
Release: 2%{?prerelease}%{?dist}
|
Release: 3%{?prerelease}%{?dist}
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
%global realname blivet
|
%global realname blivet
|
||||||
@ -35,6 +35,8 @@ Source1: http://github.com/storaged-project/blivet/archive/%{realname}-%{realver
|
|||||||
Patch0: 0001-remove-btrfs-plugin.patch
|
Patch0: 0001-remove-btrfs-plugin.patch
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
Patch1: 0002-Fix-resolving-devices-with-names-that-look-like-BIOS.patch
|
||||||
|
|
||||||
# Versions of required components (done so we make sure the buildrequires
|
# Versions of required components (done so we make sure the buildrequires
|
||||||
# match the requires versions of things).
|
# match the requires versions of things).
|
||||||
%global partedver 3.2
|
%global partedver 3.2
|
||||||
@ -196,6 +198,9 @@ configuration.
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jun 30 2021 Vojtech Trefny <vtrefny@redhat.com> - 3.4.0-3
|
||||||
|
- Fix resolving devices with names that look like BIOS drive number (#1960798)
|
||||||
|
|
||||||
* Thu Jun 03 2021 Python Maint <python-maint@redhat.com> - 1:3.4.0-2
|
* Thu Jun 03 2021 Python Maint <python-maint@redhat.com> - 1:3.4.0-2
|
||||||
- Rebuilt for Python 3.10
|
- Rebuilt for Python 3.10
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user