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 1070680 - cpu-stats boundary value problem
Summary: cpu-stats boundary value problem
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-02-27 11:01 UTC by Jincheng Miao
Modified: 2015-03-05 07:30 UTC (History)
7 users (show)

Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 07:30:49 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-02-27 11:01:01 UTC
Description of problem:
virsh cpu-stats has boundary value problem, the argument --start should be
a valid CPU id. But if --start is $MAX_CPU_ID + 1, no error is reported.


Version-Release number of selected component (if applicable):
libvirt-1.1.1-25.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. check valid cpu id
# lspcu | grep "CPU(s)"
CPU(s):                8
On-line CPU(s) list:   0-7

So the max cpu id is 7.

2. pass 8 to --start
# virsh cpu-stats r7 --start 8

# echo $?
0

# virsh cpu-stats r7 --start 9
error: Failed to retrieve CPU statistics for domain 'r7'
error: invalid argument: start_cpu 9 larger than maximum of 8

# echo $?
1

Expect results:
# virsh cpu-stats r7 --start 8
error: Failed to retrieve CPU statistics for domain 'r7'
error: invalid argument: start_cpu 8 larger than maximum of 7

Comment 1 Ján Tomko 2014-04-03 15:00:59 UTC
Upstream patch has been posted by Jincheng Miao in February:
https://www.redhat.com/archives/libvir-list/2014-February/msg01579.html

Comment 2 Ján Tomko 2014-04-04 08:53:28 UTC
I've sent a series fixing the problem and cleaning up the function:
https://www.redhat.com/archives/libvir-list/2014-April/msg00172.html

Comment 3 Ján Tomko 2014-04-09 14:32:44 UTC
The series is now pushed upstream, with this commit fixing the boundary check:
commit 9fe5267adecc6c87074ce673626a73ea4d9f2d6e
Author:     Ján Tomko <jtomko>
CommitDate: 2014-04-09 16:24:08 +0200

    Check maximum startcpu value correctly
    
    The cpus are indexed from 0, so a startcpu value equal
    to the number of CPUs is invalid.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1070680

git describe: v1.2.3-103-g9fe5267

Comment 5 vivian zhang 2014-11-26 08:43:52 UTC
I can produce this bug on build libvirt-1.1.1-23.el7.x86_64

verify it on build
libvirt-1.2.8-9.el7.x86_64
qemu-kvm-rhev-2.1.2-12.el7.x86_64
kernel-3.10.0-208.el7.x86_64

verify steps:
1. check valid cpu id
# lscpu |grep CPU
CPU op-mode(s):        32-bit, 64-bit
CPU(s):                8
On-line CPU(s) list:   0-7
CPU family:            6
Model name:            Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
CPU MHz:               3878.921
NUMA node0 CPU(s):     0-7

so the max cpu id is 7

2. get cpu stats start from 8, error reported to inform maximum is 7
# virsh cpu-stats rhel7new --start 8
error: Failed to retrieve CPU statistics for domain 'rhel7new'
error: invalid argument: start_cpu 8 larger than maximum of 7

# echo $?
1

3. get cpu stats start from 7, return value is normal
# virsh cpu-stats rhel7new --start 7
CPU7:
	cpu_time             0.358009875 seconds
	vcpu_time            0.000042752 seconds

# echo $?
0

4. try more 
# virsh cpu-stats rhel7new --start 9
error: Failed to retrieve CPU statistics for domain 'rhel7new'
error: invalid argument: start_cpu 9 larger than maximum of 7

Comment 6 vivian zhang 2014-11-26 10:25:16 UTC
5. verify more steps about cpu-stats
# virsh cpu-stats rhel7new --start 7 --total
CPU7:
	cpu_time             0.418870727 seconds
	vcpu_time            0.000000000 seconds
Total:
	cpu_time            25.916091411 seconds
	user_time            2.800000000 seconds
	system_time          4.220000000 seconds


[root@server images]# virsh cpu-stats rhel7new --start 7 --total --count 0
Total:
	cpu_time            26.096086335 seconds
	user_time            2.800000000 seconds
	system_time          4.230000000 seconds

[root@server images]# virsh cpu-stats rhel7new --start 7 --total --count 1
CPU7:
	cpu_time             0.418979441 seconds
	vcpu_time            0.000000000 seconds
Total:
	cpu_time            26.115569245 seconds
	user_time            2.800000000 seconds
	system_time          4.230000000 seconds

[root@server images]# virsh cpu-stats rhel7new --start 2 --total --count 3
CPU2:
	cpu_time             2.835158656 seconds
	vcpu_time            1.799808960 seconds
CPU3:
	cpu_time             3.713079677 seconds
	vcpu_time            3.231146174 seconds
CPU4:
	cpu_time             3.254891858 seconds
	vcpu_time            2.849673348 seconds
Total:
	cpu_time            26.151207055 seconds
	user_time            2.810000000 seconds
	system_time          4.230000000 seconds

[root@server images]# virsh cpu-stats rhel7new --start 2 --total --count 8
CPU2:
	cpu_time             2.836865893 seconds
	vcpu_time            1.799808960 seconds
CPU3:
	cpu_time             3.723412885 seconds
	vcpu_time            3.235013680 seconds
CPU4:
	cpu_time             3.262947951 seconds
	vcpu_time            2.849673348 seconds
CPU5:
	cpu_time             3.709556985 seconds
	vcpu_time            3.500103878 seconds
CPU6:
	cpu_time             0.011104798 seconds
	vcpu_time            0.000921704 seconds
CPU7:
	cpu_time             0.418979441 seconds
	vcpu_time            0.000000000 seconds
Total:
	cpu_time            26.178165567 seconds
	user_time            2.810000000 seconds
	system_time          4.230000000 seconds

[root@server images]# virsh cpu-stats rhel7new --start 9 --count 8
error: Failed to retrieve CPU statistics for domain 'rhel7new'
error: invalid argument: start_cpu 9 larger than maximum of 7

[root@server images]# virsh cpu-stats rhel7new --start 7 --count 8
CPU7:
	cpu_time             2.124014381 seconds
	vcpu_time            1.585571433 seconds

[root@server images]# virsh cpu-stats rhel7new --start 7 --count 0

[root@server images]# virsh cpu-stats rhel7new --start 7 --count 1
CPU7:
	cpu_time             2.144098909 seconds
	vcpu_time            1.585571433 seconds

[root@server images]# virsh cpu-stats rhel7new --start 7 --count 3333
Only 8 CPUs available to show
CPU7:
	cpu_time             2.144098909 seconds
	vcpu_time            1.585571433 seconds
[root@server images]# virsh cpu-stats rhel7new --start 7 --count aa
error: Unable to parse integer parameter for CPUs to show

[root@server images]# virsh cpu-stats rhel7new --start a
error: Unable to parse integer parameter for start

above steps are all right behaviour about cpu-stats
move to verified

Comment 8 errata-xmlrpc 2015-03-05 07:30:49 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.