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 1145048 - freepages argument has wrong unit and range
Summary: freepages argument has wrong unit and range
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-22 09:30 UTC by Jincheng Miao
Modified: 2015-03-05 07:45 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.2.8-6.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 07:45:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description Jincheng Miao 2014-09-22 09:30:21 UTC
description of problem:
The unit of argument '--pagesize' for freepages is kibibytes, but it treats it as bytes
And '--pagesize' should only accept positive number.

version:
libvirt-1.2.8-2.el7.x86_64
qemu-kvm-rhev-2.1.0-3.el7.x86_64

How reproducible:
100%

step to reproduce:
1. check free 2M memory page
# virsh freepages --cellno -1 --pagesize 2048
error: Failed to open file '/sys/kernel/mm/hugepages/hugepages-2kB/free_hugepages': No such file or directory

# virsh help freepages
  NAME
    freepages - NUMA free pages

  SYNOPSIS
    freepages [--cellno <number>] [--pagesize <number>] [--all]

  DESCRIPTION
    display available free pages for the NUMA cell.

  OPTIONS
    --cellno <number>  NUMA cell number
    --pagesize <number>  page size (in kibibytes)
    --all            show free pages for all NUMA cells

2. pass negative number to '--pagesize'
# virsh freepages --cellno -1 --pagesize -2048
error: page size has to be a number
error: numerical overflow: value too large: 18446744073709549568

Expect result:
1. # virsh freepages --cellno -1 --pagesize 2048
2048KiB: 250

2. # virsh freepages --cellno -1 --pagesize -2048
error: page size must be positive.

Comment 2 Michal Privoznik 2014-09-23 08:29:43 UTC
I've just pushed patches upstream:

commit c46fa72e4090b7884b8c6edaf63f1638eb8e04f8
Author:     Jincheng Miao <jmiao>
AuthorDate: Mon Sep 22 18:14:28 2014 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Sep 23 10:23:20 2014 +0200

    Fix typo of virNodeGetFreePages comment
    
    Signed-off-by: Jincheng Miao <jmiao>

commit 7db19366423dcab388907c12caf766c6e5870d00
Author:     Jincheng Miao <jmiao>
AuthorDate: Mon Sep 22 18:14:27 2014 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Sep 23 10:23:20 2014 +0200

    nodeinfo: report error when given node is out of range
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1145050
    
    Signed-off-by: Jincheng Miao <jmiao>
    Signed-off-by: Michal Privoznik <mprivozn>

commit c3e2d5929c1bfaaeb2ef2df121dc90d767b228f5
Author:     Jincheng Miao <jmiao>
AuthorDate: Mon Sep 22 18:14:26 2014 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Sep 23 10:23:20 2014 +0200

    virsh-host: fix pagesize unit of freepages
    
    The unit of '--pagesize' of freepages is kibibytes.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1145048
    
    Signed-off-by: Jincheng Miao <jmiao>
    Signed-off-by: Michal Privoznik <mprivozn>

v1.2.8-230-gc46fa72

Comment 5 Hu Jianwei 2014-10-15 03:42:20 UTC
Maybe we need blow two upstream patches:

[hujianwei@localhost libvirt]$ git show 8baf0f02
commit 8baf0f025f975267e3f9a3af71f69137130907b7
Author: Jincheng Miao <jmiao>
Date:   Wed Sep 24 13:45:30 2014 +0800

    nodeinfo: fix nodeGetFreePages when max node is zero
    
    In nodeGetFreePages, if startCell is given by '0',
    and the max node number is '0' too. The for-loop
    wouldn't be executed.
    So convert it to while-loop.
    
    Before:
    > virsh freepages --cellno 0 --pagesize 4
    error: internal error: no suitable info found
    
    After:
    > virsh freepages --cellno 0 --pagesize 4
    4KiB: 472637
    
    Signed-off-by: Jincheng Miao <jmiao>
    Signed-off-by: Michal Privoznik <mprivozn>

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2459922..04ae382 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -2043,7 +2043,7 @@ nodeGetFreePages(unsigned int npages,
 
     lastCell = MIN(lastCell, startCell + cellCount);
 
-    for (cell = startCell; cell < lastCell; cell++) {
+    for (cell = startCell; cell <= lastCell; cell++) {
         for (i = 0; i < npages; i++) {
             unsigned int page_size = pages[i];
             unsigned int page_free;

[hujianwei@localhost libvirt]$ git show  4aa8a68faa8
commit 4aa8a68faa86d6e1c6ecaeabcec487ee30eff813
Author: Michal Privoznik <mprivozn>
Date:   Wed Sep 24 15:10:18 2014 +0200

    nodeGetFreePages: Push forgotten change
    
    In the previous patch I've changed the for loop bounds but forgot
    to 'git add' changes that adapt the rest of the code.
    
    Signed-off-by: Michal Privoznik <mprivozn>

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 04ae382..3bc0c3c 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -2041,7 +2041,7 @@ nodeGetFreePages(unsigned int npages,
         goto cleanup;
     }
 
-    lastCell = MIN(lastCell, startCell + cellCount);
+    lastCell = MIN(lastCell, startCell + (int) cellCount - 1);
 
     for (cell = startCell; cell <= lastCell; cell++) {
         for (i = 0; i < npages; i++) {

Before the patches:
[root@ibm-x3850x5-05 ~]# rpm -q libvirt
libvirt-1.2.8-5.el7.x86_64

[root@ibm-x3850x5-05 ~]# numactl --hard
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23
node 0 size: 65514 MB
node 0 free: 62986 MB
node 1 cpus: 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31
node 1 size: 65536 MB
node 1 free: 62785 MB
node distances:
node   0   1 
  0:  10  11 
  1:  11  10 
[root@ibm-x3850x5-05 ~]# virsh freepages --all
Node 0:
4KiB: 16124187
2048KiB: 0

error: internal error: no suitable info found

[root@ibm-x3850x5-05 ~]# virsh freepages --cellno 1 --pagesize 4
error: internal error: no suitable info found

After applying the patches:
[root@ibm-x3850x5-06 x86_64]# rpm -q libvirt
libvirt-1.2.8-5.el7_jiahu.x86_64
[root@ibm-x3850x5-06 x86_64]# virsh freepages --all
Node 0:
4KiB: 3626649
2048KiB: 0

Node 1:
4KiB: 3829784
2048KiB: 0


[root@ibm-x3850x5-06 x86_64]# virsh freepages --cellno 1 --pagesize 4
4KiB: 3829836

Comment 6 Michal Privoznik 2014-10-15 10:11:52 UTC
Yeah, so moving to POST again:

http://post-office.corp.redhat.com/archives/rhvirt-patches/2014-October/msg00372.html

Comment 8 Jincheng Miao 2014-11-06 05:51:16 UTC
The unit of pagesize is already fix in latest libvirt-1.2.8-6.el7:

# rpm -q libvirt
libvirt-1.2.8-6.el7.x86_64

# virsh freepages --cellno -1 --pagesize 4
4KiB: 1119867

# virsh freepages --cellno -1 --pagesize 4k
4KiB: 1119580

# virsh freepages --cellno -1 --pagesize 1G
1048576KiB: 2

# virsh freepages --cellno 0 --pagesize 1G
1048576KiB: 2

# virsh freepages --cellno 1 --pagesize 1G
error: internal error: start cell 1 out of range (0-0)


There is a little problem is that reporting numerical overflow for negative pagesize:
# virsh freepages --cellno -1 --pagesize -4
error: page size has to be a number
error: numerical overflow: value too large: 18446744073709551612

I had filed a bug https://bugzilla.redhat.com/show_bug.cgi?id=1159171 for it,
so change this status to VERIFIED.

Comment 10 errata-xmlrpc 2015-03-05 07:45:00 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-2015-0323.html


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