[PATCH rhel6-branch master] Don't crash when putting mpath devices into the filter name cache (#597223).

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

 



The big problem here is that identifyMultipaths returns a list of lists of
components, whereas the name cache stuff expects just a regular list.
Therefore, I need to first flatten the component structure when creating
the cache and also check every component of an mpath device to see if it's
in the cache before deciding a device is new or not.
---
 iw/filter_gui.py |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/iw/filter_gui.py b/iw/filter_gui.py
index 4552491..50346c9 100644
--- a/iw/filter_gui.py
+++ b/iw/filter_gui.py
@@ -23,6 +23,7 @@ import collections
 import gtk, gobject
 import gtk.glade
 import gui
+import itertools
 import iutil
 import parted
 import _ped
@@ -445,9 +446,20 @@ class FilterWindow(InstallWindow):
                                                     new_singlepaths)
 
         nonraids = filter(lambda d: d not in self._cachedDevices, new_nonraids)
-        mpaths = filter(lambda d: d not in self._cachedMPaths, new_mpaths)
         raids = filter(lambda d: d not in self._cachedRaidDevices, new_raids)
 
+        # The end result of the loop below is that mpaths is a list of lists of
+        # components, just like new_mpaths.  That's what populate expects.
+        mpaths = []
+        for mp in new_mpaths:
+            for d in mp:
+                # If all components of this multipath device are in the
+                # cache, skip it.  Otherwise, it's a new device and needs to
+                # be populated into the UI.
+                if d not in self._cachedMPaths:
+                    mpaths.append(mp)
+                    break
+
         self.populate(nonraids, mpaths, raids, activeByDefault=True)
 
         # Make sure to update the size label at the bottom.
@@ -457,6 +469,11 @@ class FilterWindow(InstallWindow):
         self._cachedMPaths.extend(mpaths)
         self._cachedRaidDevices.extend(raids)
 
+        # And then we need to do the same list flattening trick here as in
+        # getScreen.
+        lst = list(itertools.chain(*mpaths))
+        self._cachedMPaths.extend(lst)
+
     def _makeBasic(self):
         np = NotebookPage(self.store, "basic", self.xml, Callbacks(self.xml))
 
@@ -610,9 +627,15 @@ class FilterWindow(InstallWindow):
         # can just add the new devices to the UI.  This is going to be slow,
         # but the user has to click a button to get to the slow part.
         self._cachedDevices = NameCache(singlepaths)
-        self._cachedMPaths = NameCache(mpaths)
         self._cachedRaidDevices = NameCache(raids)
 
+        # Multipath is a little more complicated.  Since mpaths is a list of
+        # lists, we can't directly store that into the cache.  Instead we want
+        # to flatten it into a single list of all components of all multipaths
+        # and store that.
+        lst = list(itertools.chain(*mpaths))
+        self._cachedMPaths = NameCache(lst)
+
         # Switch to the first notebook page that displays any devices.
         i = 0
         for pg in self.pages:
-- 
1.7.0.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux