[gnome-boxes] libvirt-machine-props: Set RAM size in correct units



commit d30f24237adb1ac6d4237d50b6d96c1a16ac3cdb
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Mar 15 18:39:28 2013 +0200

    libvirt-machine-props: Set RAM size in correct units
    
    The RAM size we get from property widget is in bytes where as default
    units used by libvirt config are in KiB. So we must convert before
    setting.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694430

 src/libvirt-machine-properties.vala |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 01a9eb0..5b6c829 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -430,19 +430,20 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
     private void on_ram_changed (Boxes.Property property, uint64 value) {
         // Ensure that we don't end-up changing RAM like a 1000 times a second while user moves the slider..
         property.deferred_change = () => {
+            var ram = (value + Osinfo.KIBIBYTES - 1) / Osinfo.KIBIBYTES;
             try {
                 var config = machine.domain.get_config (GVir.DomainXMLFlags.INACTIVE);
-                config.memory = value;
+                config.memory = ram;
                 if (config.get_class ().find_property ("current-memory") != null)
-                    config.set ("current-memory", value);
+                    config.set ("current-memory", ram);
                 machine.domain.set_config (config);
-                debug ("RAM changed to %llu", value);
+                debug ("RAM changed to %llu KiB", ram);
                 if (machine.is_on ())
                     notify_reboot_required ();
             } catch (GLib.Error error) {
-                warning ("Failed to change RAM of box '%s' to %llu: %s",
+                warning ("Failed to change RAM of box '%s' to %llu KiB: %s",
                          machine.domain.get_name (),
-                         value,
+                         ram,
                          error.message);
             }
 


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