[master 3/3] Copy all DeviceFormat objects using deepcopy.

mulkieran installerbot-noreply at redhat.com
Wed Jun 24 21:42:17 UTC 2015


From: mulhern <amulhern at redhat.com>

To avoid sharing of mutable subparts.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/blivet.py          | 2 +-
 blivet/devices/btrfs.py   | 2 +-
 blivet/devices/storage.py | 2 +-
 blivet/populator.py       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/blivet/blivet.py b/blivet/blivet.py
index cc9607f..3cdf629 100644
--- a/blivet/blivet.py
+++ b/blivet/blivet.py
@@ -1121,7 +1121,7 @@ def resetDevice(self, device):
             self.devicetree.cancelAction(action)
 
         # make sure any random overridden attributes are reset
-        device.format = copy.copy(device.originalFormat)
+        device.format = copy.deepcopy(device.originalFormat)
 
     def resizeDevice(self, device, new_size):
         """ Schedule a resize of a device and its formatting, if any.
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
index 867e271..56f0f37 100644
--- a/blivet/devices/btrfs.py
+++ b/blivet/devices/btrfs.py
@@ -204,7 +204,7 @@ def __init__(self, *args, **kwargs):
                                     device=self.path,
                                     subvolspec=self.vol_id,
                                     mountopts="subvolid=%d" % self.vol_id)
-            self.originalFormat = copy.copy(self.format)
+            self.originalFormat = copy.deepcopy(self.format)
 
         self._defaultSubVolumeID = None
 
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 525db63..911652c 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -124,7 +124,7 @@ def __init__(self, name, fmt=None, uuid=None,
         self.controllable = not flags.testing
 
         self.format = fmt
-        self.originalFormat = copy.copy(self.format)
+        self.originalFormat = copy.deepcopy(self.format)
         self.fstabComment = ""
         self._targetSize = self._size
 
diff --git a/blivet/populator.py b/blivet/populator.py
index 8927b47..323094f 100644
--- a/blivet/populator.py
+++ b/blivet/populator.py
@@ -756,7 +756,7 @@ def addUdevDevice(self, info, updateOrigFmt=False):
         # now handle the device's formatting
         self.handleUdevDeviceFormat(info, device)
         if device_added or updateOrigFmt:
-            device.originalFormat = copy.copy(device.format)
+            device.originalFormat = copy.deepcopy(device.format)
         device.deviceLinks = udev.device_get_symlinks(info)
 
     def handleUdevDiskLabelFormat(self, info, device):


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/4af685dcb9e871171ff482ff49bbcbe5e3593921


More information about the anaconda-patches mailing list