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