From 39382d82c35494d0b359b32a48de723d9f3a0908 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Mon, 21 Nov 2022 11:04:40 +0100 Subject: [PATCH 1/2] Add a basic read-only support for UDF filesystem Resolves: RHEL-13329 --- blivet/formats/fs.py | 12 ++++++++++++ blivet/populator/helpers/disklabel.py | 2 +- blivet/populator/helpers/partition.py | 2 +- blivet/tasks/fsmount.py | 4 ++++ tests/storage_tests/formats_test/fs_test.py | 4 ++++ tests/unit_tests/populator_test.py | 5 +++++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py index 3f553eb0..5b60bd6f 100644 --- a/blivet/formats/fs.py +++ b/blivet/formats/fs.py @@ -1359,6 +1359,18 @@ class Iso9660FS(FS): register_device_format(Iso9660FS) +class UDFFS(FS): + + """ UDF filesystem. """ + _type = "udf" + _modules = ["udf"] + _supported = True + _mount_class = fsmount.UDFFSMount + + +register_device_format(UDFFS) + + class NoDevFS(FS): """ nodev filesystem base class """ diff --git a/blivet/populator/helpers/disklabel.py b/blivet/populator/helpers/disklabel.py index db10638e..842cd308 100644 --- a/blivet/populator/helpers/disklabel.py +++ b/blivet/populator/helpers/disklabel.py @@ -42,7 +42,7 @@ class DiskLabelFormatPopulator(FormatPopulator): # XXX ignore disklabels on multipath or biosraid member disks return (bool(udev.device_get_disklabel_type(data)) and not udev.device_is_biosraid_member(data) and - udev.device_get_format(data) != "iso9660" and + udev.device_get_format(data) not in ("iso9660", "udf") and not (device.is_disk and udev.device_get_format(data) == "mpath_member")) def _get_kwargs(self): diff --git a/blivet/populator/helpers/partition.py b/blivet/populator/helpers/partition.py index 8659bd48..9257407e 100644 --- a/blivet/populator/helpers/partition.py +++ b/blivet/populator/helpers/partition.py @@ -75,7 +75,7 @@ class PartitionDevicePopulator(DevicePopulator): # For partitions on disklabels parted cannot make sense of, go ahead # and instantiate a PartitionDevice so our view of the layout is # complete. - if not disk.partitionable or disk.format.type == "iso9660" or disk.format.hidden: + if not disk.partitionable or disk.format.type in ("iso9660", "udf") or disk.format.hidden: log.debug("ignoring partition %s on %s", name, disk.format.type) return diff --git a/blivet/tasks/fsmount.py b/blivet/tasks/fsmount.py index 65b2470a..a7f493dd 100644 --- a/blivet/tasks/fsmount.py +++ b/blivet/tasks/fsmount.py @@ -163,6 +163,10 @@ class Iso9660FSMount(FSMount): options = ["ro"] +class UDFFSMount(FSMount): + options = ["ro"] + + class NoDevFSMount(FSMount): @property --- a/tests/storage_tests/formats_test/fs_test.py +++ b/tests/storage_tests/formats_test/fs_test.py @@ -223,6 +223,10 @@ class Iso9660FS(fstesting.FSAsRoot): _fs_class = fs.Iso9660FS +class UDFFS(fstesting.FSAsRoot): + _fs_class = fs.UDFFS + + @unittest.skip("Too strange to test using this framework.") class NoDevFSTestCase(fstesting.FSAsRoot): _fs_class = fs.NoDevFS diff --git a/tests/unit_tests/populator_test.py b/tests/unit_tests/populator_test.py index 1ee29b57..df56e1f5 100644 --- a/tests/unit_tests/populator_test.py +++ b/tests/unit_tests/populator_test.py @@ -979,6 +979,11 @@ class DiskLabelPopulatorTestCase(PopulatorHelperTestCase): self.assertFalse(self.helper_class.match(data, device)) device_get_format.return_value = None + # no match for whole-disk udf filesystem + device_get_format.return_value = "udf" + self.assertFalse(self.helper_class.match(data, device)) + device_get_format.return_value = None + # no match for biosraid members device_is_biosraid_member.return_value = True self.assertFalse(self.helper_class.match(data, device)) -- 2.46.0 From 54e6cc7a7e01bfe8a627b2c2f4ba352c9e6e5564 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 14 Mar 2024 15:10:27 +0100 Subject: [PATCH 2/2] nvme: Skip startup/write when NVMe plugin isn't available This is similar to other modules like iSCSI where these methods are silently skipped if the technology isn't supported or available. Resolves: RHEL-28124 --- blivet/nvme.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/blivet/nvme.py b/blivet/nvme.py index b1513c19..4309dea3 100644 --- a/blivet/nvme.py +++ b/blivet/nvme.py @@ -71,10 +71,21 @@ class NVMe(object): except Exception: # pylint: disable=broad-except pass + def available(self): + if not hasattr(blockdev.Plugin, "NVME"): + return False + if not hasattr(blockdev.NVMETech, "FABRICS"): + return False + return True + def startup(self): if self.started: return + if not self.available(): + log.info("NVMe support not available, not starting") + return + self._hostnqn = blockdev.nvme_get_host_nqn() self._hostid = blockdev.nvme_get_host_id() if not self._hostnqn: @@ -97,6 +108,9 @@ class NVMe(object): self.started = True def write(self, root, overwrite=True): # pylint: disable=unused-argument + if not self.available(): + return + # write down the hostnqn and hostid files p = root + ETC_NVME_PATH if not os.path.isdir(p): -- 2.46.0