[blivet][all branches] Round device size down to nearest MiB. (#1257997)

Samantha N. Bueno sbueno+anaconda at redhat.com
Wed Sep 2 20:55:10 UTC 2015


Occasionally (eg on s390x) it happens that the number of blocks reported
by a disk * LINUX_SECTOR_SIZE (used to calculate size of disk in a more
human readable form) did not result in a perfectly round, non-decimal
value. (It seems that on x86_64 disks, the number of blocks was "just
so" that the size calculation did always end up being a non-decimal
value.)

Since this resulted in anaconda writing a ks.cfg with decimal values in
partitioning information, and since int values must be specified in ks,
the best "fix" here is to just round the calculated value.

Resolves: rhbz#1257997

---
 blivet/devices/storage.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index add18e6..ad8d04d 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -572,7 +572,7 @@ class StorageDevice(Device):
             blocks = int(util.get_sysfs_attr(self.sysfsPath, "size"))
             size = Size(blocks * LINUX_SECTOR_SIZE)
 
-        return size
+        return size.roundToNearest('MiB', 'ROUND_DOWN')
 
     @property
     def currentSize(self):
@@ -584,7 +584,7 @@ class StorageDevice(Device):
         """
         if self._currentSize == Size(0):
             self._currentSize = self.readCurrentSize()
-        return self._currentSize
+        return self._currentSize.roundToNearest('MiB', 'ROUND_DOWN')
 
     def updateSize(self):
         """ Update size, currentSize, and targetSize to actual size. """
-- 
1.9.3



More information about the anaconda-patches mailing list