Bug 817239

Summary: dominfo outputs incorrectly for memory unit
Product: Red Hat Enterprise Linux 6 Reporter: Min Zhan <mzhan>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3CC: acathrow, bili, dallan, dyasny, dyuan, eblake, mzhan, rwu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.9.13-3.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 07:12:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Min Zhan 2012-04-28 08:24:28 UTC
Description of problem:
dominfo outputs incorrectly for memory unit

Version-Release number of selected component (if applicable):
libvirt-0.9.10-14.el6

How reproducible:
Always

Steps to Reproduce:
# virsh dumpxml rhel63
...
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
...

# virsh dominfo rhel63
Id:             -
Name:           rhel63
UUID:           9078a4b7-f1b5-71a2-43dc-7e3e000bc0ce
OS Type:        hvm
State:          shut off
CPU(s):         1
Max memory:     1048576 kB -> the unit should be KiB or k
Used memory:    1048576 kB -> the unit should be KiB or k
Persistent:     yes
Autostart:      enable
Managed save:   no
Security model: selinux
Security DOI:   0

Actual results:
As above

Expected results:
Use k or KiB for memory unit


Additional info:

Comment 1 Min Zhan 2012-04-28 08:25:52 UTC
Also for the following memory unit:

# virsh nodeinfo
CPU model:           x86_64
CPU(s):              4
CPU frequency:       2659 MHz
CPU socket(s):       1
Core(s) per socket:  4
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         7994800 kB 

# virsh nodememstats
total  :              7994800 kB
free   :              5690124 kB
buffers:               251384 kB
cached :              1123096 kB

Comment 2 Eric Blake 2012-04-28 16:48:05 UTC
These should be trivial fixes to virsh.  I'll propose something upstream soon.

Comment 4 Eric Blake 2012-04-30 20:31:39 UTC
Upstream patch proposed
https://www.redhat.com/archives/libvir-list/2012-April/msg01535.html

Comment 5 Eric Blake 2012-05-23 17:48:33 UTC
Will be fixed for 6.4 when the rebase picks this up:

commit 706aa7c52bcedb9a1346e23ecb244b7291d06c53
Author: Eric Blake <eblake>
Date:   Mon Apr 30 14:27:56 2012 -0600

    virsh: output scaled values with correct units
    
    The recent push to use correct scaling terms (kB for 1000, KiB for
    1024 - such as commit 9dfdead) missed some places in virsh.
    
    * tools/virsh.c (prettyCapacity, cmdDominfo, cmdFreecell)
    (cmdNodeinfo, cmdNodeMemStats, cmdMigrateSetMaxSpeed)
    (cmdBlockCopy, cmdBlockPull, cmdBlockJob): Use KiB, not kB, when
    referring to multiples of 1024.
    * tests/virshtest.c: Update expected output to match.

Comment 8 EricLee 2012-07-25 02:04:11 UTC
Verified in libvirt-0.9.13-3.el6:

# virsh dumpxml qcow2_foo | grep -I mem
  <memory unit='KiB'>1048576</memory>
    <memballoon model='virtio'>
    </memballoon>

# virsh dominfo qcow2_foo
Id:             -
Name:           qcow2_foo
UUID:           8ac888e7-7288-bce9-0ef1-ce639d51c095
OS Type:        hvm
State:          shut off
CPU(s):         4
Max memory:     1048576 KiB
Used memory:    1048576 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: selinux
Security DOI:   0

# virsh nodeinfo
CPU model:           x86_64
CPU(s):              4
CPU frequency:       2000 MHz
CPU socket(s):       1
Core(s) per socket:  4
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         3791292 KiB

# virsh nodememstats
total  :              3791292 KiB
free   :              2727060 KiB
buffers:               110820 KiB
cached :               424992 KiB

And can reproduce in libvirt-0.9.10-21.el6:

# virsh dominfo qcow2_foo
Id:             -
Name:           qcow2_foo
UUID:           8ac888e7-7288-bce9-0ef1-ce639d51c095
OS Type:        hvm
State:          shut off
CPU(s):         4
Max memory:     1048576 kB
Used memory:    1048576 kB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: selinux
Security DOI:   0

# virsh nodeinfo
CPU model:           x86_64
CPU(s):              4
CPU frequency:       2000 MHz
CPU socket(s):       1
Core(s) per socket:  4
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         3791292 kB

# virsh nodememstats
total  :              3791292 kB
free   :              2735832 kB
buffers:               110888 kB
cached :               418464 kB

So setting to VERIFIED.

Comment 9 errata-xmlrpc 2013-02-21 07:12:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0276.html