[master 4/5] Make sure factory target size is within the limits of the fstype.

dwlehman installerbot-noreply at redhat.com
Fri Jul 24 21:41:12 UTC 2015


From: David Lehman <dlehman at redhat.com>

---
 blivet/devicefactory.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py
index 285d4b5..776b4a8 100644
--- a/blivet/devicefactory.py
+++ b/blivet/devicefactory.py
@@ -383,6 +383,22 @@ def _get_free_disk_space(self):
         free_info = self.storage.getFreeSpace(disks=self.disks)
         return sum(d[0] for d in free_info.values())
 
+    def _normalize_size(self):
+        if self.size is None:
+            self._handle_no_size()
+
+        size = self.size
+        fmt = getFormat(self.fstype)
+        if size < fmt.minSize:
+            size = fmt.minSize
+        elif fmt.maxSize and size > fmt.maxSize:
+            size = fmt.maxSize
+
+        if self.size != size:
+            log.debug("adjusted size from %s to %s to honor format limits",
+                      self.size, size)
+            self.size = size
+
     def _handle_no_size(self):
         """ Set device size so that it grows to the largest size possible. """
         if self.size is not None:
@@ -812,7 +828,7 @@ def _configure(self):
         if self.container and self.container.exists:
             self.disks = self.container.disks
 
-        self._handle_no_size()
+        self._normalize_size()
         self._set_up_child_factory()
 
         # Configure any devices this device will use as building blocks, except


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/a8001281b592dc0266a4220b452abadc4063b74b


More information about the anaconda-patches mailing list