Blob Blame History Raw
From d2d9a4e0c086a0551dac644d45954f23e0116ef1 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 12 Sep 2018 10:45:41 +0200
Subject: [PATCH 1/2] Allow removing btrfs volumes without btrfs support

Btrfs volumes are removed using wipefs so we don't need to check
for device dependencies availability when removing the volume
(btrfs support depends on libblockdev btrfs plugin).

Resolves: rhbz#1605213
---
 blivet/deviceaction.py | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
index 3e337e18..b3e9e5f1 100644
--- a/blivet/deviceaction.py
+++ b/blivet/deviceaction.py
@@ -160,15 +160,19 @@ class DeviceAction(util.ObjectID):
         if not isinstance(device, StorageDevice):
             raise ValueError("arg 1 must be a StorageDevice instance")
 
-        unavailable_dependencies = device.unavailable_dependencies
-        if unavailable_dependencies:
-            dependencies_str = ", ".join(str(d) for d in unavailable_dependencies)
-            raise DependencyError("device type %s requires unavailable_dependencies: %s" % (device.type, dependencies_str))
-
         self.device = device
+
+        self._check_device_dependencies()
+
         self.container = getattr(self.device, "container", None)
         self._applied = False
 
+    def _check_device_dependencies(self):
+        unavailable_dependencies = self.device.unavailable_dependencies
+        if unavailable_dependencies:
+            dependencies_str = ", ".join(str(d) for d in unavailable_dependencies)
+            raise DependencyError("device type %s requires unavailable_dependencies: %s" % (self.device.type, dependencies_str))
+
     def apply(self):
         """ apply changes related to the action to the device(s) """
         self._applied = True
@@ -379,6 +383,15 @@ class ActionDestroyDevice(DeviceAction):
         # XXX should we insist that device.fs be None?
         DeviceAction.__init__(self, device)
 
+    def _check_device_dependencies(self):
+        if self.device.type == "btrfs volume":
+            # XXX destroying a btrfs volume is a special case -- we don't destroy
+            # the device, but use wipefs to destroy format on its parents so we
+            # don't need btrfs plugin or btrfs-progs for this
+            return
+
+        super(ActionDestroyDevice, self)._check_device_dependencies()
+
     def execute(self, callbacks=None):
         super(ActionDestroyDevice, self).execute(callbacks=callbacks)
         self.device.destroy()
-- 
2.17.1


From a9bcf26e085160a84b78c396c33cd0a77a35a746 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 17 Sep 2018 10:25:24 +0200
Subject: [PATCH 2/2] Check device dependencies only for device actions

We don't want to check device dependencies for format actions.
It should be possible to for example format an opened LUKS device
without libblockdev crypto plugin.

Related: rhbz#1605213
---
 blivet/deviceaction.py                  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
index b3e9e5f1..14a06ff0 100644
--- a/blivet/deviceaction.py
+++ b/blivet/deviceaction.py
@@ -162,7 +162,8 @@ class DeviceAction(util.ObjectID):
 
         self.device = device
 
-        self._check_device_dependencies()
+        if self.is_device:
+            self._check_device_dependencies()
 
         self.container = getattr(self.device, "container", None)
         self._applied = False
-- 
2.17.1