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

[PATCH 2/2] Make sure /boot is mapped to a single LVM PV on s390x



When /boot lives on a logical volume on s390x, zipl requires that it map
to single physical volume.  This patch is a followup to
39244f8f49ee3864edf8bd54f41a6a37864ed56d to ensure that /boot is on a
logical volume that maps to a single physical volume.  I do that by
generating a list of parents, sorting, and taking the last one.  Not
exactly foolproof, but it should work for the autopart case which is the
main request.

Related: rhbz#618376
---
 platform.py               |    6 ++++++
 storage/devicelibs/lvm.py |    4 ++--
 storage/devices.py        |   19 ++++++++++++++++++-
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/platform.py b/platform.py
index d7a890c..1d38475 100644
--- a/platform.py
+++ b/platform.py
@@ -485,6 +485,12 @@ class S390(Platform):
         return [PartSpec(mountpoint="/boot", fstype=self.defaultBootFSType, size=500,
                          weight=self.weight(mountpoint="/boot"), asVol=True)]
 
+    def weight(self, fstype=None, mountpoint=None):
+        if mountpoint and mountpoint == "/boot":
+            return 5000
+        else:
+            return 0
+
 class Sparc(Platform):
     _diskLabelType = "sun"
 
diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
index 0482cd5..22dab68 100644
--- a/storage/devicelibs/lvm.py
+++ b/storage/devicelibs/lvm.py
@@ -366,12 +366,12 @@ def lvorigin(vg_name, lv_name):
 
     return origin
 
-def lvcreate(vg_name, lv_name, size, progress=None):
+def lvcreate(vg_name, lv_name, size, progress=None, pvs=[]):
     args = ["lvcreate"] + \
             ["-L", "%dm" % size] + \
             ["-n", lv_name] + \
             config_args + \
-            [vg_name]
+            [vg_name] + pvs
 
     try:
         lvm(args, progress=progress)
diff --git a/storage/devices.py b/storage/devices.py
index 0776f22..2a243d2 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -2420,6 +2420,18 @@ class LVMLogicalVolumeDevice(DMDevice):
             except Exception as e:
                 log.debug("vg %s teardown failed; continuing" % self.vg.name)
 
+    def _getSinglePV(self):
+        pvs = []
+        paths = []
+
+        for parent in self.parents:
+            pvs += parent.parents
+
+        paths = map(lambda x: x.path, pvs)
+
+        paths.sort()
+        return paths[-1:]
+
     def create(self, intf=None):
         """ Create the device. """
         log_method_call(self, self.name, status=self.status)
@@ -2437,7 +2449,12 @@ class LVMLogicalVolumeDevice(DMDevice):
             self.setupParents()
 
             # should we use --zero for safety's sake?
-            lvm.lvcreate(self.vg.name, self._name, self.size, progress=w)
+            if hasattr(self.format, "mountpoint") and \
+               self.format.mountpoint == "/boot":
+                lvm.lvcreate(self.vg.name, self._name, self.size, progress=w,
+                             pvs=self._getSinglePV())
+            else:
+                lvm.lvcreate(self.vg.name, self._name, self.size, progress=w)
         except Exception:
             raise
         else:
-- 
1.7.3.4


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