neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone
a9158f
From fed62af06eb1584adbacd821dfe79c2df52c6aa4 Mon Sep 17 00:00:00 2001
a9158f
From: Vojtech Trefny <vtrefny@redhat.com>
a9158f
Date: Wed, 2 Nov 2022 12:14:28 +0100
a9158f
Subject: [PATCH] Catch BlockDevNotImplementedError for btrfs plugin calls
a9158f
a9158f
This is a workaround for RHEL where the btrfs plugin is not
a9158f
available and where we might still try to call some libblockdev
a9158f
functions to gather information about preexisting btrfs devices.
a9158f
---
a9158f
 blivet/devices/btrfs.py | 8 ++++----
a9158f
 1 file changed, 4 insertions(+), 4 deletions(-)
a9158f
a9158f
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
a9158f
index 0e029715..1ae6a04d 100644
a9158f
--- a/blivet/devices/btrfs.py
a9158f
+++ b/blivet/devices/btrfs.py
a9158f
@@ -362,7 +362,7 @@ class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice, RaidDevice):
a9158f
         try:
a9158f
             subvols = blockdev.btrfs.list_subvolumes(mountpoint,
a9158f
                                                      snapshots_only=snapshots_only)
a9158f
-        except blockdev.BtrfsError as e:
a9158f
+        except (blockdev.BtrfsError, blockdev.BlockDevNotImplementedError) as e:
a9158f
             log.debug("failed to list subvolumes: %s", e)
a9158f
         else:
a9158f
             self._get_default_subvolume_id()
a9158f
@@ -400,7 +400,7 @@ class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice, RaidDevice):
a9158f
         with self._do_temp_mount() as mountpoint:
a9158f
             try:
a9158f
                 subvolid = blockdev.btrfs.get_default_subvolume_id(mountpoint)
a9158f
-            except blockdev.BtrfsError as e:
a9158f
+            except (blockdev.BtrfsError, blockdev.BlockDevNotImplementedError) as e:
a9158f
                 log.debug("failed to get default subvolume id: %s", e)
a9158f
 
a9158f
         self._default_subvolume_id = subvolid
a9158f
@@ -413,7 +413,7 @@ class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice, RaidDevice):
a9158f
         with self._do_temp_mount() as mountpoint:
a9158f
             try:
a9158f
                 blockdev.btrfs.set_default_subvolume(mountpoint, vol_id)
a9158f
-            except blockdev.BtrfsError as e:
a9158f
+            except (blockdev.BtrfsError, blockdev.BlockDevNotImplementedError) as e:
a9158f
                 log.error("failed to set new default subvolume id (%s): %s",
a9158f
                           vol_id, e)
a9158f
                 # The only time we set a new default subvolume is so we can remove
a9158f
@@ -471,7 +471,7 @@ class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice, RaidDevice):
a9158f
         if not self.format.vol_uuid:
a9158f
             try:
a9158f
                 bd_info = blockdev.btrfs.filesystem_info(self.parents[0].path)
a9158f
-            except blockdev.BtrfsError as e:
a9158f
+            except (blockdev.BtrfsError, blockdev.BlockDevNotImplementedError) as e:
a9158f
                 log.error("failed to get filesystem info for new btrfs volume %s", e)
a9158f
             else:
a9158f
                 self.format.vol_uuid = bd_info.uuid
a9158f
-- 
a9158f
2.38.1
a9158f