neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone
Vojtech Trefny 607a1e
From 8ece3da18b1abb89320d02f4475002e6a3ed7875 Mon Sep 17 00:00:00 2001
Vojtech Trefny 607a1e
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny 607a1e
Date: Thu, 20 May 2021 13:40:26 +0200
Vojtech Trefny 607a1e
Subject: [PATCH] Fix activating old style LVM snapshots
Vojtech Trefny 607a1e
Vojtech Trefny 607a1e
The old style snapshots are activated together with the origin LV
Vojtech Trefny 607a1e
so we need to make sure it is activated to be able to remove the
Vojtech Trefny 607a1e
snapshot or its format.
Vojtech Trefny 607a1e
Vojtech Trefny 607a1e
Resolves: rhbz#1961739
Vojtech Trefny 607a1e
---
Vojtech Trefny 607a1e
 blivet/devices/lvm.py | 10 +++++++---
Vojtech Trefny 607a1e
 1 file changed, 7 insertions(+), 3 deletions(-)
Vojtech Trefny 607a1e
Vojtech Trefny 607a1e
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
Vojtech Trefny 607a1e
index a55515fcb..fb57804d9 100644
Vojtech Trefny 607a1e
--- a/blivet/devices/lvm.py
Vojtech Trefny 607a1e
+++ b/blivet/devices/lvm.py
Vojtech Trefny 607a1e
@@ -1461,9 +1461,13 @@ def _set_format(self, fmt):  # pylint: disable=unused-argument
Vojtech Trefny 607a1e
             self._update_format_from_origin()
Vojtech Trefny 607a1e
 
Vojtech Trefny 607a1e
     @old_snapshot_specific
Vojtech Trefny 607a1e
-    def setup(self, orig=False):
Vojtech Trefny 607a1e
-        # the old snapshot cannot be setup and torn down
Vojtech Trefny 607a1e
-        pass
Vojtech Trefny 607a1e
+    def setup(self, orig=False):  # pylint: disable=unused-argument
Vojtech Trefny 607a1e
+        # the old snapshot is activated together with the origin
Vojtech Trefny 607a1e
+        if self.origin and not self.origin.status:
Vojtech Trefny 607a1e
+            try:
Vojtech Trefny 607a1e
+                self.origin.setup()
Vojtech Trefny 607a1e
+            except blockdev.LVMError as lvmerr:
Vojtech Trefny 607a1e
+                log.error("failed to activate origin LV: %s", lvmerr)
Vojtech Trefny 607a1e
 
Vojtech Trefny 607a1e
     @old_snapshot_specific
Vojtech Trefny 607a1e
     def teardown(self, recursive=False):