RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 796526 - Improve memory usage readability in guest XML configuration
Summary: Improve memory usage readability in guest XML configuration
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: x86_64
OS: Linux
medium
low
Target Milestone: rc
: ---
Assignee: Daniel Veillard
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 770683
Blocks: 808522 813972
TreeView+ depends on / blocked
 
Reported: 2012-02-23 06:01 UTC by Alex Jia
Modified: 2012-06-20 06:49 UTC (History)
8 users (show)

Fixed In Version: libvirt-0.9.10-6.el6
Doc Type: Bug Fix
Doc Text:
Previously, libvirt would output guest memory values in kibibytes (multiples of 1024), but with no indication of the scale. Furthermore, the libvirt documentation referred to kilobytes (multiples of 1000). Meanwhile, qemu defaults to mebibytes (multiples of 1024*1024), and these differences in scale could result in users making mistakes such as giving a guest 1000 times less memory than planned, with a failure mode that was not easy to diagnose. Now the output is clear on the scale used, and the input allows user to use other scales that might be more convenient.
Clone Of:
: 808522 813972 (view as bug list)
Environment:
Last Closed: 2012-06-20 06:49:03 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 19:31:38 UTC

Description Alex Jia 2012-02-23 06:01:20 UTC
Description of problem:
I have ever met memory usage issue when I tried to change memory value in guest XML configuration before several years, I didn't know memory default unit is kilotypes, so it took me some time to debug it. 

......
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
......

At the time, I thought it was a improvement not a bug, hence, I haven't focus on it. however, it indeed isn't convenient for users, and it often let users confuse, now, some users start to complain this issue, so we need a bug to trace the issue.


Version-Release number of selected component (if applicable):
# rpm -q libvirt
libvirt-0.9.10-2.el6.x86_64

How reproducible:
always.

Steps to Reproduce:
1. virsh dumpxml <domain> |grep -i memory

  
Actual results:
......
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
......

Notes, we don't know what's the memory unit.

Expected results:
......
  <memory units='KiB'>1048576</memory>
  <currentMemory units='KiB'>1048576</currentMemory>
......

Additional info:

Comment 1 Alex Jia 2012-02-23 06:03:16 UTC
At present, Eric is working on it:
https://www.redhat.com/archives/libvir-list/2012-February/msg00959.html

Comment 2 Eric Blake 2012-03-06 00:36:14 UTC
v2 posted to upstream
https://www.redhat.com/archives/libvir-list/2012-March/msg00188.html

Comment 6 dyuan 2012-03-14 02:45:17 UTC
Verified PASS with libvirt-0.9.10-5.el6.

# virsh dumpxml rhel6 |grep -i memory
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>

Comment 7 Eric Blake 2012-03-14 02:53:22 UTC
(In reply to comment #6)
> Verified PASS with libvirt-0.9.10-5.el6.
> 
> # virsh dumpxml rhel6 |grep -i memory
>   <memory unit='KiB'>1048576</memory>
>   <currentMemory unit='KiB'>1048576</currentMemory>

It would also be worth testing the other improvements made in this patch, such as 'virsh setmem --size=900M' setting the size to 921600 KiB.

Comment 8 Alex Jia 2012-03-14 03:00:22 UTC
(In reply to comment #6)
> Verified PASS with libvirt-0.9.10-5.el6.
> 
> # virsh dumpxml rhel6 |grep -i memory
>   <memory unit='KiB'>1048576</memory>
>   <currentMemory unit='KiB'>1048576</currentMemory>

Yuandan, it seems patches of Comment 3 fix many places, including docs, and try different memory unit, so we probably also need to check them together, oh, Eric has commented this.

Regards,
Alex

Comment 9 dyuan 2012-03-14 03:48:39 UTC
Move back to ON_QA, and will continue to test the following items:
  blockResize: add flag for bytes
  docs: use correct terminology for 1024 bytes
  api: add overflow error
  util: new function for scaling numbers
  xml: share 'unit' in RNG
  xml: output memory unit for clarity
  storage: support more scaling suffixes
  xml: drop unenforced minimum memory limit from RNG
  xml: use long long internally, to centralize overflow checks
  xml: use better types for memory values
  xml: allow scaled memory on input
  virsh: add option aliases
  virsh: use option aliases
  virsh: add command aliases, and rename nodedev-detach
  virsh: improve storage unit parsing
  virsh: improve memory unit parsing

Comment 12 dyuan 2012-03-16 10:02:34 UTC
There are some issues in the following test:

15/16. error msg for --shrink option of vol-resize
# virsh vol-resize /var/lib/libvirt/images/rhel5.img 6000000000  --shrink
error: Failed to change size of volume 'rhel5.img' to 6000000000

error: invalid argument: storageVolumeResize: unsupported flags (0x4)

13/16. virsh: use option aliases
--tunneled can work well for migrate, but --read-bytes_sec doesn't work for blkdeviotune.

# virsh blkdeviotune  --read-bytes_sec
error: command 'blkdeviotune' doesn't support option --read-bytes_sec

# virsh blkdeviotune  --read-bytes-sec
error: expected syntax: --read-bytes-sec <number>

14/16. virsh: add command aliases, and rename nodedev-detach
show both detach command, saw that it's fixed on upstream but existing in rhel.

# virsh -h|grep nodedev-det
 Node Device (help keyword 'nodedev')
    nodedev-detach                 detach node device from its device driver
    nodedev-dettach                detach node device from its device driver


Others are okay for me:

6/16 xml: output memory unit for clarity

# virsh dumpxml rhel6 |grep -i mem

<memory unit='KiB'>2048576</memory>
  <currentMemory unit='KiB'>2049024</currentMemory>
  <memtune>
    <hard_limit unit='KiB'>512000</hard_limit>
    <soft_limit unit='KiB'>128000</soft_limit>
    <swap_hard_limit unit='KiB'>1024000</swap_hard_limit>
  </memtune>


1/16 blockResize: add flag for bytes
15/16  virsh: improve storage unit parsing

# virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size 5GB
Block device '/var/lib/libvirt/images/rhel62.img' is resized
# qemu-img info /var/lib/libvirt/images/rhel62.img
image: /var/lib/libvirt/images/rhel62.img
file format: raw
virtual size: 4.7G (5000000000 bytes)
disk size: 935M

# virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size 5GiB
Block device '/var/lib/libvirt/images/rhel62.img' is resized
# qemu-img info  /var/lib/libvirt/images/rhel62.img
image: /var/lib/libvirt/images/rhel62.img
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: 864M

# virsh vol-resize /var/lib/libvirt/images/rhel5.img 7G
Size of volume 'rhel5.img' successfully changed to 7G

# qemu-img info /var/lib/libvirt/images/rhel5.img
image: /var/lib/libvirt/images/rhel5.img
file format: raw
virtual size: 7.0G (7516192768 bytes)
disk size: 0

# virsh vol-resize /var/lib/libvirt/images/rhel5.img 7GB
Size of volume 'rhel5.img' successfully changed to 7GB

# qemu-img info /var/lib/libvirt/images/rhel5.img
image: /var/lib/libvirt/images/rhel5.img
file format: raw
virtual size: 6.5G (7000000000 bytes)
disk size: 0


# virsh vol-resize /var/lib/libvirt/images/rhel5.img 1GiB --delta
Size of volume 'rhel5.img' successfully changed by 1GiB

# qemu-img info /var/lib/libvirt/images/rhel5.img
image: /var/lib/libvirt/images/rhel5.img
file format: raw
virtual size: 7.5G (8073741824 bytes)
disk size: 0


11/16  xml: allow scaled memory on input
16/16  virsh: improve memory unit parsing

# virsh setmaxmem rhel55 4G

# virsh dumpxml rhel55 |grep -i mem
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>

# virsh setmaxmem rhel55 4GB

# virsh dumpxml rhel55 |grep -i mem
  <memory unit='KiB'>3906250</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>

# virsh dumpxml rhel55|grep -i memtune -A 3
  <memtune>
    <hard_limit unit='KiB'>512000</hard_limit>
    <soft_limit unit='KiB'>128000</soft_limit>
    <swap_hard_limit unit='KiB'>1024000</swap_hard_limit>
  </memtune>

# virsh memtune rhel55 --hard-limit 512M --soft-limit 512MB --swap-hard-limit 512MiB

# virsh dumpxml rhel55|grep -i memtune -A 3
  <memtune>
    <hard_limit unit='KiB'>524288</hard_limit>
    <soft_limit unit='KiB'>500000</soft_limit>
    <swap_hard_limit unit='KiB'>524288</swap_hard_limit>
  </memtune>

# virsh setmem rhel55 --size=512M

# virsh dumpxml rhel55|grep -i mem
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>524288</currentMemory>

# virsh setmem rhel55 --size=1G

[root@rhel62-release schemas]# virsh dumpxml rhel55|grep -i mem
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>

# virsh setmem rhel55 --size=1GB

# virsh dumpxml rhel55|grep -i mem
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>976564</currentMemory>

# virsh setmem rhel55 --size=1.5GB
error: memory size has to be a number

Comment 13 Eric Blake 2012-03-16 12:07:11 UTC
(In reply to comment #12)
> There are some issues in the following test:
> 
> 15/16. error msg for --shrink option of vol-resize
> # virsh vol-resize /var/lib/libvirt/images/rhel5.img 6000000000  --shrink
> error: Failed to change size of volume 'rhel5.img' to 6000000000
> 
> error: invalid argument: storageVolumeResize: unsupported flags (0x4)

Expected, and unrelated to this BZ - although the API allows --shrink, it has not yet been wired up and backported to RHEL.

> 
> 13/16. virsh: use option aliases
> --tunneled can work well for migrate, but --read-bytes_sec doesn't work for
> blkdeviotune.
> 
> # virsh blkdeviotune  --read-bytes_sec
> error: command 'blkdeviotune' doesn't support option --read-bytes_sec

Invalid, so the error is expected.  You can only use '--read-bytes-sec' (new preferred spelling) or '--read_bytes_sec' (deprecated but still supported spelling), but not a mix.

> 
> # virsh blkdeviotune  --read-bytes-sec
> error: expected syntax: --read-bytes-sec <number>

Invalid, so the error is expected.  You must supply an argument for --read-bytes-sec.

> 
> 14/16. virsh: add command aliases, and rename nodedev-detach
> show both detach command, saw that it's fixed on upstream but existing in rhel.
> 
> # virsh -h|grep nodedev-det
>  Node Device (help keyword 'nodedev')
>     nodedev-detach                 detach node device from its device driver
>     nodedev-dettach                detach node device from its device driver

Real bug; I fixed 'virsh help' but not 'virsh -h' to omit deprecated aliases.  I'll move this back to assigned; it should be a quick fix.

> Others are okay for me:

Good to hear.

> 
> 1/16 blockResize: add flag for bytes
> 15/16  virsh: improve storage unit parsing
> 
> # virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size 5GB

> # virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size
> 5GiB

Both of these blockresize commands happened to test a multiple of 1024 bytes, and therefore, while they tested the new virsh parsing of 15/16, they did not test the new bytes flag for 1/16.  You also want to test setting the size to something that is not a multiple of 1024.

> 
> # virsh setmem rhel55 --size=1.5GB
> error: memory size has to be a number

It might be nice to teach virsh to support fractional values, but I agree that the patch as-is did not do this, so this error is expected.

Comment 14 Eric Blake 2012-03-16 19:31:11 UTC
The fix for the one identified issue in QA testing is now pending upstream review:
https://www.redhat.com/archives/libvir-list/2012-March/msg00741.html

Comment 16 dyuan 2012-03-19 03:37:48 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > There are some issues in the following test:
> > 
> > 15/16. error msg for --shrink option of vol-resize
> > # virsh vol-resize /var/lib/libvirt/images/rhel5.img 6000000000  --shrink
> > error: Failed to change size of volume 'rhel5.img' to 6000000000
> > 
> > error: invalid argument: storageVolumeResize: unsupported flags (0x4)
> 
> Expected, and unrelated to this BZ - although the API allows --shrink, it has
> not yet been wired up and backported to RHEL.
>
No bug to track it in rhel, will fill a new one to rhel6.4.0.

> > 
> > 13/16. virsh: use option aliases
> > --tunneled can work well for migrate, but --read-bytes_sec doesn't work for
> > blkdeviotune.
> > 
> > # virsh blkdeviotune  --read-bytes_sec
> > error: command 'blkdeviotune' doesn't support option --read-bytes_sec
> 
> Invalid, so the error is expected.  You can only use '--read-bytes-sec' (new
> preferred spelling) or '--read_bytes_sec' (deprecated but still supported
> spelling), but not a mix.
> 
Sorry, I read it wrong in the patch.

> > 
> > # virsh blkdeviotune  --read-bytes-sec
> > error: expected syntax: --read-bytes-sec <number>
> 
> Invalid, so the error is expected.  You must supply an argument for
> --read-bytes-sec.
> 
> > 
> > 14/16. virsh: add command aliases, and rename nodedev-detach
> > show both detach command, saw that it's fixed on upstream but existing in rhel.
> > 
> > # virsh -h|grep nodedev-det
> >  Node Device (help keyword 'nodedev')
> >     nodedev-detach                 detach node device from its device driver
> >     nodedev-dettach                detach node device from its device driver
> 
> Real bug; I fixed 'virsh help' but not 'virsh -h' to omit deprecated aliases. 
> I'll move this back to assigned; it should be a quick fix.
> 
> > Others are okay for me:
> 
> Good to hear.
> 
> > 
> > 1/16 blockResize: add flag for bytes
> > 15/16  virsh: improve storage unit parsing
> > 
> > # virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size 5GB
> 
> > # virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size
> > 5GiB
> 
> Both of these blockresize commands happened to test a multiple of 1024 bytes,
> and therefore, while they tested the new virsh parsing of 15/16, they did not
> test the new bytes flag for 1/16.  You also want to test setting the size to
> something that is not a multiple of 1024.
> 

Tested it with size < 1024bytes, got the unmatched size with qemu-img.
Seems no issue related to libvirt when setting to sth not a multiple of 1024, will re-check it for qemu-img.

# virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size 900B
Block device '/var/lib/libvirt/images/rhel62.img' is resized

# qemu-img info /var/lib/libvirt/images/rhel62.img
image: /var/lib/libvirt/images/rhel62.img
file format: raw
virtual size: 512 (512 bytes)
disk size: 4.0K

# ll /var/lib/libvirt/images/rhel62.img -h
-rw-------. 1 qemu qemu 900 Mar 19 11:11 /var/lib/libvirt/images/rhel62.img

# virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size 1024B
Block device '/var/lib/libvirt/images/rhel62.img' is resized

# qemu-img info /var/lib/libvirt/images/rhel62.img
image: /var/lib/libvirt/images/rhel62.img
file format: raw
virtual size: 1.0K (1024 bytes)
disk size: 4.0K

# virsh blockresize rhel62 --path /var/lib/libvirt/images/rhel62.img --size 600B
Block device '/var/lib/libvirt/images/rhel62.img' is resized
# qemu-img info /var/lib/libvirt/images/rhel62.img
image: /var/lib/libvirt/images/rhel62.img
file format: raw
virtual size: 512 (512 bytes)
disk size: 4.0K

# ll /var/lib/libvirt/images/rhel62.img -h
-rw-------. 1 qemu qemu 600 Mar 19 11:09 /var/lib/libvirt/images/rhel62.img


> > 
> > # virsh setmem rhel55 --size=1.5GB
> > error: memory size has to be a number
> 
> It might be nice to teach virsh to support fractional values, but I agree that
> the patch as-is did not do this, so this error is expected.

Comment 17 dyuan 2012-03-19 06:58:19 UTC
Verified the virsh -h issue PASS with libvirt-0.9.10-6.el6.

# virsh -h |grep nodedev-det
    nodedev-detach                 detach node device from its device driver

and new bug 804516 is to track the --shrink issue.

Comment 18 Eric Blake 2012-03-30 17:38:04 UTC
This patch introduced a regression tracked in bug 808522

Comment 19 Eric Blake 2012-04-18 21:56:12 UTC
See also bug 813972 for a related patch to the same area of code.

Comment 20 Eric Blake 2012-05-03 19:34:28 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Previously, libvirt would output guest memory values in kibibytes (multiples of 1024), but with no indication of the scale.  Furthermore, the libvirt documentation referred to kilobytes (multiples of 1000).  Meanwhile, qemu defaults to mebibytes (multiples of 1024*1024), and these differences in scale could result in users making mistakes such as giving a guest 1000 times less memory than planned, with a failure mode that was not easy to diagnose.  Now the output is clear on the scale used, and the input allows user to use other scales that might be more convenient.

Comment 22 errata-xmlrpc 2012-06-20 06:49:03 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-2012-0748.html


Note You need to log in before you can comment on or make changes to this bug.