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

49 lines
2.0 KiB
Plaintext
Raw Normal View History

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