neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

Blame SOURCES/0005-Round-down-to-nearest-MiB-value-when-writing-ks-parittion-info.ks

3668c7
From dc964f10d24499ea7fc90fd896a8b50c9c5e2d74 Mon Sep 17 00:00:00 2001
3668c7
From: "Samantha N. Bueno" <sbueno+anaconda@redhat.com>
3668c7
Date: Wed, 8 Jun 2016 13:47:40 -0400
3668c7
Subject: [PATCH] Round down to nearest MiB value when writing ks parittion
3668c7
 info.
3668c7
3668c7
On s390x in particular, some partition alignment issue is causing fractional
3668c7
sizes to be reported. Pykickstart doesn't take anything except int values for
3668c7
partition info, hence the call to roundToNearest.
3668c7
3668c7
This change only affects the data that is written to ks.cfg.
3668c7
3668c7
Resolves: rhbz#1850670
3668c7
---
3668c7
 blivet/devices/partition.py | 9 ++++++---
3668c7
 1 file changed, 6 insertions(+), 3 deletions(-)
3668c7
3668c7
diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
3668c7
index 0c56a6e7..76048aed 100644
3668c7
--- a/blivet/devices/partition.py
3668c7
+++ b/blivet/devices/partition.py
3668c7
@@ -35,7 +35,7 @@
3668c7
 from ..storage_log import log_method_call
3668c7
 from .. import udev
3668c7
 from ..formats import DeviceFormat, get_format
3668c7
-from ..size import Size, MiB
3668c7
+from ..size import Size, MiB, ROUND_DOWN
3668c7
 
3668c7
 import logging
3668c7
 log = logging.getLogger("blivet")
3668c7
@@ -967,7 +967,8 @@ def populate_ksdata(self, data):
3668c7
         data.resize = (self.exists and self.target_size and
3668c7
                        self.target_size != self.current_size)
3668c7
         if not self.exists:
3668c7
-            data.size = self.req_base_size.convert_to(MiB)
3668c7
+            # round this to nearest MiB before doing anything else
3668c7
+            data.size = self.req_base_size.round_to_nearest(MiB, rounding=ROUND_DOWN).convert_to(spec=MiB)
3668c7
             data.grow = self.req_grow
3668c7
             if self.req_grow:
3668c7
                 data.max_size_mb = self.req_max_size.convert_to(MiB)
3668c7
@@ -980,4 +981,6 @@ def populate_ksdata(self, data):
3668c7
             data.on_part = self.name                     # by-id
3668c7
 
3668c7
             if data.resize:
3668c7
-                data.size = self.size.convert_to(MiB)
3668c7
+                # on s390x in particular, fractional sizes are reported, which
3668c7
+                # cause issues when writing to ks.cfg
3668c7
+                data.size = self.size.round_to_nearest(MiB, rounding=ROUND_DOWN).convert_to(spec=MiB)