Bug 1245476

Summary: error not right when set memtune but get failed
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, mzhan, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:20:04 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 Luyao Huang 2015-07-22 07:24:00 UTC
Description of problem:
error not right when set memtune but get failed

Version-Release number of selected component (if applicable):

libvirt-1.2.17-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.
prepare a running guest:

# virsh list
 Id    Name                           State
----------------------------------------------------
 13    rhel7.0-rhel                   running


2. set some invalid memory hard limit :

# virsh memtune rhel7.0-rhel 1
error: Unable to change memory parameters
error: unable to set memory hard_limit tunable: Operation not permitted

3. check the log:

2015-07-22 07:13:14.560+0000: 28633: error : virCgroupSetValueStr:735 : Unable to write to '/sys/fs/cgroup/memory/machine.slice/machine-qemu\x2drhel7.0\x2drhel.scope/memory.limit_in_bytes': Device or resource busy
2015-07-22 07:13:14.560+0000: 28633: error : qemuDomainSetMemoryParameters:9909 : unable to set memory hard_limit tunable: Operation not permitted

Actual results:

memtune report Operation not permitted but should be Device or resource busy

Expected results:

not cover the error from the virCgroup*:
Unable to write to '/sys/fs/cgroup/memory/machine.slice/machine-qemu\x2drhel7.0\x2drhel.scope/memory.limit_in_bytes': Device or resource busy

or just:
unable to set memory hard_limit tunable: Device or resource busy

Additional info:


We will report the error in the cgroup code after commit 0d7f45a, so the cgroup function will return -1, and as 1 is defined as:

#define EPERM        1  /* Operation not permitted */

so we will always report Operation not permitted.

Comment 1 Luyao Huang 2015-07-22 07:37:36 UTC
I have sent a patch to upstream:

http://www.redhat.com/archives/libvir-list/2015-July/msg00831.html

Comment 2 Peter Krempa 2015-07-22 10:10:53 UTC
Fixed upstream:

commit 704cf06a14ca92dcb9be2c3db6bdf1b21f02e1f7
Author: Luyao Huang <lhuang>
Date:   Wed Jul 22 15:35:14 2015 +0800

    qemu: fix the error cover issue in SetMemoryParameters
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1245476
    
    We won't return the errno after commit 0d7f45ae, and
    the more clearly error will be set in the code in vircgroup*.
    Also We will always report error "Operation not permitted",
    because the return is -1.
    
    Signed-off-by: Luyao Huang <lhuang>

v1.2.17-158-g704cf06

Comment 5 Luyao Huang 2016-06-01 08:19:20 UTC
Verify this bug on libvirt-1.3.4-1.el7.x86_64:

1. prepare a running guest:

# virsh  list --all
 Id    Name                           State
----------------------------------------------------
 56    rhel72-test                    running


2. set set guest memory hard limit with a too small value:

# virsh memtune rhel72-test 1
error: Unable to change memory parameters
error: Unable to write to '/sys/fs/cgroup/memory/machine.slice/machine-qemu\x2d56\x2drhel72\x2dtest.scope/memory.limit_in_bytes': Device or resource busy

3. check libvirtd log:

2016-06-01 08:12:02.349+0000: 8702: error : virCgroupSetValueStr:788 : Unable to write to '/sys/fs/cgroup/memory/machine.slice/machine-qemu\x2d56\x2drhel72\x2dtest.scope/memory.limit_in_bytes': Device or resource busy

Comment 7 errata-xmlrpc 2016-11-03 18:20:04 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.

https://rhn.redhat.com/errata/RHSA-2016-2577.html