From b4754974029e1b213177a565a2f7042af14de3a8 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Tue, 19 Nov 2024 13:23:50 +0100 Subject: [PATCH] Make GPT default label type on all architectures Resolves: RHEL-52200 --- ...ault-label-type-on-all-architectures.patch | 122 ++++++++++++++++++ python-blivet.spec | 7 +- 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 0011-Make-GPT-default-label-type-on-all-architectures.patch diff --git a/0011-Make-GPT-default-label-type-on-all-architectures.patch b/0011-Make-GPT-default-label-type-on-all-architectures.patch new file mode 100644 index 0000000..7fba7a3 --- /dev/null +++ b/0011-Make-GPT-default-label-type-on-all-architectures.patch @@ -0,0 +1,122 @@ +From c8eff25e4c25183a76e97108d4607455cfc96ae2 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 14 Nov 2024 14:53:28 +0100 +Subject: [PATCH] Make GPT default label type on all architectures + +Exceptions are DASD drives on s390 and 32bit ARM. Everywhere else +GPT will be default. + +Resolves: RHEL-52200 +--- + blivet/formats/disklabel.py | 11 +++++----- + .../formats_tests/disklabel_test.py | 20 +++++++++---------- + 2 files changed, 16 insertions(+), 15 deletions(-) + +diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py +index f2857f07..8b39dc79 100644 +--- a/blivet/formats/disklabel.py ++++ b/blivet/formats/disklabel.py +@@ -220,12 +220,13 @@ class DiskLabel(DeviceFormat): + + @classmethod + def get_platform_label_types(cls): +- label_types = ["msdos", "gpt"] ++ # always prefer gpt except for configurations below ++ label_types = ["gpt", "msdos"] + if arch.is_pmac(): + label_types = ["mac"] +- # always prefer gpt on aarch64, x86_64, and EFI plats except 32-bit ARM +- elif arch.is_aarch64() or arch.is_x86(bits=64) or (arch.is_efi() and not arch.is_arm()): +- label_types = ["gpt", "msdos"] ++ # prefet msdos on 32-bit ARM ++ elif arch.is_arm(): ++ label_types = ["msdos", "gpt"] + elif arch.is_s390(): + label_types += ["dasd"] + +@@ -254,7 +255,7 @@ class DiskLabel(DeviceFormat): + if arch.is_s390(): + if blockdev.s390.dasd_is_fba(self.device): + # the device is FBA DASD +- return "msdos" ++ return "gpt" + elif self.parted_device.type == parted.DEVICE_DASD: + # the device is DASD + return "dasd" +diff --git a/tests/unit_tests/formats_tests/disklabel_test.py b/tests/unit_tests/formats_tests/disklabel_test.py +index 9f6e4542..823a3663 100644 +--- a/tests/unit_tests/formats_tests/disklabel_test.py ++++ b/tests/unit_tests/formats_tests/disklabel_test.py +@@ -71,7 +71,7 @@ class DiskLabelTestCase(unittest.TestCase): + arch.is_pmac.return_value = False + arch.is_x86.return_value = False + +- self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "gpt"]) ++ self.assertEqual(disklabel_class.get_platform_label_types(), ["gpt", "msdos"]) + + arch.is_pmac.return_value = True + self.assertEqual(disklabel_class.get_platform_label_types(), ["mac"]) +@@ -100,7 +100,7 @@ class DiskLabelTestCase(unittest.TestCase): + arch.is_efi.return_value = False + + arch.is_s390.return_value = True +- self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "gpt", "dasd"]) ++ self.assertEqual(disklabel_class.get_platform_label_types(), ["gpt", "msdos", "dasd"]) + arch.is_s390.return_value = False + + def test_label_type_size_check(self): +@@ -121,14 +121,14 @@ class DiskLabelTestCase(unittest.TestCase): + + with patch.object(blivet.formats.disklabel.DiskLabel, "parted_device", new=PropertyMock(return_value=None)): + # no parted device -> no passing size check +- self.assertEqual(dl._label_type_size_check("msdos"), False) ++ self.assertEqual(dl._label_type_size_check("gpt"), False) + + @patch("blivet.formats.disklabel.arch") + def test_best_label_type(self, arch): + """ + 1. is always in _disklabel_types + 2. is the default unless the device is too long for the default +- 3. is msdos for fba dasd on S390 ++ 3. is gpt for fba dasd on S390 + 4. is dasd for non-fba dasd on S390 + """ + dl = blivet.formats.disklabel.DiskLabel() +@@ -144,17 +144,17 @@ class DiskLabelTestCase(unittest.TestCase): + arch.is_x86.return_value = False + + with patch.object(dl, '_label_type_size_check') as size_check: +- # size check passes for first type ("msdos") ++ # size check passes for first type ("gpt") + size_check.return_value = True +- self.assertEqual(dl._get_best_label_type(), "msdos") ++ self.assertEqual(dl._get_best_label_type(), "gpt") + + # size checks all fail -> label type is None + size_check.return_value = False + self.assertEqual(dl._get_best_label_type(), None) + +- # size check passes on second call -> label type is "gpt" (second in platform list) ++ # size check passes on second call -> label type is "msdos" (second in platform list) + size_check.side_effect = [False, True] +- self.assertEqual(dl._get_best_label_type(), "gpt") ++ self.assertEqual(dl._get_best_label_type(), "msdos") + + arch.is_pmac.return_value = True + with patch.object(dl, '_label_type_size_check') as size_check: +@@ -175,10 +175,10 @@ class DiskLabelTestCase(unittest.TestCase): + size_check.return_value = True + with patch("blivet.formats.disklabel.blockdev.s390") as _s390: + _s390.dasd_is_fba.return_value = False +- self.assertEqual(dl._get_best_label_type(), "msdos") ++ self.assertEqual(dl._get_best_label_type(), "gpt") + + _s390.dasd_is_fba.return_value = True +- self.assertEqual(dl._get_best_label_type(), "msdos") ++ self.assertEqual(dl._get_best_label_type(), "gpt") + + _s390.dasd_is_fba.return_value = False + dl._parted_device.type = parted.DEVICE_DASD +-- +2.47.0 + diff --git a/python-blivet.spec b/python-blivet.spec index 172ad35..097ce2e 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -5,7 +5,7 @@ Version: 3.10.0 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 12%{?prerelease}%{?dist} +Release: 13%{?prerelease}%{?dist} Epoch: 1 License: LGPL-2.1-or-later %global realname blivet @@ -26,6 +26,7 @@ Patch6: 0007-Fix-checking-for-NVMe-plugin-availability.patch Patch7: 0008-Align-sizes-up-for-growable-LVs.patch Patch8: 0009-mod_pass_in_stratis_test.patch Patch9: 0010-Fix_running_tests_in_FIPS_mode.patch +Patch10: 0011-Make-GPT-default-label-type-on-all-architectures.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -120,6 +121,10 @@ make DESTDIR=%{buildroot} install %{python3_sitelib}/* %changelog +* Tue Nov 19 2024 Vojtech Trefny - 3.10.0-13 +- Make GPT default label type on all architectures + Resolves: RHEL-52200 + * Tue Nov 12 2024 Vojtech Trefny - 3.10.0-12 - Fix running tests in FIPS mode Resolves: RHEL-45173