[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 1/2] Put back the deepcopy of the device stack in ActionDestroyFormat.



This is needed to make preexisting LUKS LVM PVs work correctly.

It reverts commit f944e092f2415caad8856f8cfe6a3834be8f95c4.
---
 storage/deviceaction.py |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/storage/deviceaction.py b/storage/deviceaction.py
index dbfaf60..61e56d6 100644
--- a/storage/deviceaction.py
+++ b/storage/deviceaction.py
@@ -21,6 +21,8 @@
 # Red Hat Author(s): Dave Lehman <dlehman redhat com>
 #
 
+import copy
+
 from udev import *
 
 from devices import StorageDevice, PartitionDevice
@@ -301,7 +303,12 @@ class ActionDestroyFormat(DeviceAction):
 
     def __init__(self, device):
         DeviceAction.__init__(self, device)
-        self.origFormat = self.device.format
+        # Save a deep copy of the device stack this format occupies.
+        # This is necessary since the stack of devices and formats
+        # required to get to this format may get yanked out from under
+        # us between now and execute.
+        self._device = copy.deepcopy(device)
+        self.origFormat = self._device.format
         if device.format.exists:
             device.format.teardown()
         self.device.format = None
@@ -309,10 +316,14 @@ class ActionDestroyFormat(DeviceAction):
     def execute(self, intf=None):
         """ wipe the filesystem signature from the device """
         if self.origFormat:
-            self.device.setup()
+            # set up our copy of the original device stack since the
+            # reference we got may have had any number of things changed
+            # since then (most notably, formats removed by this very
+            # class' constructor)
+            self._device.setup()
             self.origFormat.destroy()
             udev_settle()
-            self.device.teardown()
+            self._device.teardown()
 
     def cancel(self):
         self.device.format = self.origFormat
-- 
1.6.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]