From bda387a89ac388020c71fb58ae77de0329a96fee Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 05 2019 19:44:22 +0000 Subject: import python-blivet-3.1.0-17.el8 --- diff --git a/.gitignore b/.gitignore index 55ed9cf..4c9628e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +SOURCES/blivet-3.1.0-tests.tar.gz SOURCES/blivet-3.1.0.tar.gz diff --git a/.python-blivet.metadata b/.python-blivet.metadata index 6dd0b4e..7860377 100644 --- a/.python-blivet.metadata +++ b/.python-blivet.metadata @@ -1 +1,2 @@ +4bd8abd1cb7bffa644cffb017f6583a2fd7c19f9 SOURCES/blivet-3.1.0-tests.tar.gz f388d30e55dfaa9c22415c2e9e3f9670f9d08f27 SOURCES/blivet-3.1.0.tar.gz diff --git a/SOURCES/0004-allow-removing-btrfs-volumes-without-btrfs-support.patch b/SOURCES/0004-allow-removing-btrfs-volumes-without-btrfs-support.patch index c4c868d..212f6c1 100644 --- a/SOURCES/0004-allow-removing-btrfs-volumes-without-btrfs-support.patch +++ b/SOURCES/0004-allow-removing-btrfs-volumes-without-btrfs-support.patch @@ -1,4 +1,4 @@ -From d2d9a4e0c086a0551dac644d45954f23e0116ef1 Mon Sep 17 00:00:00 2001 +From fd07d14ad1f19c700d5344c8af11be6a1e314ceb Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 12 Sep 2018 10:45:41 +0200 Subject: [PATCH 1/2] Allow removing btrfs volumes without btrfs support @@ -16,7 +16,7 @@ diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py index 3e337e18..b3e9e5f1 100644 --- a/blivet/deviceaction.py +++ b/blivet/deviceaction.py -@@ -160,15 +160,19 @@ class DeviceAction(util.ObjectID): +@@ -160,15 +160,19 @@ def __init__(self, device): if not isinstance(device, StorageDevice): raise ValueError("arg 1 must be a StorageDevice instance") @@ -41,7 +41,7 @@ index 3e337e18..b3e9e5f1 100644 def apply(self): """ apply changes related to the action to the device(s) """ self._applied = True -@@ -379,6 +383,15 @@ class ActionDestroyDevice(DeviceAction): +@@ -379,6 +383,15 @@ def __init__(self, device): # XXX should we insist that device.fs be None? DeviceAction.__init__(self, device) @@ -57,11 +57,8 @@ index 3e337e18..b3e9e5f1 100644 def execute(self, callbacks=None): super(ActionDestroyDevice, self).execute(callbacks=callbacks) self.device.destroy() --- -2.17.1 - -From a9bcf26e085160a84b78c396c33cd0a77a35a746 Mon Sep 17 00:00:00 2001 +From b9f1b4acb654c5fb70be1a2200bcf3a34dcde467 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Mon, 17 Sep 2018 10:25:24 +0200 Subject: [PATCH 2/2] Check device dependencies only for device actions @@ -73,13 +70,14 @@ without libblockdev crypto plugin. Related: rhbz#1605213 --- blivet/deviceaction.py | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + tests/devices_test/dependencies_test.py | 4 ---- + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py index b3e9e5f1..14a06ff0 100644 --- a/blivet/deviceaction.py +++ b/blivet/deviceaction.py -@@ -162,7 +162,8 @@ class DeviceAction(util.ObjectID): +@@ -162,7 +162,8 @@ def __init__(self, device): self.device = device @@ -89,6 +87,18 @@ index b3e9e5f1..14a06ff0 100644 self.container = getattr(self.device, "container", None) self._applied = False --- -2.17.1 - +diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py +index 0b44493e..e6b5bdb4 100644 +--- a/tests/devices_test/dependencies_test.py ++++ b/tests/devices_test/dependencies_test.py +@@ -97,10 +97,6 @@ def test_availability_mdraidplugin(self): + ActionCreateDevice(self.luks) + with self.assertRaises(DependencyError): + ActionDestroyDevice(self.dev) +- with self.assertRaises(DependencyError): +- ActionCreateFormat(self.dev) +- with self.assertRaises(DependencyError): +- ActionDestroyFormat(self.dev) + + def _clean_up(self): + availability.BLOCKDEV_MDRAID_PLUGIN._method = self.mdraid_method diff --git a/SOURCES/0005-arm7-cleanups.patch b/SOURCES/0005-arm7-cleanups.patch index 7a05106..8d4f93c 100644 --- a/SOURCES/0005-arm7-cleanups.patch +++ b/SOURCES/0005-arm7-cleanups.patch @@ -1,7 +1,7 @@ -From ec8e27664a6a551647ace23bfd5d16036db95bd6 Mon Sep 17 00:00:00 2001 +From 12a2bdf3fc5a7a4568ff56b244d3067b73f82681 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Tue, 7 Aug 2018 15:11:56 +0100 -Subject: [PATCH 1/4] arch: arm: drop omap specifics for partitioning +Subject: [PATCH 1/6] arch: arm: drop omap specifics for partitioning We've long stopped supporting or using any specifics around OMAP ARM machines and all ARM platforms support the extlinux means of @@ -32,7 +32,7 @@ diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py index 47ff547b..623e1c9d 100644 --- a/blivet/devices/partition.py +++ b/blivet/devices/partition.py -@@ -421,9 +421,6 @@ class PartitionDevice(StorageDevice): +@@ -421,9 +421,6 @@ def _get_weight(self): # On ARM images '/' must be the last partition. if self.format.mountpoint == "/": weight = -100 @@ -42,14 +42,11 @@ index 47ff547b..623e1c9d 100644 elif arch.is_ppc(): if arch.is_pmac() and self.format.type == "appleboot": weight = 5000 --- -2.18.0 - -From be145b613ceea45edf4e2d522d28113300d706fa Mon Sep 17 00:00:00 2001 +From ec978c3c625c74c387a9c8074d2378c4ecbeac47 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Thu, 16 Aug 2018 14:32:19 +0100 -Subject: [PATCH 2/4] arch: arm: drop get_arm_machine function +Subject: [PATCH 2/6] arch: arm: drop get_arm_machine function The get_arm_machine function was used when we had to have detection for which arm specific kernel to install. The last userr of this was the omap check for @@ -66,7 +63,7 @@ diff --git a/blivet/arch.py b/blivet/arch.py index f30b2d8b..55ce8108 100644 --- a/blivet/arch.py +++ b/blivet/arch.py -@@ -33,7 +33,6 @@ from __future__ import absolute_import +@@ -33,7 +33,6 @@ import os @@ -106,7 +103,7 @@ diff --git a/blivet/flags.py b/blivet/flags.py index 18401218..4e26d82f 100644 --- a/blivet/flags.py +++ b/blivet/flags.py -@@ -57,8 +57,6 @@ class Flags(object): +@@ -57,8 +57,6 @@ def __init__(self): self.jfs = True self.reiserfs = True @@ -115,14 +112,11 @@ index 18401218..4e26d82f 100644 self.gpt = False # for this flag to take effect, --- -2.18.0 - -From 34595cfef911f9512558b02216eaf58d0fdd6786 Mon Sep 17 00:00:00 2001 +From e75049e9e9edac9da789cee2add2b4190159805d Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Thu, 16 Aug 2018 14:35:30 +0100 -Subject: [PATCH 3/4] Aarch64 platforms: Fix gpt defaults for 64 bit arm +Subject: [PATCH 3/6] Aarch64 platforms: Fix gpt defaults for 64 bit arm platforms The 46165f589d commit added support for msdos needed on some aarch64 devices @@ -138,7 +132,7 @@ diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py index 44f9834c..e93a4c13 100644 --- a/blivet/formats/disklabel.py +++ b/blivet/formats/disklabel.py -@@ -223,6 +223,8 @@ class DiskLabel(DeviceFormat): +@@ -223,6 +223,8 @@ def get_platform_label_types(cls): label_types = ["msdos", "gpt"] if arch.is_pmac(): label_types = ["mac"] @@ -147,14 +141,11 @@ index 44f9834c..e93a4c13 100644 elif arch.is_efi() and not arch.is_aarch64(): label_types = ["gpt"] elif arch.is_s390(): --- -2.18.0 - -From 461623d49963618a30bd960d48c6d34f1d076917 Mon Sep 17 00:00:00 2001 +From dda51536e902def437872fcdb3005efaff231703 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Thu, 16 Aug 2018 14:38:16 +0100 -Subject: [PATCH 4/4] arm: add support for EFI on ARMv7 +Subject: [PATCH 4/6] arm: add support for EFI on ARMv7 We now can support EFI for ARMv7 so add/enabled the checks for ARM too. @@ -167,7 +158,7 @@ diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py index e93a4c13..e13ab2f8 100644 --- a/blivet/formats/disklabel.py +++ b/blivet/formats/disklabel.py -@@ -225,6 +225,8 @@ class DiskLabel(DeviceFormat): +@@ -225,6 +225,8 @@ def get_platform_label_types(cls): label_types = ["mac"] elif arch.is_aarch64(): label_types = ["gpt", "msdos"] @@ -176,6 +167,106 @@ index e93a4c13..e13ab2f8 100644 elif arch.is_efi() and not arch.is_aarch64(): label_types = ["gpt"] elif arch.is_s390(): --- -2.18.0 +From 1cdd509f2034f456402f39045425cbdfe62bde97 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Thu, 23 Aug 2018 14:23:38 +0100 +Subject: [PATCH 5/6] Update disk label tests for ARM platforms + +UEFI supports either gpt or msdos but different platforms have different +requirements. Update the disk label tests to test the following: +- aarch64: gpt default but msdos option also supported +- ARMv7 UEFI: msdos default but gpt option also supported +- ARMv7 extlinux: msdos default, also support gpt + +Signed-off-by: Peter Robinson +--- + tests/formats_test/disklabel_test.py | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/tests/formats_test/disklabel_test.py b/tests/formats_test/disklabel_test.py +index 4b6608f5..3edbdb0b 100644 +--- a/tests/formats_test/disklabel_test.py ++++ b/tests/formats_test/disklabel_test.py +@@ -71,6 +71,7 @@ def test_platform_label_types(self, arch): + arch.is_s390.return_value = False + arch.is_efi.return_value = False + arch.is_aarch64.return_value = False ++ arch.is_arm.return_value = False + arch.is_pmac.return_value = False + + self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "gpt"]) +@@ -81,8 +82,18 @@ def test_platform_label_types(self, arch): + + arch.is_efi.return_value = True + self.assertEqual(disklabel_class.get_platform_label_types(), ["gpt"]) ++ arch.is_aarch64.return_value = True ++ self.assertEqual(disklabel_class.get_platform_label_types(), ["gpt", "msdos"]) ++ arch.is_aarch64.return_value = False ++ arch.is_arm.return_value = True ++ self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "gpt"]) ++ arch.is_arm.return_value = False + arch.is_efi.return_value = False + ++ arch.is_arm.return_value = True ++ self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "gpt"]) ++ arch.is_arm.return_value = False ++ + arch.is_s390.return_value = True + self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "dasd"]) + arch.is_s390.return_value = False +@@ -123,6 +134,7 @@ def test_best_label_type(self, arch): + arch.is_s390.return_value = False + arch.is_efi.return_value = False + arch.is_aarch64.return_value = False ++ arch.is_arm.return_value = False + arch.is_pmac.return_value = False + + with mock.patch.object(dl, '_label_type_size_check') as size_check: + +From e0e6ac41cea805c3bf56852bfe2cd67d4bfe0b83 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Thu, 23 Aug 2018 15:54:51 +0100 +Subject: [PATCH 6/6] Drop omap partition table tests on ARM platforms + +We no longer need to test the /boot/uboot tests for omap platforms so +drop them as they're obsolete. + +Signed-off-by: Peter Robinson +--- + tests/devices_test/partition_test.py | 14 ++------------ + 1 file changed, 2 insertions(+), 12 deletions(-) + +diff --git a/tests/devices_test/partition_test.py b/tests/devices_test/partition_test.py +index 394ffc27..08c0447d 100644 +--- a/tests/devices_test/partition_test.py ++++ b/tests/devices_test/partition_test.py +@@ -26,11 +26,9 @@ + Weighted(fstype="efi", mountpoint="/boot/efi", true_funcs=['is_efi'], weight=5000), + Weighted(fstype="prepboot", mountpoint=None, true_funcs=['is_ppc', 'is_ipseries'], weight=5000), + Weighted(fstype="appleboot", mountpoint=None, true_funcs=['is_ppc', 'is_pmac'], weight=5000), +- Weighted(fstype="vfat", mountpoint="/boot/uboot", true_funcs=['is_arm', 'is_omap_arm'], weight=5000), +- Weighted(fstype=None, mountpoint="/", true_funcs=['is_arm'], weight=-100), +- Weighted(fstype=None, mountpoint="/", true_funcs=['is_arm', 'is_omap_arm'], weight=-100)] ++ Weighted(fstype=None, mountpoint="/", true_funcs=['is_arm'], weight=-100)] + +-arch_funcs = ['is_arm', 'is_efi', 'is_ipseries', 'is_omap_arm', 'is_pmac', 'is_ppc', 'is_x86'] ++arch_funcs = ['is_arm', 'is_efi', 'is_ipseries', 'is_pmac', 'is_ppc', 'is_x86'] + + + class PartitionDeviceTestCase(unittest.TestCase): +@@ -309,14 +307,6 @@ def test_weight_1(self, *patches): + fmt.mountpoint = "/" + self.assertEqual(dev.weight, -100) + +- arch.is_omap_arm.return_value = False +- fmt.mountpoint = "/boot/uboot" +- fmt.type = "vfat" +- self.assertEqual(dev.weight, 0) +- +- arch.is_omap_arm.return_value = True +- self.assertEqual(dev.weight, 5000) +- + # + # ppc + # diff --git a/SOURCES/0007-Wipe-all-stale-metadata-after-creating-md-array.patch b/SOURCES/0007-Wipe-all-stale-metadata-after-creating-md-array.patch index 14b46ff..429d9b9 100644 --- a/SOURCES/0007-Wipe-all-stale-metadata-after-creating-md-array.patch +++ b/SOURCES/0007-Wipe-all-stale-metadata-after-creating-md-array.patch @@ -5,7 +5,8 @@ Subject: [PATCH] Wipe all stale metadata after creating md array. (#1639682) --- blivet/devices/md.py | 4 ++++ - 1 files changed, 4 insertions(+) + tests/devices_test/device_methods_test.py | 3 ++- + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/blivet/devices/md.py b/blivet/devices/md.py index dad099e8..6a837df0 100644 @@ -13,19 +14,32 @@ index dad099e8..6a837df0 100644 +++ b/blivet/devices/md.py @@ -31,6 +31,7 @@ from ..devicelibs import mdraid, raid - + from .. import errors +from ..formats import DeviceFormat from .. import util from ..static_data import pvs_info from ..storage_log import log_method_call @@ -563,6 +564,9 @@ def remove_stale_lvm(): - + remove_stale_lvm() - + + # remove any other stale metadata before proceeding + DeviceFormat(device=self.path, exists=True).destroy() + def _create(self): """ Create the device. """ log_method_call(self, self.name, status=self.status) +diff --git a/tests/devices_test/device_methods_test.py b/tests/devices_test/device_methods_test.py +index 8e40e6b6..12d5f7d8 100644 +--- a/tests/devices_test/device_methods_test.py ++++ b/tests/devices_test/device_methods_test.py +@@ -404,6 +404,7 @@ def test_setup(self): + self.assertTrue(self.patches["md"].activate.called) + + def test_create(self): +- super(MDRaidArrayDeviceMethodsTestCase, self).test_create() ++ with patch("blivet.devices.md.DeviceFormat"): ++ super(MDRaidArrayDeviceMethodsTestCase, self).test_create() + self.device._create() + self.assertTrue(self.patches["md"].create.called) diff --git a/SOURCES/0010-Use-udev-to-determine-if-disk-is-a-multipath-member.patch b/SOURCES/0010-Use-udev-to-determine-if-disk-is-a-multipath-member.patch index 48a6a55..8583654 100644 --- a/SOURCES/0010-Use-udev-to-determine-if-disk-is-a-multipath-member.patch +++ b/SOURCES/0010-Use-udev-to-determine-if-disk-is-a-multipath-member.patch @@ -1,7 +1,7 @@ From 8bdade5e60b746e8d992289e71123ad27146a7f1 Mon Sep 17 00:00:00 2001 From: David Lehman Date: Wed, 24 Oct 2018 20:08:48 -0400 -Subject: [PATCH 2/2] Use udev to determine if disk is a multipath member. +Subject: [PATCH] Use udev to determine if disk is a multipath member. Related: rhbz#1575953 --- @@ -13,7 +13,7 @@ diff --git a/blivet/populator/helpers/disklabel.py b/blivet/populator/helpers/di index c2acb117..db10638e 100644 --- a/blivet/populator/helpers/disklabel.py +++ b/blivet/populator/helpers/disklabel.py -@@ -28,7 +28,6 @@ from ... import udev +@@ -28,7 +28,6 @@ from ...errors import InvalidDiskLabelError from ...storage_log import log_exception_info, log_method_call from .formatpopulator import FormatPopulator @@ -21,7 +21,7 @@ index c2acb117..db10638e 100644 import logging log = logging.getLogger("blivet") -@@ -44,7 +43,7 @@ class DiskLabelFormatPopulator(FormatPopulator): +@@ -44,7 +43,7 @@ def match(cls, data, device): return (bool(udev.device_get_disklabel_type(data)) and not udev.device_is_biosraid_member(data) and udev.device_get_format(data) != "iso9660" and @@ -30,6 +30,35 @@ index c2acb117..db10638e 100644 def _get_kwargs(self): kwargs = super(DiskLabelFormatPopulator, self)._get_kwargs() --- -2.17.2 - +diff --git a/tests/populator_test.py b/tests/populator_test.py +index b6f70319..d9c326d7 100644 +--- a/tests/populator_test.py ++++ b/tests/populator_test.py +@@ -827,7 +827,6 @@ class HFSPopulatorTestCase(FormatPopulatorTestCase): + class DiskLabelPopulatorTestCase(PopulatorHelperTestCase): + helper_class = DiskLabelFormatPopulator + +- @patch("blivet.static_data.mpath_members.is_mpath_member", return_value=False) + @patch("blivet.udev.device_is_biosraid_member", return_value=False) + @patch("blivet.udev.device_get_format", return_value=None) + @patch("blivet.udev.device_get_disklabel_type", return_value="dos") +@@ -836,7 +835,6 @@ def test_match(self, *args): + device_get_disklabel_type = args[0] + device_get_format = args[1] + device_is_biosraid_member = args[2] +- is_mpath_member = args[3] + + device = Mock() + device.is_disk = True +@@ -861,9 +859,9 @@ def test_match(self, *args): + device_is_biosraid_member.return_value = False + + # no match for multipath members +- is_mpath_member.return_value = True ++ device_get_format.return_value = "mpath_member" + self.assertFalse(self.helper_class.match(data, device)) +- is_mpath_member.return_value = False ++ device_get_format.return_value = None + + @patch("blivet.static_data.mpath_members.is_mpath_member", return_value=False) + @patch("blivet.udev.device_is_biosraid_member", return_value=False) diff --git a/SOURCES/0013-Add-flag-for-protecting-cdrom-devices-during-populate.patch b/SOURCES/0013-Add-flag-for-protecting-cdrom-devices-during-populate.patch deleted file mode 100644 index 652eb25..0000000 --- a/SOURCES/0013-Add-flag-for-protecting-cdrom-devices-during-populate.patch +++ /dev/null @@ -1,54 +0,0 @@ -From ac5646f8e9e59389bdc651c63b5e7dcd2d693bf4 Mon Sep 17 00:00:00 2001 -From: Radek Vykydal -Date: Wed, 22 May 2019 13:35:01 +0200 -Subject: [PATCH] Add flag for protecting cdrom devices during populate - -Resolves: rhbz#1719648 ---- - blivet/devices/optical.py | 14 ++++++++++++++ - blivet/flags.py | 3 +++ - 2 files changed, 17 insertions(+) - -diff --git a/blivet/devices/optical.py b/blivet/devices/optical.py -index b9dba1f2..122825f2 100644 ---- a/blivet/devices/optical.py -+++ b/blivet/devices/optical.py -@@ -24,6 +24,7 @@ - from .. import errors - from .. import util - from ..storage_log import log_method_call -+from ..flags import flags - - import logging - log = logging.getLogger("blivet") -@@ -81,3 +82,16 @@ def eject(self): - util.run_program(["eject", self.name]) - except OSError as e: - log.warning("error ejecting cdrom %s: %s", self.name, e) -+ -+ @property -+ def protected(self): -+ protected = super(OpticalDevice, self).protected -+ -+ if flags.protect_cdroms: -+ return True -+ else: -+ return protected -+ -+ @protected.setter -+ def protected(self, value): -+ self._protected = value -diff --git a/blivet/flags.py b/blivet/flags.py -index 6500be30..a6a78edc 100644 ---- a/blivet/flags.py -+++ b/blivet/flags.py -@@ -77,6 +77,9 @@ def __init__(self): - # (so far only for LUKS) - self.discard_new = False - -+ # whether cdroms should be protected -+ self.protect_cdroms = False -+ - self.boot_cmdline = {} - - self.update_from_boot_cmdline() diff --git a/SOURCES/0013-Various-test-fixes.patch b/SOURCES/0013-Various-test-fixes.patch new file mode 100644 index 0000000..0ed48bf --- /dev/null +++ b/SOURCES/0013-Various-test-fixes.patch @@ -0,0 +1,122 @@ +From c495f74951caa0104636032e00704a83ab5f73b1 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 26 Mar 2019 12:58:53 +0100 +Subject: [PATCH 1/3] Properly clean after availability test case + +We need to set availability of the 'mkfs.hfsplus' utility back to +it's real value after changing it to "always available" for this +test case. +--- + tests/devices_test/dependencies_test.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py +index 9dbdd24d..76bf758b 100644 +--- a/tests/devices_test/dependencies_test.py ++++ b/tests/devices_test/dependencies_test.py +@@ -69,6 +69,7 @@ class MockingDeviceDependenciesTestCase1(unittest.TestCase): + + self.mdraid_method = availability.BLOCKDEV_MDRAID_PLUGIN._method + self.dm_method = availability.BLOCKDEV_DM_PLUGIN._method ++ self.hfsplus_method = availability.MKFS_HFSPLUS_APP._method + self.cache_availability = availability.CACHE_AVAILABILITY + + self.addCleanup(self._clean_up) +@@ -105,10 +106,12 @@ class MockingDeviceDependenciesTestCase1(unittest.TestCase): + def _clean_up(self): + availability.BLOCKDEV_MDRAID_PLUGIN._method = self.mdraid_method + availability.BLOCKDEV_DM_PLUGIN._method = self.dm_method ++ availability.MKFS_HFSPLUS_APP._method = self.hfsplus_method + + availability.CACHE_AVAILABILITY = False + availability.BLOCKDEV_MDRAID_PLUGIN.available # pylint: disable=pointless-statement + availability.BLOCKDEV_DM_PLUGIN.available # pylint: disable=pointless-statement ++ availability.MKFS_HFSPLUS_APP.available # pylint: disable=pointless-statement + + availability.CACHE_AVAILABILITY = self.cache_availability + +-- +2.20.1 + + +From a6798882f5ba5b1e0ea655255d6f1fd5eda85f64 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 26 Mar 2019 13:00:40 +0100 +Subject: [PATCH 2/3] Skip weak dependencies test if we don't have all + libblockdev plugins + +This test checks that creating devices works when we have all +plugins and fails "nicely" if we don't have all plugins so we +actually need all the plugins for this test case. +--- + tests/devices_test/dependencies_test.py | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py +index 76bf758b..308d6192 100644 +--- a/tests/devices_test/dependencies_test.py ++++ b/tests/devices_test/dependencies_test.py +@@ -157,6 +157,11 @@ class MissingWeakDependenciesTestCase(unittest.TestCase): + self.disk1_file = create_sparse_tempfile("disk1", Size("2GiB")) + self.plugins = blockdev.plugin_specs_from_names(blockdev.get_available_plugin_names()) + ++ loaded_plugins = self.load_all_plugins() ++ if not all(p in loaded_plugins for p in ("btrfs", "crypto", "lvm", "md")): ++ # we don't have all plugins needed for this test case ++ self.skipTest("Missing libblockdev plugins needed from weak dependencies test.") ++ + def _clean_up(self): + # reload all libblockdev plugins + self.load_all_plugins() +-- +2.20.1 + + +From 151fce2c9a98dc5a7943b314828518518a755ec8 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 26 Mar 2019 13:36:31 +0100 +Subject: [PATCH 3/3] Check for format tools availability in action_test + +--- + tests/action_test.py | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/tests/action_test.py b/tests/action_test.py +index 93ed9e57..101d5a21 100644 +--- a/tests/action_test.py ++++ b/tests/action_test.py +@@ -19,6 +19,13 @@ from blivet.devices import MDRaidArrayDevice + from blivet.devices import LVMVolumeGroupDevice + from blivet.devices import LVMLogicalVolumeDevice + ++# format classes ++from blivet.formats.fs import Ext2FS ++from blivet.formats.fs import Ext3FS ++from blivet.formats.fs import Ext4FS ++from blivet.formats.fs import FATFS ++from blivet.formats.fs import XFS ++ + # action classes + from blivet.deviceaction import ActionCreateDevice + from blivet.deviceaction import ActionResizeDevice +@@ -39,8 +46,17 @@ DEVICE_CLASSES = [ + LVMLogicalVolumeDevice + ] + ++FORMAT_CLASSES = [ ++ Ext2FS, ++ Ext3FS, ++ Ext4FS, ++ FATFS, ++ XFS ++] ++ + + @unittest.skipUnless(not any(x.unavailable_type_dependencies() for x in DEVICE_CLASSES), "some unsupported device classes required for this test") ++@unittest.skipUnless(not any(x().utils_available for x in FORMAT_CLASSES), "some unsupported format classes required for this test") + class DeviceActionTestCase(StorageTestCase): + + """ DeviceActionTestSuite """ +-- +2.20.1 + diff --git a/SOURCES/0014-Tests-archive.patch b/SOURCES/0014-Tests-archive.patch new file mode 100644 index 0000000..30cef18 --- /dev/null +++ b/SOURCES/0014-Tests-archive.patch @@ -0,0 +1,110 @@ +From 545c41e6750d5e28743a7da9e43175302c4fa812 Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Thu, 4 Apr 2019 13:52:54 -0400 +Subject: [PATCH 1/4] Remove profanity from an old comment. + +--- + blivet/blivet.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/blivet/blivet.py b/blivet/blivet.py +index 8128347f..ff4410ae 100644 +--- a/blivet/blivet.py ++++ b/blivet/blivet.py +@@ -875,7 +875,7 @@ def safe_device_name(self, name): + + LVM limits lv names to 128 characters. I don't know the limits for + the other various device types, so I'm going to pick a number so +- that we don't have to have an entire fucking library to determine ++ that we don't have to have an entire library to determine + device name limits. + """ + max_len = 96 # No, you don't need longer names than this. Really. + +From 7395fb481b7b7a5054a3ba12e07f40ba1c8d926a Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Mon, 22 Apr 2019 17:44:42 -0400 +Subject: [PATCH 2/4] Add a target to create an archive of the unit tests. + +--- + Makefile | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/Makefile b/Makefile +index 76817278..f9b2066e 100644 +--- a/Makefile ++++ b/Makefile +@@ -120,6 +120,10 @@ archive: po-pull + git checkout -- po/$(PKGNAME).pot + @echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz" + ++tests-archive: ++ git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(VERSION_TAG) tests/ | gzip -9 > $(PKGNAME)-$(VERSION)-tests.tar.gz ++ @echo "The test archive is in $(PKGNAME)-$(VERSION)-tests.tar.gz" ++ + local: po-pull + @make -B ChangeLog + $(PYTHON) setup.py -q sdist --dist-dir . + +From 28959739b46d22698c05f34494d2d9c67f37f0c4 Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Mon, 22 Apr 2019 17:45:19 -0400 +Subject: [PATCH 3/4] Add spec file logic to include unit tests in SRPM. + +--- + python-blivet.spec | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/python-blivet.spec b/python-blivet.spec +index 668e0913..23fa07f6 100644 +--- a/python-blivet.spec ++++ b/python-blivet.spec +@@ -29,6 +29,7 @@ License: LGPLv2+ + %global realname blivet + %global realversion %{version}%{?prerelease} + Source0: http://github.com/storaged-project/blivet/archive/%{realname}-%{realversion}.tar.gz ++Source1: http://github.com/storaged-project/blivet/archive/%{realname}-%{realversion}-tests.tar.gz + + # Versions of required components (done so we make sure the buildrequires + # match the requires versions of things). +@@ -165,7 +166,8 @@ configuration. + %endif + + %prep +-%autosetup -n %{realname}-%{realversion} -p1 ++%autosetup -n %{realname}-%{realversion} -N ++%autosetup -n %{realname}-%{realversion} -b1 -p1 + + %build + %{?with_python2:make PYTHON=%{__python2}} + +From 305c9b52ee5682baf53be660c501b7b263029699 Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Fri, 26 Apr 2019 16:39:35 -0400 +Subject: [PATCH 4/4] Include tests archive where appropriate in make targets. + +--- + Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Makefile b/Makefile +index f9b2066e..552550a6 100644 +--- a/Makefile ++++ b/Makefile +@@ -119,6 +119,7 @@ archive: po-pull + rm -rf $(PKGNAME)-$(VERSION) + git checkout -- po/$(PKGNAME).pot + @echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz" ++ @make tests-archive + + tests-archive: + git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(VERSION_TAG) tests/ | gzip -9 > $(PKGNAME)-$(VERSION)-tests.tar.gz +@@ -128,6 +129,8 @@ local: po-pull + @make -B ChangeLog + $(PYTHON) setup.py -q sdist --dist-dir . + @echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz" ++ git ls-files tests/ | tar -T- -czf $(PKGNAME)-$(VERSION)-tests.tar.gz ++ @echo "The test archive is in $(PKGNAME)-$(VERSION)-tests.tar.gz" + + rpmlog: + @git log --pretty="format:- %s (%ae)" $(RELEASE_TAG).. |sed -e 's/@.*)/)/' diff --git a/SOURCES/0015-Deactivate-incomplete-VGs.patch b/SOURCES/0015-Deactivate-incomplete-VGs.patch new file mode 100644 index 0000000..d843143 --- /dev/null +++ b/SOURCES/0015-Deactivate-incomplete-VGs.patch @@ -0,0 +1,47 @@ +From 6528bb0149720b336c9da7b57eaea048d693871c Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Wed, 20 Jun 2018 16:37:24 -0400 +Subject: [PATCH] Deactivate incomplete VGs along with everything else. + +(cherry picked from commit 39637796ca1aa2f03c89b5ec86ac246eecca1570) +--- + blivet/devices/lvm.py | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py +index 0cb1a2ac..1e9da2a8 100644 +--- a/blivet/devices/lvm.py ++++ b/blivet/devices/lvm.py +@@ -216,15 +216,25 @@ class LVMVolumeGroupDevice(ContainerDevice): + if lv.status: + return True + ++ # special handling for incomplete VGs ++ if not self.complete: ++ try: ++ lvs_info = blockdev.lvm.lvs(vg_name=self.name) ++ except blockdev.LVMError: ++ lvs_info = dict() ++ ++ for lv_info in lvs_info.values(): ++ lv_attr = udev.device_get_lv_attr(lv_info) ++ if lv_attr and lv_attr[4] == 'a': ++ return True ++ ++ return False ++ + # if any of our PVs are not active then we cannot be + for pv in self.pvs: + if not pv.status: + return False + +- # if we are missing some of our PVs we cannot be active +- if not self.complete: +- return False +- + return True + + def _pre_setup(self, orig=False): +-- +2.20.1 + diff --git a/SOURCES/0016-Automatically-adjust-size-of-growable-devices-for-new-format.patch b/SOURCES/0016-Automatically-adjust-size-of-growable-devices-for-new-format.patch new file mode 100644 index 0000000..342367a --- /dev/null +++ b/SOURCES/0016-Automatically-adjust-size-of-growable-devices-for-new-format.patch @@ -0,0 +1,31 @@ +From caec289d8220fc9a8d8b3d6e99271394f4ef83fe Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 27 Feb 2019 12:26:30 +0100 +Subject: [PATCH] Automatically adjust size of growable devices for new format + +Without this kickstart 'part /home --size=1 --grow --encrypted' +will fail because min size for LUKS is 2 MiB. + +Resolves: rhbz#1680013 +--- + blivet/devices/storage.py | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py +index 904b60df..9d6001e8 100644 +--- a/blivet/devices/storage.py ++++ b/blivet/devices/storage.py +@@ -721,7 +721,12 @@ def _set_format(self, fmt): + if fmt.max_size and fmt.max_size < self.size: + raise errors.DeviceError("device is too large for new format") + elif fmt.min_size and fmt.min_size > self.size: +- raise errors.DeviceError("device is too small for new format") ++ if self.growable: ++ log.info("%s: using size %s instead of %s to accommodate " ++ "format minimum size", self.name, fmt.min_size, self.size) ++ self.size = fmt.min_size ++ else: ++ raise errors.DeviceError("device is too small for new format") + + if self._format != fmt: + callbacks.format_removed(device=self, fmt=self._format) diff --git a/SOURCES/0017-Add-flag-for-protecting-cdrom-devices-during-populate.patch b/SOURCES/0017-Add-flag-for-protecting-cdrom-devices-during-populate.patch new file mode 100644 index 0000000..652eb25 --- /dev/null +++ b/SOURCES/0017-Add-flag-for-protecting-cdrom-devices-during-populate.patch @@ -0,0 +1,54 @@ +From ac5646f8e9e59389bdc651c63b5e7dcd2d693bf4 Mon Sep 17 00:00:00 2001 +From: Radek Vykydal +Date: Wed, 22 May 2019 13:35:01 +0200 +Subject: [PATCH] Add flag for protecting cdrom devices during populate + +Resolves: rhbz#1719648 +--- + blivet/devices/optical.py | 14 ++++++++++++++ + blivet/flags.py | 3 +++ + 2 files changed, 17 insertions(+) + +diff --git a/blivet/devices/optical.py b/blivet/devices/optical.py +index b9dba1f2..122825f2 100644 +--- a/blivet/devices/optical.py ++++ b/blivet/devices/optical.py +@@ -24,6 +24,7 @@ + from .. import errors + from .. import util + from ..storage_log import log_method_call ++from ..flags import flags + + import logging + log = logging.getLogger("blivet") +@@ -81,3 +82,16 @@ def eject(self): + util.run_program(["eject", self.name]) + except OSError as e: + log.warning("error ejecting cdrom %s: %s", self.name, e) ++ ++ @property ++ def protected(self): ++ protected = super(OpticalDevice, self).protected ++ ++ if flags.protect_cdroms: ++ return True ++ else: ++ return protected ++ ++ @protected.setter ++ def protected(self, value): ++ self._protected = value +diff --git a/blivet/flags.py b/blivet/flags.py +index 6500be30..a6a78edc 100644 +--- a/blivet/flags.py ++++ b/blivet/flags.py +@@ -77,6 +77,9 @@ def __init__(self): + # (so far only for LUKS) + self.discard_new = False + ++ # whether cdroms should be protected ++ self.protect_cdroms = False ++ + self.boot_cmdline = {} + + self.update_from_boot_cmdline() diff --git a/SOURCES/0018-Clean-up-some-errors-evident-in-installer-logs.patch b/SOURCES/0018-Clean-up-some-errors-evident-in-installer-logs.patch new file mode 100644 index 0000000..10c62dd --- /dev/null +++ b/SOURCES/0018-Clean-up-some-errors-evident-in-installer-logs.patch @@ -0,0 +1,81 @@ +From 8124b804915d54e341e80bdd84e84eec3a54aaba Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Tue, 27 Nov 2018 13:37:49 -0500 +Subject: [PATCH 1/2] Only update sysfs path in ctor for active devices. + +Related: rhbz#1579375 +--- + blivet/devices/storage.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py +index 3cc29436..904b60df 100644 +--- a/blivet/devices/storage.py ++++ b/blivet/devices/storage.py +@@ -149,8 +149,8 @@ def __init__(self, name, fmt=None, uuid=None, + self.device_links = [] + + if self.exists: +- self.update_sysfs_path() + if self.status: ++ self.update_sysfs_path() + self.update_size() + + def __str__(self): + +From 4cc31c735db820896278a7b91bb761df00becdb5 Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Tue, 27 Nov 2018 14:03:40 -0500 +Subject: [PATCH 2/2] Fix xfs sync of chrooted mountpoint. + +Related: rhbz#1579375 +--- + blivet/tasks/fssync.py | 22 ++++++++++++++++------ + 1 file changed, 16 insertions(+), 6 deletions(-) + +diff --git a/blivet/tasks/fssync.py b/blivet/tasks/fssync.py +index a15c8e1b..996fe782 100644 +--- a/blivet/tasks/fssync.py ++++ b/blivet/tasks/fssync.py +@@ -49,11 +49,21 @@ class XFSSync(FSSync): + + ext = availability.XFSFREEZE_APP + +- def _freeze_command(self): +- return [str(self.ext), "-f", self.fs.system_mountpoint] ++ def _get_mountpoint(self, root=None): ++ mountpoint = self.fs.system_mountpoint ++ if root is not None and root.replace('/', ''): ++ if mountpoint == root: ++ mountpoint = '/' ++ else: ++ mountpoint = mountpoint[len(root):] + +- def _unfreeze_command(self): +- return [str(self.ext), "-u", self.fs.system_mountpoint] ++ return mountpoint ++ ++ def _freeze_command(self, root=None): ++ return [str(self.ext), "-f", self._get_mountpoint(root=root)] ++ ++ def _unfreeze_command(self, root=None): ++ return [str(self.ext), "-u", self._get_mountpoint(root=root)] + + def do_task(self, root="/"): + # pylint: disable=arguments-differ +@@ -63,13 +73,13 @@ def do_task(self, root="/"): + + error_msg = None + try: +- rc = util.run_program(self._freeze_command(), root=root) ++ rc = util.run_program(self._freeze_command(root=root), root=root) + except OSError as e: + error_msg = "failed to sync filesytem: %s" % e + error_msg = error_msg or rc + + try: +- rc = util.run_program(self._unfreeze_command(), root=root) ++ rc = util.run_program(self._unfreeze_command(root=root), root=root) + except OSError as e: + error_msg = error_msg or "failed to sync filesystem: %s" % e + error_msg = error_msg or rc diff --git a/SOURCES/0019-Use-dasd-disklabel-for-vm-disks-backed-by-dasds.patch b/SOURCES/0019-Use-dasd-disklabel-for-vm-disks-backed-by-dasds.patch new file mode 100644 index 0000000..58bea0b --- /dev/null +++ b/SOURCES/0019-Use-dasd-disklabel-for-vm-disks-backed-by-dasds.patch @@ -0,0 +1,128 @@ +From 1d9dc59ab2c471d7dcc39cd6982bd14380d5f726 Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Thu, 13 Jun 2019 11:22:16 -0400 +Subject: [PATCH 1/3] Add a function to detect if running in a vm. + +Related: rhbz#1676935 +--- + blivet/util.py | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/blivet/util.py b/blivet/util.py +index 542bc93f..fa5e9e35 100644 +--- a/blivet/util.py ++++ b/blivet/util.py +@@ -1,4 +1,5 @@ + import copy ++from distutils.spawn import find_executable + import functools + import glob + import itertools +@@ -1100,3 +1101,16 @@ def decorated(*args, **kwargs): + return None + return decorated + return decorator ++ ++ ++def detect_virt(): ++ """ Return True if we are running in a virtual machine. """ ++ in_vm = False ++ detect_virt_prog = find_executable('systemd-detect-virt') ++ if detect_virt_prog: ++ try: ++ in_vm = run_program([detect_virt_prog, "--vm"]) == 0 ++ except OSError: ++ pass ++ ++ return in_vm + +From 26d4b48ab5eca44695dced52c6170ec04610bc1d Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Thu, 13 Jun 2019 10:57:48 -0400 +Subject: [PATCH 2/3] Use dasd disklabel for vm disks backed by dasds. + +Resolves: rhbz#1676935 +--- + blivet/formats/disklabel.py | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py +index 8186d1a1..0c4fce35 100644 +--- a/blivet/formats/disklabel.py ++++ b/blivet/formats/disklabel.py +@@ -261,6 +261,15 @@ def _get_best_label_type(self): + elif self.parted_device.type == parted.DEVICE_DASD: + # the device is DASD + return "dasd" ++ elif util.detect_virt(): ++ # check for dasds exported into qemu as normal virtio/scsi disks ++ try: ++ _parted_disk = parted.Disk(device=self.parted_device) ++ except (_ped.DiskLabelException, _ped.IOException, NotImplementedError): ++ pass ++ else: ++ if _parted_disk.type == "dasd": ++ return "dasd" + + for lt in label_types: + if self._label_type_size_check(lt): + +From c93d1207bb2942736a390bd58adafda3deb1c25c Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Thu, 13 Jun 2019 12:04:23 -0400 +Subject: [PATCH 3/3] Use DBus call to see if we're in a vm. + +--- + blivet/util.py | 22 +++++++++++++--------- + 1 file changed, 13 insertions(+), 9 deletions(-) + +diff --git a/blivet/util.py b/blivet/util.py +index fa5e9e35..2932e8b5 100644 +--- a/blivet/util.py ++++ b/blivet/util.py +@@ -1,5 +1,4 @@ + import copy +-from distutils.spawn import find_executable + import functools + import glob + import itertools +@@ -20,6 +19,7 @@ + from enum import Enum + + from .errors import DependencyError ++from . import safe_dbus + + import gi + gi.require_version("BlockDev", "2.0") +@@ -39,6 +39,12 @@ + program_log_lock = Lock() + + ++SYSTEMD_SERVICE = "org.freedesktop.systemd1" ++SYSTEMD_MANAGER_PATH = "/org/freedesktop/systemd1/Manager" ++SYSTEMD_MANAGER_IFACE = "org.freedesktop.systemd1.Manager" ++VIRT_PROP_NAME = "Virtualization" ++ ++ + class Path(str): + + """ Path(path, root=None) provides a filesystem path object, which +@@ -1105,12 +1111,10 @@ def decorated(*args, **kwargs): + + def detect_virt(): + """ Return True if we are running in a virtual machine. """ +- in_vm = False +- detect_virt_prog = find_executable('systemd-detect-virt') +- if detect_virt_prog: +- try: +- in_vm = run_program([detect_virt_prog, "--vm"]) == 0 +- except OSError: +- pass ++ try: ++ vm = safe_dbus.get_property_sync(SYSTEMD_SERVICE, SYSTEMD_MANAGER_PATH, ++ SYSTEMD_MANAGER_IFACE, VIRT_PROP_NAME) ++ except (safe_dbus.DBusCallError, safe_dbus.DBusPropertyError): ++ vm = None + +- return in_vm ++ return vm in ('qemu', 'kvm') diff --git a/SOURCES/0020-Fix-reading-LV-attributes-in-LVMVolumeGroupDevice.patch b/SOURCES/0020-Fix-reading-LV-attributes-in-LVMVolumeGroupDevice.patch new file mode 100644 index 0000000..19a2248 --- /dev/null +++ b/SOURCES/0020-Fix-reading-LV-attributes-in-LVMVolumeGroupDevice.patch @@ -0,0 +1,30 @@ +From 5097a0f3fba2960fc77cfd6ceb828287f60c930c Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 6 Dec 2018 10:32:58 +0100 +Subject: [PATCH] Fix reading LV attributes in LVMVolumeGroupDevice.status + +This was not adjusted to libblockdev API when cherry-picking fixes +from rhel7-branch in 3c8f8dbf78b0a093e120f69241b44a48ff07be30 +--- + blivet/devices/lvm.py | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py +index 7835b7e8..8c4ee2ba 100644 +--- a/blivet/devices/lvm.py ++++ b/blivet/devices/lvm.py +@@ -222,11 +222,10 @@ def status(self): + try: + lvs_info = blockdev.lvm.lvs(vg_name=self.name) + except blockdev.LVMError: +- lvs_info = dict() ++ lvs_info = [] + +- for lv_info in lvs_info.values(): +- lv_attr = udev.device_get_lv_attr(lv_info) +- if lv_attr and lv_attr[4] == 'a': ++ for lv_info in lvs_info: ++ if lv_info.attr and lv_info.attr[4] == 'a': + return True + + return False diff --git a/SOURCES/0021-Correctly-handle-non-unicode-iSCSI-initiator-names.patch b/SOURCES/0021-Correctly-handle-non-unicode-iSCSI-initiator-names.patch new file mode 100644 index 0000000..9abdbd5 --- /dev/null +++ b/SOURCES/0021-Correctly-handle-non-unicode-iSCSI-initiator-names.patch @@ -0,0 +1,65 @@ +From 5f7dbb212b4d6da4f8f2609ae1415e8630d031cd Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 13 May 2019 12:49:52 +0200 +Subject: [PATCH] Correctly handle non-unicode iSCSI initiator names + +--- + blivet/iscsi.py | 4 +++- + blivet/udev.py | 20 +++++++++++--------- + 2 files changed, 14 insertions(+), 10 deletions(-) + +diff --git a/blivet/iscsi.py b/blivet/iscsi.py +index 74432505..f612cf15 100644 +--- a/blivet/iscsi.py ++++ b/blivet/iscsi.py +@@ -206,7 +206,9 @@ def initiator(self): + if self._initiator != "": + return self._initiator + +- return self._call_initiator_method("GetInitiatorName")[0] ++ # udisks returns initiatorname as a NULL terminated bytearray ++ raw_initiator = bytes(self._call_initiator_method("GetInitiatorNameRaw")[0][:-1]) ++ return raw_initiator.decode("utf-8", errors="replace") + + @initiator.setter + @storaged_iscsi_required(critical=True, eval_mode=util.EvalMode.onetime) +diff --git a/blivet/udev.py b/blivet/udev.py +index 51b69b76..a70e3e08 100644 +--- a/blivet/udev.py ++++ b/blivet/udev.py +@@ -836,24 +836,26 @@ def device_get_iscsi_nic(info): + + + def device_get_iscsi_initiator(info): +- initiator = None ++ initiator_name = None + if device_is_partoff_iscsi(info): + host = re.match(r'.*/(host\d+)', device_get_sysfs_path(info)).groups()[0] + if host: + initiator_file = "/sys/class/iscsi_host/%s/initiatorname" % host + if os.access(initiator_file, os.R_OK): +- initiator = open(initiator_file).read().strip() ++ initiator = open(initiator_file, "rb").read().strip() ++ initiator_name = initiator.decode("utf-8", errors="replace") + log.debug("found offload iscsi initiatorname %s in file %s", +- initiator, initiator_file) +- if initiator.lstrip("(").rstrip(")").lower() == "null": +- initiator = None +- if initiator is None: ++ initiator_name, initiator_file) ++ if initiator_name.lstrip("(").rstrip(")").lower() == "null": ++ initiator_name = None ++ if initiator_name is None: + session = device_get_iscsi_session(info) + if session: + initiator = open("/sys/class/iscsi_session/%s/initiatorname" % +- session).read().strip() +- log.debug("found iscsi initiatorname %s", initiator) +- return initiator ++ session, "rb").read().strip() ++ initiator_name = initiator.decode("utf-8", errors="replace") ++ log.debug("found iscsi initiatorname %s", initiator_name) ++ return initiator_name + + + # fcoe disks have ID_PATH in the form of: diff --git a/SOURCES/0022-Do-not-crash-if-dm_get_member_raid_sets-fails.patch b/SOURCES/0022-Do-not-crash-if-dm_get_member_raid_sets-fails.patch new file mode 100644 index 0000000..e1135bd --- /dev/null +++ b/SOURCES/0022-Do-not-crash-if-dm_get_member_raid_sets-fails.patch @@ -0,0 +1,27 @@ +From 408da7ad8eaedf9edb8dfa240af35a222fa8b481 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 11 Mar 2019 13:29:04 +0100 +Subject: [PATCH] Do not crash if 'dm.get_member_raid_sets' fails (#1684851) + +--- + blivet/populator/helpers/dmraid.py | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/blivet/populator/helpers/dmraid.py b/blivet/populator/helpers/dmraid.py +index c8cc3a8e..ed48bd66 100644 +--- a/blivet/populator/helpers/dmraid.py ++++ b/blivet/populator/helpers/dmraid.py +@@ -53,7 +53,12 @@ def run(self): + minor = udev.device_get_minor(self.data) + + # Have we already created the DMRaidArrayDevice? +- rs_names = blockdev.dm.get_member_raid_sets(name, uuid, major, minor) ++ try: ++ rs_names = blockdev.dm.get_member_raid_sets(name, uuid, major, minor) ++ except blockdev.DMError as e: ++ log.error("Failed to get RAID sets information for '%s': %s", name, str(e)) ++ return ++ + if len(rs_names) == 0: + log.warning("dmraid member %s does not appear to belong to any " + "array", self.device.name) diff --git a/SOURCES/0023-Minor-cleanups-to-reduce-log-noise.patch b/SOURCES/0023-Minor-cleanups-to-reduce-log-noise.patch new file mode 100644 index 0000000..3d14628 --- /dev/null +++ b/SOURCES/0023-Minor-cleanups-to-reduce-log-noise.patch @@ -0,0 +1,166 @@ +From c667dbb3ebf05eafeb4fb55d3ffa22d27c25420c Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Wed, 24 Oct 2018 20:12:20 -0400 +Subject: [PATCH 1/3] Don't try to update sysfs path for non-block devices. + (#1579375) + +--- + blivet/devices/file.py | 3 +++ + blivet/devices/nfs.py | 3 +++ + blivet/devices/nodev.py | 3 +++ + 3 files changed, 9 insertions(+) + +diff --git a/blivet/devices/file.py b/blivet/devices/file.py +index 55522c1d..fa3dfb8a 100644 +--- a/blivet/devices/file.py ++++ b/blivet/devices/file.py +@@ -132,6 +132,9 @@ def is_name_valid(self, name): + # Override StorageDevice.is_name_valid to allow / + return not('\x00' in name or name == '.' or name == '..') + ++ def update_sysfs_path(self): ++ pass ++ + + class SparseFileDevice(FileDevice): + +diff --git a/blivet/devices/nfs.py b/blivet/devices/nfs.py +index 97cbe01e..a0142f91 100644 +--- a/blivet/devices/nfs.py ++++ b/blivet/devices/nfs.py +@@ -77,3 +77,6 @@ def update_size(self, newsize=None): + def is_name_valid(self, name): + # Override StorageDevice.is_name_valid to allow / + return not('\x00' in name or name == '.' or name == '..') ++ ++ def update_sysfs_path(self): ++ pass +diff --git a/blivet/devices/nodev.py b/blivet/devices/nodev.py +index f6129258..f1b87392 100644 +--- a/blivet/devices/nodev.py ++++ b/blivet/devices/nodev.py +@@ -75,6 +75,9 @@ def destroy(self): + def update_size(self, newsize=None): + pass + ++ def update_sysfs_path(self): ++ pass ++ + + class TmpFSDevice(NoDevice): + + +From acb0953ad89327b3ffd3571b6d45565762548203 Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Wed, 24 Oct 2018 20:27:22 -0400 +Subject: [PATCH 2/3] Only try to set selinux context for lost+found on ext + file systems. + +Related: rhbz#1579375 +--- + blivet/formats/fs.py | 19 ++++++++++++++----- + tests/formats_test/selinux_test.py | 5 ++++- + 2 files changed, 18 insertions(+), 6 deletions(-) + +diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py +index 81e367f4..b915a2de 100644 +--- a/blivet/formats/fs.py ++++ b/blivet/formats/fs.py +@@ -569,11 +569,6 @@ def _post_setup(self, **kwargs): + ret = util.reset_file_context(mountpoint, chroot) + if not ret: + log.warning("Failed to reset SElinux context for newly mounted filesystem root directory to default.") +- lost_and_found_context = util.match_path_context("/lost+found") +- lost_and_found_path = os.path.join(mountpoint, "lost+found") +- ret = util.set_file_context(lost_and_found_path, lost_and_found_context, chroot) +- if not ret: +- log.warning("Failed to set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context) + + def _pre_teardown(self, **kwargs): + if not super(FS, self)._pre_teardown(**kwargs): +@@ -840,6 +835,20 @@ class Ext2FS(FS): + parted_system = fileSystemType["ext2"] + _metadata_size_factor = 0.93 # ext2 metadata may take 7% of space + ++ def _post_setup(self, **kwargs): ++ super(Ext2FS, self)._post_setup(**kwargs) ++ ++ options = kwargs.get("options", "") ++ chroot = kwargs.get("chroot", "/") ++ mountpoint = kwargs.get("mountpoint") or self.mountpoint ++ ++ if flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon: ++ lost_and_found_context = util.match_path_context("/lost+found") ++ lost_and_found_path = os.path.join(mountpoint, "lost+found") ++ ret = util.set_file_context(lost_and_found_path, lost_and_found_context, chroot) ++ if not ret: ++ log.warning("Failed to set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context) ++ + register_device_format(Ext2FS) + + +diff --git a/tests/formats_test/selinux_test.py b/tests/formats_test/selinux_test.py +index 79c10327..028e084e 100644 +--- a/tests/formats_test/selinux_test.py ++++ b/tests/formats_test/selinux_test.py +@@ -43,7 +43,10 @@ def exec_mount_selinux_format(self, formt, *args): + + blivet.flags.flags.selinux_reset_fcon = True + fmt.setup(mountpoint="dummy") # param needed to pass string check +- lsetfilecon.assert_called_with(ANY, lost_found_context) ++ if isinstance(fmt, fs.Ext2FS): ++ lsetfilecon.assert_called_with(ANY, lost_found_context) ++ else: ++ lsetfilecon.assert_not_called() + + lsetfilecon.reset_mock() + + +From 1b4e658f098bda3161ff0d5ffee07ea9be5c1d15 Mon Sep 17 00:00:00 2001 +From: David Lehman +Date: Wed, 24 Oct 2018 20:33:36 -0400 +Subject: [PATCH 3/3] Don't try to set selinux context for nodev or vfat file + systems. + +Related: rhbz#1579375 +--- + blivet/formats/fs.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py +index b915a2de..6f09eaff 100644 +--- a/blivet/formats/fs.py ++++ b/blivet/formats/fs.py +@@ -76,6 +76,7 @@ class FS(DeviceFormat): + _sync_class = fssync.UnimplementedFSSync + _writelabel_class = fswritelabel.UnimplementedFSWriteLabel + _writeuuid_class = fswriteuuid.UnimplementedFSWriteUUID ++ _selinux_supported = True + # This constant is aquired by testing some filesystems + # and it's giving us percentage of space left after the format. + # This number is more guess than precise number because this +@@ -565,7 +566,7 @@ def _post_setup(self, **kwargs): + chroot = kwargs.get("chroot", "/") + mountpoint = kwargs.get("mountpoint") or self.mountpoint + +- if flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon: ++ if self._selinux_supported and flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon: + ret = util.reset_file_context(mountpoint, chroot) + if not ret: + log.warning("Failed to reset SElinux context for newly mounted filesystem root directory to default.") +@@ -902,6 +903,7 @@ class FATFS(FS): + _metadata_size_factor = 0.99 # fat metadata may take 1% of space + # FIXME this should be fat32 in some cases + parted_system = fileSystemType["fat16"] ++ _selinux_supported = False + + def generate_new_uuid(self): + ret = "" +@@ -1235,6 +1237,7 @@ class NoDevFS(FS): + """ nodev filesystem base class """ + _type = "nodev" + _mount_class = fsmount.NoDevFSMount ++ _selinux_supported = False + + def __init__(self, **kwargs): + FS.__init__(self, **kwargs) diff --git a/SOURCES/0024-Fix-util.detect_virt-function.patch b/SOURCES/0024-Fix-util.detect_virt-function.patch new file mode 100644 index 0000000..961ea1b --- /dev/null +++ b/SOURCES/0024-Fix-util.detect_virt-function.patch @@ -0,0 +1,91 @@ +From 471d43cbfe99db1c8246fb863e3ce49b3403fc61 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 11 Sep 2019 10:48:19 +0200 +Subject: [PATCH] Fix util.detect_virt function + +Fixed the systemd Manager object path, also get_property_sync +returns a tuple so we need to check its first element. + +Resolves: rhbz#1676935 +--- + blivet/util.py | 8 ++++---- + tests/formats_test/disklabel_test.py | 26 ++++++++++++++------------ + tests/util_test.py | 4 ++++ + 3 files changed, 22 insertions(+), 16 deletions(-) + +diff --git a/blivet/util.py b/blivet/util.py +index 2932e8b5..27468992 100644 +--- a/blivet/util.py ++++ b/blivet/util.py +@@ -40,7 +40,7 @@ program_log_lock = Lock() + + + SYSTEMD_SERVICE = "org.freedesktop.systemd1" +-SYSTEMD_MANAGER_PATH = "/org/freedesktop/systemd1/Manager" ++SYSTEMD_MANAGER_PATH = "/org/freedesktop/systemd1" + SYSTEMD_MANAGER_IFACE = "org.freedesktop.systemd1.Manager" + VIRT_PROP_NAME = "Virtualization" + +@@ -1115,6 +1115,6 @@ def detect_virt(): + vm = safe_dbus.get_property_sync(SYSTEMD_SERVICE, SYSTEMD_MANAGER_PATH, + SYSTEMD_MANAGER_IFACE, VIRT_PROP_NAME) + except (safe_dbus.DBusCallError, safe_dbus.DBusPropertyError): +- vm = None +- +- return vm in ('qemu', 'kvm') ++ return False ++ else: ++ return vm[0] in ('qemu', 'kvm') +diff --git a/tests/formats_test/disklabel_test.py b/tests/formats_test/disklabel_test.py +index 4b105da6..94f3775f 100644 +--- a/tests/formats_test/disklabel_test.py ++++ b/tests/formats_test/disklabel_test.py +@@ -163,16 +163,18 @@ class DiskLabelTestCase(unittest.TestCase): + arch.is_efi.return_value = False + + arch.is_s390.return_value = True +- with mock.patch.object(dl, '_label_type_size_check') as size_check: +- size_check.return_value = True +- with mock.patch("blivet.formats.disklabel.blockdev.s390") as _s390: +- _s390.dasd_is_fba.return_value = False +- self.assertEqual(dl._get_best_label_type(), "msdos") +- +- _s390.dasd_is_fba.return_value = True +- self.assertEqual(dl._get_best_label_type(), "msdos") +- +- _s390.dasd_is_fba.return_value = False +- dl._parted_device.type = parted.DEVICE_DASD +- self.assertEqual(dl._get_best_label_type(), "dasd") ++ with mock.patch('blivet.util.detect_virt') as virt: ++ virt.return_value = False ++ with mock.patch.object(dl, '_label_type_size_check') as size_check: ++ size_check.return_value = True ++ with mock.patch("blivet.formats.disklabel.blockdev.s390") as _s390: ++ _s390.dasd_is_fba.return_value = False ++ self.assertEqual(dl._get_best_label_type(), "msdos") ++ ++ _s390.dasd_is_fba.return_value = True ++ self.assertEqual(dl._get_best_label_type(), "msdos") ++ ++ _s390.dasd_is_fba.return_value = False ++ dl._parted_device.type = parted.DEVICE_DASD ++ self.assertEqual(dl._get_best_label_type(), "dasd") + arch.is_s390.return_value = False +diff --git a/tests/util_test.py b/tests/util_test.py +index 5fa3070e..9a2ff492 100644 +--- a/tests/util_test.py ++++ b/tests/util_test.py +@@ -37,6 +37,10 @@ class MiscTest(unittest.TestCase): + # real deduplication + self.assertEqual([1, 2, 3, 4, 5, 6], util.dedup_list([1, 2, 3, 4, 2, 2, 2, 1, 3, 5, 3, 6, 6, 2, 3, 1, 5])) + ++ def test_detect_virt(self): ++ in_virt = not util.run_program(["systemd-detect-virt", "--vm"]) ++ self.assertEqual(util.detect_virt(), in_virt) ++ + + class TestDefaultNamedtuple(unittest.TestCase): + def test_default_namedtuple(self): +-- +2.20.1 + diff --git a/SPECS/python-blivet.spec b/SPECS/python-blivet.spec index 8b3431a..72b8757 100644 --- a/SPECS/python-blivet.spec +++ b/SPECS/python-blivet.spec @@ -23,13 +23,14 @@ Version: 3.1.0 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 12%{?prerelease}%{?dist} +Release: 17%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ Group: System Environment/Libraries %global realname blivet %global realversion %{version}%{?prerelease} Source0: http://github.com/storaged-project/blivet/archive/%{realname}-%{realversion}.tar.gz +Source1: http://github.com/storaged-project/blivet/archive/%{realname}-%{realversion}-tests.tar.gz Patch0: 0001-force-lvm-cli.plugin Patch1: 0002-remove-btrfs-plugin.patch Patch2: 0003-separate-dmraid-availability-check.patch @@ -43,7 +44,18 @@ Patch9: 0009-Require-libfc-instead-of-fcoe-for-offloaded-FCoE.-15.patch Patch10: 0010-Use-udev-to-determine-if-disk-is-a-multipath-member.patch Patch11: 0011-Don-t-crash-if-blockdev-mpath-plugin-isn-t-available.patch Patch12: 0012-Ensure-correct-type-of-mpath-cache-member-list.patch -Patch13: 0013-Add-flag-for-protecting-cdrom-devices-during-populate.patch +Patch13: 0013-Various-test-fixes.patch +Patch14: 0014-Tests-archive.patch +Patch15: 0015-Deactivate-incomplete-VGs.patch +Patch16: 0016-Automatically-adjust-size-of-growable-devices-for-new-format.patch +Patch17: 0017-Add-flag-for-protecting-cdrom-devices-during-populate.patch +Patch18: 0018-Clean-up-some-errors-evident-in-installer-logs.patch +Patch19: 0019-Use-dasd-disklabel-for-vm-disks-backed-by-dasds.patch +Patch20: 0020-Fix-reading-LV-attributes-in-LVMVolumeGroupDevice.patch +Patch21: 0021-Correctly-handle-non-unicode-iSCSI-initiator-names.patch +Patch22: 0022-Do-not-crash-if-dm_get_member_raid_sets-fails.patch +Patch23: 0023-Minor-cleanups-to-reduce-log-noise.patch +Patch24: 0024-Fix-util.detect_virt-function.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -171,7 +183,9 @@ configuration. %endif %prep -%autosetup -n %{realname}-%{realversion} -p1 +%autosetup -n %{realname}-%{realversion} -N +%autosetup -n %{realname}-%{realversion} -b1 -p1 + %build %{?with_python2:make PYTHON=%{__python2}} @@ -204,13 +218,43 @@ configuration. %endif %changelog -* Wed Aug 14 2019 Vojtech Trefny - 3.1.0-12 -- Rebuild with fixed gating - Related: rhbz#1734318 - -* Wed Aug 14 2019 Vojtech Trefny - 3.1.0-11 +* Wed Oct 02 2019 David Lehman - 3.1.0-17 +- Fix util.detect_virt function + Resolves: rhbz#1676935 + +* Mon Aug 05 2019 Vojtech Trefny - 3.1.0-16 +- Minor cleanups to reduce log noise + Related: rhbz#1579375 + +* Mon Jul 15 2019 Vojtech Trefny - 3.1.0-15 +- Do not crash if 'dm.get_member_raid_sets' fails + Resolves: rhbz#1704289 + +* Tue Jul 02 2019 Vojtech Trefny - 3.1.0-14 +- Correctly handle non-unicode iSCSI initiator names + Resolves: rhbz#1632117 + +* Tue Jun 18 2019 Vojtech Trefny - 3.1.0-13 +- Fix reading LV attributes in LVMVolumeGroupDevice.status + Resolves: rhbz#1721381 + +* Fri Jun 14 2019 Vojtech Trefny - 3.1.0-12 +- Deactivate incomplete VGs along with everything else + Resolves: rhbz#1635125 +- Automatically adjust size of growable devices for new format + Resolves: rhbz#1680013 - Add flag for protecting cdrom devices during populate - Resolves: rhbz#1734318 + Resolves: rhbz#1719648 +- Clean up some errors evident in installer logs + Resolves: rhbz#1579375 +- Use dasd disklabel for vm disks backed by dasds + Resolves: rhbz#1676935 + +* Thu May 16 2019 Vojtech Trefny - 3.1.0-11 +- Various test fixes for RHEL 8 + Related: rhbz#1682561 +- Add upstream test suite to the SRPM + Related: rhbz#1682561 * Wed Apr 03 2019 David Lehman - 3.1.0-10 - Ensure correct type of mpath cache member list.