Bug 1224587

Summary: Improve error report for virsh allocpages command
Product: Red Hat Enterprise Linux 7 Reporter: vivian zhang <vivianzhang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, lhuang, mzhan, rbalakri
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.17-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:39:03 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 vivian zhang 2015-05-25 02:10:00 UTC
Description:
For virsh allocpages command, using some negative values test, report error should be improved

Version-Release number of selected component (if applicable):
libvirt-1.2.15-2.el7.x86_64
qemu-kvm-rhev-2.3.0-1.el7.x86_64
3.10.0-243.el7.x86_64


How reproducible:
100%

Steps:

1. check NUMA host virsh capabilities,two cells exist
# virsh capabilities |grep cell 
...
<cells num='2'>
        <cell id='0'>
          <memory unit='KiB'>67086628</memory>
          <pages unit='KiB' size='4'>16246345</pages>
          <pages unit='KiB' size='2048'>2</pages>
          <pages unit='KiB' size='1048576'>2</pages>
          <distances>
            <sibling id='0' value='10'/>
            <sibling id='1' value='11'/>
          </distances>
          <cpus num='8'>
            <cpu id='0' socket_id='0' core_id='1' siblings='0'/>
            <cpu id='1' socket_id='0' core_id='2' siblings='1'/>
            <cpu id='2' socket_id='0' core_id='8' siblings='2'/>
            <cpu id='3' socket_id='0' core_id='9' siblings='3'/>
            <cpu id='4' socket_id='0' core_id='16' siblings='4'/>
            <cpu id='5' socket_id='0' core_id='17' siblings='5'/>
            <cpu id='6' socket_id='0' core_id='18' siblings='6'/>
            <cpu id='7' socket_id='0' core_id='24' siblings='7'/>
          </cpus>
        </cell>
        <cell id='1'>
          <memory unit='KiB'>67108864</memory>
          <pages unit='KiB' size='4'>15996928</pages>
          <pages unit='KiB' size='2048'>500</pages>
          <pages unit='KiB' size='1048576'>2</pages>
          <distances>
            <sibling id='0' value='11'/>
            <sibling id='1' value='10'/>
          </distances>
          <cpus num='8'>
            <cpu id='8' socket_id='3' core_id='0' siblings='8'/>
            <cpu id='9' socket_id='3' core_id='1' siblings='9'/>
            <cpu id='10' socket_id='3' core_id='2' siblings='10'/>
            <cpu id='11' socket_id='3' core_id='8' siblings='11'/>
            <cpu id='12' socket_id='3' core_id='17' siblings='12'/>
            <cpu id='13' socket_id='3' core_id='18' siblings='13'/>
            <cpu id='14' socket_id='3' core_id='24' siblings='14'/>
            <cpu id='15' socket_id='3' core_id='25' siblings='15'/>
          </cpus>
        </cell>
      </cells>
...

2. allocate some pages for cell with positive values, command success
# virsh allocpages --pagesize 2048 --pagecount 5 --cellno 1

# virsh allocpages --pagesize 2048 --pagecount 4 --all

3. set cellno with negative value, for -1, no error report

# virsh allocpages --pagesize 2048 --pagecount 5 --cellno -1

# echo $?
0

3. set cellno with negative value, for -2 or others, error report, but it should be improved to show more clearly and reasonable

# virsh allocpages --pagesize 2048 --pagecount 5 --cellno -2
error: Failed to open file '/sys/devices/system/node/node-2/hugepages/hugepages-2048kB/nr_hugepages': No such file or directory

[root@ibm-x3850x5-04 ~]# echo $?
1

4. the same error as below should be improved also
# virsh allocpages --pagesize 2049 --pagecount 4   <---- pagesize 2049 not supported, but report error should be improved
error: Failed to open file '/sys/kernel/mm/hugepages/hugepages-2049kB/nr_hugepages': No such file or directory

# virsh allocpages --pagesize -1 --pagecount 4    
error: pagesize has to be a number
error: numerical overflow: value too large: 18446744073709551615


# virsh allocpages --pagesize 2048 --pagecount -1 --cellno 0
error: pagecount has to be a number


Actual result:
Report errors are not suitable

Expect result:
Report error for virsh allocpages should be improved more clearly

Comment 2 Michal Privoznik 2015-06-08 12:41:33 UTC
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2015-June/msg00310.html

Comment 3 Michal Privoznik 2015-06-10 15:47:59 UTC
Patch pushed upstream:

commit 1c24cfe9d8016f7561af7b295835f4d1973243b2
Author:     Michal Privoznik <mprivozn>
AuthorDate: Mon Jun 8 14:05:25 2015 +0200
Commit:     Michal Privoznik <mprivozn>
CommitDate: Wed Jun 10 17:27:16 2015 +0200

    virNumaSetPagePoolSize: Produce friendlier error message
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1224587
    
    The function takes two important arguments (among many others): @node
    and @page_size. From these two a path under /sys is constructed. The
    path is then used to read and write the desired size of huge pages
    pool. However, if the path does not exists due to either @node or
    @page_size having nonexistent value (e.g. there's no such NUMA node or
    no page size like -2), an cryptic error message is produced:
    
      virsh # allocpages --pagesize 2049 --pagecount 8 --cellno -2
      error: Failed to open file '/sys/devices/system/node/node-2/hugepages/hugepages-2049kB/nr_hugepages': No such file or directory
    
    Add two more checks to catch this and therefore produce much more
    friendlier error messages.
    
    Signed-off-by: Michal Privoznik <mprivozn>

v1.2.16-122-g1c24cfe

Comment 5 Luyao Huang 2015-07-13 09:11:53 UTC
I can reproduce this issue with libvirt-1.2.15-2.el7.x86_64:

1.
# virsh allocpages --cellno -2 --pagesize 2048 --pagecount 1
error: Failed to open file '/sys/devices/system/node/node-2/hugepages/hugepages-2048kB/nr_hugepages': No such file or directory

2.
# virsh allocpages --cellno 0 --pagesize 2049 --pagecount 1
error: Failed to open file '/sys/devices/system/node/node0/hugepages/hugepages-2049kB/nr_hugepages': No such file or directory

3.
# virsh allocpages --cellno 0 --pagesize -1 --pagecount 1
error: pagesize has to be a number
error: numerical overflow: value too large: 18446744073709551615

4.
# virsh allocpages --cellno 0 --pagesize 2048 --pagecount -1
error: pagecount has to be a number


And verify this bug with libvirt-1.2.17-2.el7.x86_64:

1. 
# virsh allocpages --cellno -2 --pagesize 2048 --pagecount 1
error: operation failed: NUMA node -2 is not available

2.
# virsh allocpages --cellno 0 --pagesize 2049 --pagecount 1
error: operation failed: page size or NUMA node not available

3.
# virsh allocpages --cellno 0 --pagesize -1 --pagecount 1
error: Numeric value '-1' for <pagesize> option is malformed or out of range

4.
# virsh allocpages --cellno 0 --pagesize 2048 --pagecount -1
error: Numeric value '-1' for <pagecount> option is malformed or out of range

Comment 8 errata-xmlrpc 2015-11-19 06:39: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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html