After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 694430 - Fix KiB/B confusion in box properties
Fix KiB/B confusion in box properties
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: 3.22
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
: 695986 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-02-22 10:29 UTC by Christophe Fergeau
Modified: 2016-03-31 13:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add memory units to diagnostics log (1.51 KB, patch)
2013-02-22 10:29 UTC, Christophe Fergeau
committed Details | Review
Use NodeInfo::memory as max memory in diagnostics log (1.40 KB, patch)
2013-02-22 10:29 UTC, Christophe Fergeau
committed Details | Review
libvirt: Fix current memory size display in properties (1.22 KB, patch)
2013-02-22 10:30 UTC, Christophe Fergeau
committed Details | Review
libvirt-machine-props: Set RAM size in correct units (2.00 KB, patch)
2013-03-15 16:46 UTC, Zeeshan Ali
reviewed Details | Review
libvirt-machine-props: Set RAM size in correct units (2.11 KB, patch)
2013-03-18 13:56 UTC, Zeeshan Ali
committed Details | Review

Description Christophe Fergeau 2013-02-22 10:29:24 UTC
When going to a box properties, the amount of RAM in the VM is currently wrong
by a factor of 1024 as it's in KiB and not bytes.
Comment 1 Christophe Fergeau 2013-02-22 10:29:26 UTC
Created attachment 237163 [details] [review]
Add memory units to diagnostics log

The troubleshooting log that can be obtained through a box properties
shows the current/max memory for the box. As this amount is in KiB,
this commit adds a unit to this log to make this explicit.
Comment 2 Christophe Fergeau 2013-02-22 10:29:29 UTC
Created attachment 237164 [details] [review]
Use NodeInfo::memory as max memory in diagnostics log

This is what add_ram_property() uses as the maximum for the memory
slider, so it's better to log that value rather than the unused
info.maxMem
Comment 3 Christophe Fergeau 2013-02-22 10:30:13 UTC
Created attachment 237165 [details] [review]
libvirt: Fix current memory size display in properties

The memory size returned by LibvirtGConfig is in KiB.
Comment 4 Zeeshan Ali 2013-02-22 11:07:38 UTC
Review of attachment 237165 [details] [review]:

Good catch, ACK
Comment 5 Zeeshan Ali 2013-02-22 11:27:05 UTC
Review of attachment 237163 [details] [review]:

::: src/libvirt-machine-properties.vala
@@ +65,3 @@
             var info = machine.domain.get_info ();
             builder.append_printf ("Cpu time: %"+uint64.FORMAT_MODIFIER+"d\n", info.cpuTime);
+            builder.append_printf ("Memory: %"+uint64.FORMAT_MODIFIER+"d KiB\n", info.memory);

I think we should use the GLib.format_size in here too.
Comment 6 Zeeshan Ali 2013-02-22 11:32:45 UTC
Review of attachment 237164 [details] [review]:

ACK
Comment 7 Christophe Fergeau 2013-02-22 13:25:52 UTC
Review of attachment 237163 [details] [review]:

::: src/libvirt-machine-properties.vala
@@ +65,3 @@
             var info = machine.domain.get_info ();
             builder.append_printf ("Cpu time: %"+uint64.FORMAT_MODIFIER+"d\n", info.cpuTime);
+            builder.append_printf ("Memory: %"+uint64.FORMAT_MODIFIER+"d KiB\n", info.memory);

As this is debugging/troubleshooting output, displaying the raw value rather than rounding it is better imo.
Comment 8 Zeeshan Ali 2013-02-22 14:50:17 UTC
Review of attachment 237163 [details] [review]:

ack then

::: src/libvirt-machine-properties.vala
@@ +65,3 @@
             var info = machine.domain.get_info ();
             builder.append_printf ("Cpu time: %"+uint64.FORMAT_MODIFIER+"d\n", info.cpuTime);
+            builder.append_printf ("Memory: %"+uint64.FORMAT_MODIFIER+"d KiB\n", info.memory);

good point.
Comment 9 Christophe Fergeau 2013-02-22 15:04:21 UTC
Attachment 237163 [details] pushed as 35cf6c0 - Add memory units to diagnostics log
Attachment 237164 [details] pushed as 26ce4c2 - Use NodeInfo::memory as max memory in diagnostics log
Attachment 237165 [details] pushed as c7e63f3 - libvirt: Fix current memory size display in properties
Comment 10 Zeeshan Ali 2013-03-15 16:46:33 UTC
Created attachment 238990 [details] [review]
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.
Comment 11 Zeeshan Ali 2013-03-15 16:47:15 UTC
Still some confusion left. :) Check attached patch.
Comment 12 Zeeshan Ali 2013-03-17 20:10:15 UTC
*** Bug 695986 has been marked as a duplicate of this bug. ***
Comment 13 Christophe Fergeau 2013-03-18 08:55:42 UTC
Review of attachment 238990 [details] [review]:

::: src/libvirt-machine-properties.vala
@@ +431,3 @@
         // 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;

Do we want to make sure this is rounded up if 'value' is not a multiple of 1024? This would make it
var ram = (value + Osinfo.KIBIBYTES - 1) / Osinfo.KIBIBYTES;

@@ +439,2 @@
                 machine.domain.set_config (config);
+                debug ("RAM changed to %llu", ram);

Please add a unit here...

@@ +447,1 @@
                          error.message);

... and to this message as well
Comment 14 Zeeshan Ali 2013-03-18 13:14:13 UTC
Review of attachment 238990 [details] [review]:

::: src/libvirt-machine-properties.vala
@@ +431,3 @@
         // 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;

Probably a good idea but I'd put that in a separate patch.
Comment 15 Christophe Fergeau 2013-03-18 13:48:54 UTC
Review of attachment 238990 [details] [review]:

::: src/libvirt-machine-properties.vala
@@ +431,3 @@
         // 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;

Why? This patch is about converting bytes to kib, why do the conversion one way, and then have  an additional patch to change how we do the conversion?
Comment 16 Zeeshan Ali 2013-03-18 13:56:36 UTC
Created attachment 239130 [details] [review]
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.
Comment 17 Christophe Fergeau 2013-03-18 14:07:16 UTC
Review of attachment 239130 [details] [review]:

Failed to publish review: Undefined subroutine &extensions::splinter::lib::WSSplinter::ThrowCodeError called at /var/www/bugzilla.gnome.org/extensions/splinter/lib/WSSplinter.pm line 88.
Comment 18 Zeeshan Ali 2013-03-18 15:46:37 UTC
Attachment 239130 [details] pushed as d30f242 - libvirt-machine-props: Set RAM size in correct units