[libvirt] freecell gives out bytes instead of kilobytes

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

 



The virsh-command freecell hands out bytes but affixes those with kB.
The error ist found in virsh.c on line 1663 and following.
I have corrected this and altered the output to the method i chose for virt-manager - in the days of 96 GB per socket (Nehalem-EP) no one cares even about a fraction of a Megabyte.

--- a/src/virsh.c        2009-04-02 17:45:50.000000000 +0200
+++ b/src/virsh.c 2009-04-02 23:35:54.000000000 +0200
@@ -1661,10 +1661,23 @@
    }

    if (cell == -1)
-        vshPrint(ctl, "%s: %llu kB\n", _("Total"), memory);
+       if (memory < 10*1024*1204*1024)
+               {
+ vshPrint(ctl, "%s: %.0f MB\n", _("Total"), (float)memory/1024/1024);
+               }
+               else
+               {
+ vshPrint(ctl, "%s: %.2f GB\n", _("Total"), (float)memory/1024/1024/1024);
+               }
    else
-        vshPrint(ctl, "%d: %llu kB\n", cell, memory);
-
+       if (memory < 10*1024*1204*1024)
+               {
+ vshPrint(ctl, "%d: %.0f MB\n", cell, (float)memory/1024/1024);
+               }
+       else
+       {
+ vshPrint(ctl, "%d: %.2f GB\n", cell, (float)memory/1024/1024/1024);
+       }
    return TRUE;
}

eg:

rr016# virsh freecell; free -m
0: 24 MB

            total       used       free     shared    buffers     cached
Mem:          3884       3859         24          0         60       1306
-/+ buffers/cache:       2492       1392
Swap:         2047        248       1798

rr017# virsh freecell; free -m
0: 1490 MB

            total       used       free     shared    buffers     cached
Mem:          2991       1501       1489          0        100       1283
-/+ buffers/cache:        117       2873
Swap:         2047          0       2047

rr019# virsh freecell; free -m
0: 1616 MB

            total       used       free     shared    buffers     cached
Mem:          3952       2337       1615          0          5       1209
-/+ buffers/cache:       1121       2831
Swap:         2047          0       2047

Is this okay with you? Or just the fix for the output removing the kB-suffix.

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]