Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1070680 - cpu-stats boundary value problem
cpu-stats boundary value problem
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Ján Tomko
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-02-27 06:01 EST by Jincheng Miao
Modified: 2015-03-05 02:30 EST (History)
7 users (show)

See Also:
Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-05 02:30:49 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 07:10:54 EST

  None (edit)
Description Jincheng Miao 2014-02-27 06:01:01 EST
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 11:00:59 EDT
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 04:53:28 EDT
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 10:32:44 EDT
The series is now pushed upstream, with this commit fixing the boundary check:
commit 9fe5267adecc6c87074ce673626a73ea4d9f2d6e
Author:     Ján Tomko <jtomko@redhat.com>
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 03:43:52 EST
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 05:25:16 EST
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 02:30:49 EST
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.