neil / rpms / python-blivet

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