Hide Forgot
Description of problem: Changing --hard-limit with memtune report invalid error when --swap-hard-limit is unlimited. Version-Release number of selected component (if applicable): Red Hat Enterprise Linux Server release 7.0 Beta libvirt-1.1.1-10.el7.x86_64 How reproducible: always Command: 1. Prepare a running vm with unlimited memory. # virsh start <vm-name> 2. Check memtune status. # virsh memtune <vm-name> --live hard_limit : unlimited soft_limit : unlimited swap_hard_limit: unlimited 3. Try to change --hard-limit with memtune. # virsh memtune <vm-name> --hard-limit 100000000 --live Result: error: Unable to change memory parameters error: invalid argument: memory hard_limit tunable value must be lower than swap_hard_limit Expected result: Change hard limit successfully. Additional info: This only happens for new started VM. After change limits manually to 'unlimited' with: # virsh memtune <vm-name> --hard-limit -1 --swap-hard-limit -1 --live , memtune works fine with step 3.
In the following part of qemuDomainSetMemoryParameters() in src/qemu/qemu_driver.c , when the VM is fresh started, vm->def->mem.swap_hard_limit is 0, then the comparison is true. when --swap-hard-limit is manually set to -1, then vm->def->mem.swap_hard_limit is the maximum ulong, then this comparison is false. if (set_swap_hard_limit || set_hard_limit) { unsigned long long mem_limit = vm->def->mem.hard_limit; unsigned long long swap_limit = vm->def->mem.swap_hard_limit; if (set_swap_hard_limit) swap_limit = swap_hard_limit; if (set_hard_limit) mem_limit = hard_limit; if (virCompareLimitUlong(mem_limit, swap_limit) > 0) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("memory hard_limit tunable value must be lower " "than swap_hard_limit")); goto cleanup; } } So this might be caused by ambiguous representation of unlimited memory.
Need to adopt this patch from upstream: commit 19e7c04dce34afeb9a762471e09777de7d219db8 Author: Bing Bu Cao <mars.ibm.com> Date: Fri Oct 11 14:50:33 2013 +0800 util: fix two virCompareLimitUlong bugs The helper function virCompareLimitUlong compares limit values, where value of 0 is equal to unlimited. If the latter parameter is 0, it should return -1 instead of 1, hence the user can only set hard_limit whe swap_hard_limit currently is unlimited. Worse, all callers pass 2 64-bit values, but on 32-bit platforms, the second argument was silently truncated to 32 bits, which could lead to incorrect computations.
Thanks for the info, but unfortunately that's not enough since upstream is currently a bit broken as well.
Rest of the upstream code is waiting for review (don't mind the misleading subject): https://www.redhat.com/archives/libvir-list/2013-December/msg00434.html and https://www.redhat.com/archives/libvir-list/2013-December/msg00501.html
This fix is VERIFIED. Verification Steps: Same as https://bugzilla.redhat.com/show_bug.cgi?id=1024272#c0 In step 3: for libvirt-1.1.1-14.el7: # virsh memtune <vm-name> --live --hard-limit 100000000 error: Unable to change memory parameters error: invalid argument: memory hard_limit tunable value must be lower than swap_hard_limit for libvirt-1.1.1-15.el7: # virsh memtune <vm-name> --live --hard-limit 100000000 # virsh memtune <vm-name> --live hard_limit : 100000000 soft_limit : unlimited swap_hard_limit: unlimited So this bug is fixed and VERIFIED.
This request was resolved in Red Hat Enterprise Linux 7.0. Contact your manager or support representative in case you have further questions about the request.