[gnome-boxes] libvirt-machine-props: Don't use default size as min size



commit 670d447bce72136503591d564ec2687e14876625
Author: Fabiano FidĂȘncio <fabiano fidencio org>
Date:   Tue Oct 24 17:55:45 2017 +0200

    libvirt-machine-props: Don't use default size as min size
    
    When an ISO is not part of osinfo-db GNOME Boxes previously used a
    default pre-defined size for storage as the minimum size for the
    storage, which had as a drawback that the users were not able to
    decrease the size of the disk when customizing the VM.
    
    In order to avoid the issue described above a new pre-defined size for
    minimum storage has been added (10 GIBIBYTES) which gives the users the
    chance to decrease the disk size according to their needs, in case the
    default pre-defined size is too big for them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789396
    
    Signed-off-by: Fabiano FidĂȘncio <fabiano fidencio org>

 src/libvirt-machine-properties.vala |    4 ++--
 src/os-database.vala                |   12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 1cc49cd..4df0bd3 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -618,8 +618,8 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
         if (minimum_resources != null && minimum_resources.storage != -1) {
             return minimum_resources.storage;
         } else {
-            var default_resources = OSDatabase.get_default_resources ();
-            return uint64.min (volume_info.capacity, default_resources.storage);
+            minimum_resources = OSDatabase.get_minimum_resources ();
+            return uint64.min (volume_info.capacity, minimum_resources.storage);
         }
     }
 
diff --git a/src/os-database.vala b/src/os-database.vala
index e595a37..461c063 100644
--- a/src/os-database.vala
+++ b/src/os-database.vala
@@ -17,6 +17,8 @@ private class Boxes.OSDatabase : GLib.Object {
         LAST
     }
 
+    private const int64 MINIMAL_STORAGE = 10 * (int64) GIBIBYTES;
+
     private const int DEFAULT_VCPUS = 1;
     private const int64 DEFAULT_RAM = 2 * (int64) GIBIBYTES;
 
@@ -40,6 +42,16 @@ private class Boxes.OSDatabase : GLib.Object {
         return resources;
     }
 
+    public static Resources get_minimum_resources () {
+        var resources = new Resources ("whatever", "x86_64");
+
+        resources.n_cpus = DEFAULT_VCPUS;
+        resources.ram = DEFAULT_RAM;
+        resources.storage = MINIMAL_STORAGE;
+
+        return resources;
+    }
+
     public async void load () {
         db_loading = true;
         var loader = new Loader ();


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