[gnome-boxes] libvirt-machine-props: Fix max value of max disk



commit e6f42ca461779f868eda055b976e7918cb10bc76
Author: Fabiano Fidêncio <fidencio redhat com>
Date:   Fri Aug 15 14:11:47 2014 +0200

    libvirt-machine-props: Fix max value of max disk
    
    As Boxes only allocates the used space of a volume (instead of its
    capacity), the capacity itself should not be taken into account when
    calculating the max disk space and is better to use the volume's
    allocation instead:
        max disk space = volume's allocation + available space in the pool
    
    However it introduces an issue where the minimum storage value can be
    bigger or equal to the maximum storage value. In this case lets just
    show the current capacity as a label and not allow to change the value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726066

 src/libvirt-machine-properties.vala |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 8e0dd2b..97ca6fb 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -471,12 +471,20 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
             var volume_info = machine.storage_volume.get_info ();
             var pool = get_storage_pool (machine.connection);
             var pool_info = pool.get_info ();
-            var max_storage = volume_info.capacity + pool_info.available;
+            var min_storage = get_minimum_disk_size ();
+            var max_storage = volume_info.allocation + pool_info.available;
+
+            if (min_storage >= max_storage) {
+                add_string_property (ref list,
+                                     _("Maximum Disk Size"),
+                                     "%s".printf (format_size (volume_info.capacity, 
FormatSizeFlags.DEFAULT)));
+                return null;
+            }
 
             var property = add_size_property (ref list,
                                               _("Maximum Disk Size"),
                                               volume_info.capacity,
-                                              get_minimum_disk_size (),
+                                              min_storage,
                                               max_storage,
                                               256 * MEGABYTES);
             // Disable 'save on timeout' all together since that could lead us to very bad user experience:


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