From c732af69322821a6c447b4a01b8442094ba79a71 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Jul 21 2021 05:57:55 +0000 Subject: Fix resolving devices with names that look like BIOS drive number Resolves: rhbz#1983310 Additionally, clean up unused duplicate patch to remove btrfs plugin. Signed-off-by: Neal Gompa --- diff --git a/0001-remove-btrfs-plugin.patch b/0001-remove-btrfs-plugin.patch deleted file mode 100644 index 4d67bef..0000000 --- a/0001-remove-btrfs-plugin.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 8b527ee85b6594d506d445ff4c30579cccef8ae6 Mon Sep 17 00:00:00 2001 -From: Vojtech Trefny -Date: Wed, 11 Nov 2020 13:24:55 +0100 -Subject: [PATCH] Remove btrfs from requested libblockdev plugins - ---- - blivet/__init__.py | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/blivet/__init__.py b/blivet/__init__.py -index 14bd5c61..1410d78e 100644 ---- a/blivet/__init__.py -+++ b/blivet/__init__.py -@@ -63,9 +63,9 @@ gi.require_version("BlockDev", "2.0") - from gi.repository import GLib - from gi.repository import BlockDev as blockdev - if arch.is_s390(): -- _REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm")) -+ _REQUESTED_PLUGIN_NAMES = set(("lvm", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm")) - else: -- _REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm")) -+ _REQUESTED_PLUGIN_NAMES = set(("lvm", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm")) - - _requested_plugins = blockdev.plugin_specs_from_names(_REQUESTED_PLUGIN_NAMES) - try: --- -2.26.2 - diff --git a/0008-Fix-resolving-devices-with-names-that-look-like-BIOS.patch b/0008-Fix-resolving-devices-with-names-that-look-like-BIOS.patch new file mode 100644 index 0000000..28c7351 --- /dev/null +++ b/0008-Fix-resolving-devices-with-names-that-look-like-BIOS.patch @@ -0,0 +1,75 @@ +From 344e624f91010b6041c22ee8a24c9305b82af969 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +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 + diff --git a/python-blivet.spec b/python-blivet.spec index 7d0ad38..953bccf 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -23,7 +23,7 @@ Version: 3.4.0 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 2%{?prerelease}%{?dist} +Release: 3%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ %global realname blivet @@ -37,6 +37,7 @@ Patch3: 0004-Revert-Terminology-cleanups.patch Patch4: 0005-Fix-unify-importing-mock-module-in-tests.patch Patch5: 0006-Fix-util.virt_detect-on-Xen.patch Patch6: 0007-Fix-activating-old-style-LVM-snapshots.patch +Patch7: 0008-Fix-resolving-devices-with-names-that-look-like-BIOS.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -199,6 +200,10 @@ configuration. %endif %changelog +* Sat Jul 17 2021 Neal Gompa - 3.4.0-3 +- Fix resolving devices with names that look like BIOS drive number + Resolves: rhbz#1983310 + * Wed Jul 7 2021 Vojtech Trefny - 3.4.0-2 - Fix activating old style LVM snapshots Resolves: rhbz#1961944