neil / rpms / python-blivet

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