[PATCH] Mark zRAM devices as protected and ignore them

Vratislav Podzimek vpodzime at redhat.com
Tue Jul 29 13:40:48 UTC 2014


We use zRAM devices as swaps and they need to be protected. We should ignore
such devices in the GUI even though they are not removable.

Also make one local import global.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/anaconda.py             | 7 ++++++-
 pyanaconda/ui/gui/spokes/custom.py | 2 +-
 pyanaconda/ui/lib/disks.py         | 3 +--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/anaconda.py b/pyanaconda/anaconda.py
index de2ba04..4c705df 100644
--- a/pyanaconda/anaconda.py
+++ b/pyanaconda/anaconda.py
@@ -30,6 +30,8 @@
 
 import os
 import sys
+import stat
+from glob import glob
 from tempfile import mkstemp
 
 from pyanaconda.bootloader import get_bootloader
@@ -140,7 +142,6 @@ class Anaconda(object):
 
     @property
     def protected(self):
-        import stat
         specs = []
         if os.path.exists("/run/initramfs/livedev") and \
            stat.S_ISBLK(os.stat("/run/initramfs/livedev")[stat.ST_MODE]):
@@ -152,6 +153,10 @@ class Anaconda(object):
         if self.stage2 and self.stage2.startswith("hd:"):
             specs.append(self.stage2[3:].split(":", 3)[0])
 
+        # zRAM swap devices need to be protected
+        for zram_dev in glob("/dev/zram*"):
+            specs.append(zram_dev)
+
         return specs
 
     @property
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 45ab6de..96366f7 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -346,7 +346,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._hidden_disks = []
 
         for disk in self._storage_playground.disks:
-            if (disk.removable and disk.protected) or not disk.mediaPresent:
+            if disk.protected or not disk.mediaPresent:
                 # hide removable disks containing install media
                 self._hidden_disks.append(disk)
                 self._storage_playground.devicetree.hide(disk)
diff --git a/pyanaconda/ui/lib/disks.py b/pyanaconda/ui/lib/disks.py
index ce0d4f5..9d4607f 100644
--- a/pyanaconda/ui/lib/disks.py
+++ b/pyanaconda/ui/lib/disks.py
@@ -58,8 +58,7 @@ def getDisks(devicetree, fake=False):
 
         disks = []
         for d in devices:
-            if d.isDisk and not d.format.hidden and not (d.protected and d.removable) \
-               and "zram" not in d.name:
+            if d.isDisk and not d.format.hidden and not d.protected:
                 # unformatted DASDs are detected with a size of 0, but they should
                 # still show up as valid disks if this function is called, since we
                 # can still use them; anaconda will know how to handle them, so they
-- 
1.9.3



More information about the anaconda-patches mailing list