Bug 680190

Summary: unable to set swap_hard_limit tunable by virsh memtune
Product: Red Hat Enterprise Linux 6 Reporter: Alex Jia <ajia>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: ajia, dyuan, eblake, jdenemar, jyang, llim, treydock, xen-maint, yoyzhang
Target Milestone: rcKeywords: Documentation
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.8.7-16.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-19 13:28:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alex Jia 2011-02-24 15:48:54 UTC
Description of problem:
Unable to set swap_hard_limit tunable by virsh memtune, but it is okay if directly edit guest xml configuration.

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

# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.145.el6.x86_64

# uname -r
2.6.32-113.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. virsh start domainname
2. virsh memtune domainname --swap-hard-limit size(kb)

  
Actual results:
# virsh memtune vr-rhel6-x86_64-kvm --swap-hard-limit 65536
error: Unable to change memory parameters
error: unable to set swap_hard_limit tunable: Invalid argument



Expected results:
can to set swap_hard_limit tunable by virsh command

Additional info:
# virsh start vr-rhel6-x86_64-kvm
Domain vr-rhel6-x86_64-kvm started

# virsh memtune vr-rhel6-x86_64-kvm
hard_limit     : unlimited
soft_limit     : unlimited
swap_hard_limit: unlimited

and can get these values via cgget:

# cgget -nr memory.limit_in_bytes libvirt/qemu/vr-rhel6-x86_64-kvm
memory.limit_in_bytes=9223372036854775807

# cgget -nr memory.soft_limit_in_bytes libvirt/qemu/vr-rhel6-x86_64-kvm
memory.soft_limit_in_bytes=9223372036854775807

# cgget -nr memory.memsw.limit_in_bytes libvirt/qemu/vr-rhel6-x86_64-kvm
memory.memsw.limit_in_bytes=9223372036854775807

# virsh memtune vr-rhel6-x86_64-kvm --swap-hard-limit 65536
error: Unable to change memory parameters
error: unable to set swap_hard_limit tunable: Invalid argument


But it's okay if directly edit guest xml configuration and add <memtune> block xml into guest xml:

# virsh edit vr-rhel6u1-x86_64-kvm

# virsh dumpxml vr-rhel6u1-x86_64-kvm
......
  <memory>2097152</memory>
  <currentMemory>1048576</currentMemory>
  <memtune>
    <hard_limit>512000</hard_limit>
    <soft_limit>128000</soft_limit>
    <swap_hard_limit>1024000</swap_hard_limit>
  </memtune>
  <vcpu>1</vcpu>
......

# virsh start vr-rhel6u1-x86_64-kvm
Domain vr-rhel6u1-x86_64-kvm started

# virsh memtune vr-rhel6u1-x86_64-kvm
hard_limit     : 512000 kB
soft_limit     : 128000 kB
swap_hard_limit: 1024000 kB

# cgget -nr memory.limit_in_bytes libvirt/qemu/vr-rhel6u1-x86_64-kvm
memory.limit_in_bytes=524288000

# cgget -nr memory.soft_limit_in_bytes libvirt/qemu/vr-rhel6u1-x86_64-kvm
memory.soft_limit_in_bytes=131072000

# cgget -nr memory.memsw.limit_in_bytes libvirt/qemu/vr-rhel6u1-x86_64-kvm
memory.memsw.limit_in_bytes=1048576000

Comment 1 Osier Yang 2011-03-02 09:44:17 UTC
Too small value is given for "swap hard limit".

virsh # start test
Domain test started

virsh # memtune test
hard_limit     : unlimited
soft_limit     : unlimited
swap_hard_limit: unlimited

virsh # memtune test --hard-limit 1024000

virsh # memtune test --swap-hard-limit 1023000
error: Unable to change memory parameters
error: unable to set swap_hard_limit tunable: Invalid argument

virsh # memtune test --swap-hard-limit 1024000

virsh # memtune test --swap-hard-limit 1024001

virsh # memtune test
hard_limit     : 1024000 kB
soft_limit     : unlimited
swap_hard_limit: 1024004 kB

virsh # memtune test --swap-hard-limit 1023999

virsh # memtune test
hard_limit     : 1024000 kB
soft_limit     : unlimited
swap_hard_limit: 1024000 kB

NB, 1024001 is rounded up to 1024004, 1023999 is rounded up to 1024000.

I beleive if you set value of "<swap_hard_limit>" smaller than of "<hard_limit>", same error will be raised up.

Note that "memsw" means "memory+swap", so, somehow it's NOTABUG, but probly we need doc improvements.

Comment 2 Osier Yang 2011-03-31 09:11:53 UTC
upstream 78ba748ef1 fix the document problem.

Comment 3 Jiri Denemark 2011-03-31 09:35:38 UTC
The upstream commit

commit 78ba748ef14c520ff1c4af2b5b0a44586ac49c8c
Author: Nikunj A. Dadhania <nikunj.ibm.com>
Date:   Wed Mar 16 10:37:12 2011 +0530

    virsh: fix memtune's help message for swap_hard_limit

is incomplete and needs a follow-up patch.

Comment 4 Jiri Denemark 2011-03-31 09:53:46 UTC
The follow-up patch has been sent upstream: https://www.redhat.com/archives/libvir-list/2011-March/msg01506.html

Comment 7 Alex Jia 2011-04-14 09:41:29 UTC
# virsh memtune rhel6_x86_64_kvm
error: Unable to get number of memory parameters
error: this function is not supported by the connection driver: qemuDomainGetMemoryParameters


Current kvm hypervisor doesn't support the function, Is this a expected result? 

Additional info:

# virsh list 
 Id Name                 State
----------------------------------
  2 rhel6_x86_64_kvm     running

# virsh dominfo rhel6_x86_64_kvm
Id:             2
Name:           rhel6_x86_64_kvm
UUID:           82092589-bce2-6e75-ecd4-d0ffa9e36651
OS Type:        hvm
State:          running
CPU(s):         1
CPU time:       37.1s
Max memory:     524288 kB
Used memory:    524288 kB
Persistent:     yes
Autostart:      disable
Security model: selinux
Security DOI:   0
Security label: system_u:system_r:svirt_t:s0:c17,c124 (enforcing)

# uname -r
2.6.32-130.el6.x86_64

# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.153.el6.x86_64

# rpm -q libvirt
libvirt-0.8.7-16.el6.x86_64

Comment 8 Jiri Denemark 2011-04-15 12:43:41 UTC
No, that's not expected. Are you sure you are running the right libvirtd version? virsh memtune works as expected for me with the latest
libvirt-0.8.7-17.el6 package.

Comment 9 Alex Jia 2011-04-18 05:40:57 UTC
(In reply to comment #8)
> No, that's not expected. Are you sure you are running the right libvirtd
> version? virsh memtune works as expected for me with the latest
> libvirt-0.8.7-17.el6 package.

Hi Jiri,
I saw 'Fixed In Version: libvirt-0.8.7-16.el6' on the right top, so I used -16 version to verify the bug, please update 'Fixed In Version' for the bug.

And will use -17 to verify the bug again.

Alex

Comment 10 Alex Jia 2011-04-18 07:00:33 UTC
The bug has been verified on rhel6.1 snapshot3(2.6.32-130.el6.x86_64) with libvirt-0.8.7-17.el6.x86_64.

# virsh start rhel6_x86_64_kvm
Domain rhel6_x86_64_kvm started

# virsh memtune rhel6_x86_64_kvm
hard_limit     : unlimited
soft_limit     : unlimited
swap_hard_limit: unlimited

# virsh memtune rhel6_x86_64_kvm --hard-limit 1024000

# virsh memtune rhel6_x86_64_kvm
hard_limit     : 1024000 kB
soft_limit     : unlimited
swap_hard_limit: unlimited


# virsh memtune rhel6_x86_64_kvm --swap-hard-limit 1024000

# virsh memtune rhel6_x86_64_kvm
hard_limit     : 1024000 kB
soft_limit     : unlimited
swap_hard_limit: 1024000 kB

# virsh memtune rhel6_x86_64_kvm --swap-hard-limit 1024001

[root@localhost Libvirt]# virsh memtune rhel6_x86_64_kvm
hard_limit     : 1024000 kB
soft_limit     : unlimited
swap_hard_limit: 1024004 kB

# virsh memtune rhel6_x86_64_kvm --swap-hard-limit 1023999

# virsh memtune rhel6_x86_64_kvm
hard_limit     : 1024000 kB
soft_limit     : unlimited
swap_hard_limit: 1024000 kB

Comment 11 Jiri Denemark 2011-04-18 07:33:30 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > No, that's not expected. Are you sure you are running the right libvirtd
> > version? virsh memtune works as expected for me with the latest
> > libvirt-0.8.7-17.el6 package.
> 
> Hi Jiri,
> I saw 'Fixed In Version: libvirt-0.8.7-16.el6' on the right top, so I used -16
> version to verify the bug, please update 'Fixed In Version' for the bug.

It should also work with -16 and even older packages. The only thing we fixed for this BZ was documentation of memtune command and that was done in -16 so Fixed In Version is correct. Since you got an error about unsupported qemuDomainGetMemoryParameters API, an ancient libvirtd must have been running.

Comment 14 errata-xmlrpc 2011-05-19 13:28:13 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0596.html

Comment 15 Trey Dockendorf 2011-10-22 19:45:29 UTC
This still seems to be a problem in 0.8.7-18.  The memtune function does not seem supported.

# virsh memtune store_0
error: Unable to get number of memory parameters
error: this function is not supported by the connection driver: qemuDomainGetMemoryParameters


# virsh dominfo store_0
Id:             4
Name:           store_0
UUID:           2b4b0dab-4160-d396-34be-10572b478dd6
OS Type:        hvm
State:          running
CPU(s):         1
CPU time:       153.4s
Max memory:     2048000 kB
Used memory:    2048000 kB
Persistent:     yes
Autostart:      disable
Security model: selinux
Security DOI:   0
Security label: system_u:system_r:svirt_t:s0:c194,c863 (enforcing)

# uname -r
2.6.32-131.17.1.el6.x86_64

# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.160.el6_1.8.x86_64

# rpm -q libvirt
libvirt-0.8.7-18.el6_1.1.x86_64