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 1131306 - number range should be checked for the 4 new options of blkiotune
Summary: number range should be checked for the 4 new options of blkiotune
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Martin Kletzander
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-19 01:23 UTC by Luyao Huang
Modified: 2015-03-05 07:42 UTC (History)
7 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:42:39 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 Luyao Huang 2014-08-19 01:23:46 UTC
description of problem:
number range should be checked for the 4 new options of blkiotune

Version-Release number of selected component (if applicable):
libvirt-1.2.7-1.el7.x86_64
kernel-3.10.0-140.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.# virsh list --all
 Id    Name                           State
----------------------------------------------------
 5     test3                          running

2.# virsh blkiotune test3
weight         : 14
device_weight  :
device_read_iops_sec:
device_write_iops_sec:
device_read_bytes_sec:
device_write_bytes_sec:

3.# virsh blkiotune test3 --device-read-iops-sec /dev/sda,12

4.# virsh blkiotune test3
weight         : 14
device_weight  :
device_read_iops_sec: /dev/sda,12
device_write_iops_sec:
device_read_bytes_sec:
device_write_bytes_sec:

5.# cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\x2dtest3.scope/blkio.throttle.read_iops_device
8:0 12


5.# virsh blkiotune test3 --device-read-iops-sec /dev/sda,-2

6..# virsh blkiotune test3
weight         : 14
device_weight  :
device_read_iops_sec: /dev/sda,4294967294
device_write_iops_sec:
device_read_bytes_sec:
device_write_bytes_sec:

7.# cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\x2dtest3.scope/blkio.throttle.read_iops_device
8:0 4294967294

8.# virsh blkiotune test6 --device-read-bytes-sec /dev/sda,-2

9.# virsh blkiotune test6
weight         : 14
device_weight  : 
device_read_iops_sec: 
device_write_iops_sec: /dev/sda,4294967294
device_read_bytes_sec: /dev/sda,18446744073709551614
device_write_bytes_sec: 

10.# cat blkio.throttle.read_bps_device
8:0 18446744073709551614



Actual results:
Can give a negative number to new 4 options(device_read_iops_sec,device_write_iops_sec,device_read_bytes_sec,device_write_bytes_sec),and nagative number will transform a positive number.

Expected results:
blkiotune should check range for new options,we shouldn't allow a nagative number

Additional info:
also i have found -1 maybe a special number to this options(it will change it to unlimited):
# virsh blkiotune test6 --device-read-bytes-sec /dev/sda,-1

# virsh blkiotune test6
weight         : 10
device_weight  : 
device_read_iops_sec: 
device_write_iops_sec: /dev/sda,4294967294
device_read_bytes_sec: /dev/sda,18446744073709551615
device_write_bytes_sec: 

# cat blkio.throttle.read_bps_device

# virsh blkiotune test6 --device-read-bytes-sec /dev/sda,0

# virsh blkiotune test6
weight         : 10
device_weight  : 
device_read_iops_sec: 
device_write_iops_sec: /dev/sda,4294967294
device_read_bytes_sec:
device_write_bytes_sec: 

# cat blkio.throttle.read_bps_device

Comment 2 Martin Kletzander 2014-08-19 13:12:30 UTC
Fix proposed upstream:

https://www.redhat.com/archives/libvir-list/2014-August/msg00795.html

Comment 3 Martin Kletzander 2014-08-20 11:14:44 UTC
Fixed upstream by v1.2.7-182-ge80adb0 and v1.2.7-183-g970ac2a:

commit 970ac2a0fe19eb6088fb4cd8b982014ee9b143dc
Author: Martin Kletzander <mkletzan>
Date:   Tue Aug 19 14:54:30 2014 +0200

    qemu: forbid negative blkio values

commit e80adb0ed51c8533d7fbcaf8438a9de1e4fa51af
Author: Martin Kletzander <mkletzan>
Date:   Tue Aug 19 14:54:24 2014 +0200

    lxc: forbid negative blkio values

Comment 5 zhengqin 2014-09-11 03:05:17 UTC
Verify this issue with build libvirt-1.2.8-1.el7.x86_64:


Steps to verify:
1.# virsh list --all
 Id    Name                           State
----------------------------------------------------
 5     test3                          running

2.# virsh blkiotune test3
weight         : 500
device_weight  : 
device_read_iops_sec: /dev/sda,12
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: 

3.# virsh blkiotune test3 --device-read-iops-sec /dev/sda,12

4.# virsh blkiotune test3
weight         : 500
device_weight  : 
device_read_iops_sec: /dev/sda,12
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: 

5. #  cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dtest3.scope/blkio.throttle.read_iops_device 
8:0 12

6. # virsh blkiotune test3 --device-read-iops-sec /dev/sda,-2
error: Unable to change blkio parameters
error: invalid argument: unable to parse blkio device 'device_read_iops_sec' '/dev/sda,-2'


7.# virsh blkiotune test3
weight         : 500
device_weight  : 
device_read_iops_sec: /dev/sda,12
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: 


8. # cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dtest3.scope/blkio.throttle.read_iops_device 
8:0 12


9. # virsh blkiotune test3 --device-read-bytes-sec /dev/sda,-2
error: Unable to change blkio parameters
error: invalid argument: unable to parse blkio device 'device_read_bytes_sec' '/dev/sda,-2'

10.# virsh blkiotune test3
weight         : 500
device_weight  : 
device_read_iops_sec: /dev/sda,12
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: 

11. #cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dtest3.scope/blkio.throttle.read_bps_device

12. # virsh blkiotune test3 --device-read-bytes-sec /dev/sda,-1
error: Unable to change blkio parameters
error: invalid argument: unable to parse blkio device 'device_read_bytes_sec' '/dev/sda,-1'


13. # virsh blkiotune test3 
weight         : 500
device_weight  : 
device_read_iops_sec: /dev/sda,12
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: 


14. #virsh blkiotune test3 --device-read-bytes-sec /dev/sda,0

15. # virsh blkiotune test3 
weight         : 500
device_weight  : 
device_read_iops_sec: /dev/sda,12
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: 

16. # cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dtest3.scope/blkio.throttle.read_bps_device

Comment 6 zhengqin 2014-09-11 03:10:47 UTC
Could reproduce this issue with build libvirt-1.2.7-1.el7.x86_64 as bug description mentioned.

Comment 7 Pei Zhang 2014-10-24 06:18:50 UTC
varify version :
libvirt-1.2.8-5.el7.x86_64
qemu-kvm-rhev-2.1.2-4.el7.x86_64
kernel-3.10.0-191.el7.x86_64

steps:
1. set a negative value
[root@184 images]# virsh blkiotune r7 --device-read-bytes-sec /dev/sda,-1
error: Unable to change blkio parameters
error: invalid argument: unable to parse blkio device 'device_read_bytes_sec' '/dev/sda,-1'

2. set a non-numeric value
[root@184 images]# virsh blkiotune r7 --device-read-bytes-sec /dev/sda,aa
error: Unable to change blkio parameters
error: invalid argument: unable to parse blkio device 'device_read_bytes_sec' '/dev/sda,aa'

3. try to set iops to max value

3.1) set value=4294967294 , set successfully. and can be checked in cgroup.
[root@184 images]# virsh blkiotune r7 --device-read-iops-sec /dev/sda,4294967294

[root@184 images]# cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dr7.scope/blkio.throttle.read_iops_device
8:0 4294967294

3.2)  set value=4294967295 , set successfully. but can not be checked in cgroup.
[root@184 images]# virsh blkiotune r7 --device-read-iops-sec /dev/sda,4294967295

[root@184 images]# cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dr7.scope/blkio.throttle.read_iops_device
[root@184 images]#
3.3)  set value=4294967296 , set failed.
[root@184 images]# virsh blkiotune r7 --device-read-iops-sec /dev/sda,4294967296
error: Unable to change blkio parameters
error: invalid argument: unable to parse blkio device 'device_read_iops_sec' '/dev/sda,4294967296'


4. try to set bytes to max value.

4.1) set value=18446744073709551614 , set successfully. and can be checked in cgroup
[root@184 images]# cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dr7.scope/blkio.throttle.read_bps_device
8:0 18446744073709551614

4.2) set value=18446744073709551615 , set successfully. but can not  be checked in cgroup
[root@184 images]# virsh blkiotune r7 --device-read-bytes-sec /dev/sda,18446744073709551615

[root@184 images]# cat /sys/fs/cgroup/blkio/machine.slice/machine-qemu\\x2dr7.scope/blkio.throttle.read_bps_device

4.3) set value=18446744073709551616 ,set failed.
[root@184 images]# virsh blkiotune r7 --device-read-bytes-sec /dev/sda,18446744073709551616
error: Unable to change blkio parameters
error: invalid argument: unable to parse blkio device 'device_read_bytes_sec' '/dev/sda,18446744073709551616'

5. dumpxml to check value. it has the value in the domain XML.

[root@184 images]# virsh dumpxml r7 | grep blkiotune -A8
  <blkiotune>
    <device>
      <path>/dev/sda</path>
      <weight>100</weight>
      <read_iops_sec>4294967295</read_iops_sec>
      <read_bytes_sec>18446744073709551615</read_bytes_sec>
    </device>
  </blkiotune>


Note: in the step 3.2 and 4.2 , the value can be set successfully and checked using blkiotune and also in doamin XML , but actually it can not be set in cgroup . Is it right?

and if it's better to give error message as a range ,
like : parameter xxx valid value from 0 to xxx.

Comment 8 Martin Kletzander 2014-10-29 15:36:15 UTC
We can't use an error message with the range as the range might differ based on kernel/qemu/etc.

Anyway, negative values could yield better error.  I'll post a fix soon.

Comment 9 Martin Kletzander 2014-11-04 09:54:58 UTC
Fixed upstream with v1.2.10-6-g278bf0a and v1.2.10-7-gb3880bb:

commit 278bf0acbfe9d468dceafde580ecce97ba9cc4e5
Author:     Martin Kletzander <mkletzan>
AuthorDate: Wed Oct 29 16:36:39 2014 +0100

    qemu: improve error message for invalid blkiotune settings

commit b3880bbe97bd0881d7860cff25c1409e74f2e9ab
Author:     Martin Kletzander <mkletzan>
AuthorDate: Wed Oct 29 16:36:39 2014 +0100

    lxc: improve error message for invalid blkiotune settings

Comment 12 Martin Kletzander 2014-11-18 16:19:56 UTC
Of course if there is a value set behind libvirt's back, you won't be able to check it in the XML.

To properly work with the limits, we might read those values back after writing them to make sure we output the right value (for example if UINT_MAX means the same as 0 for the kernel), just to make sure we cope exactly, however, that is something completely unrelated to this bug and might be done later on, but not now as it's very low priority.

Comment 13 Pei Zhang 2014-11-19 09:30:23 UTC
varify version :
kernel-3.10.0-203.el7.x86_64
qemu-kvm-rhev-2.1.2-8.el7.x86_64
libvirt-1.2.8-6.el7.x86_64

steps:
1.prepare a running guest 
# virsh list
 Id    Name                           State
----------------------------------------------------
 27    r7                         running

2.check blkiotune 
# virsh blkiotune r7 
weight         : 500
device_weight  : 
device_read_iops_sec: 
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: 

3. set negative value 

# virsh blkiotune r7  --device-write-iops-sec /dev/sda,-1
error: Unable to change blkio parameters
error: invalid argument: invalid value '-1' for parameter 'device_write_iops_sec' of device '/dev/sda'

# virsh blkiotune r7  --device-read-iops-sec /dev/sda,-1
error: Unable to change blkio parameters
error: invalid argument: invalid value '-1' for parameter 'device_read_iops_sec' of device '/dev/sda'

# virsh blkiotune r7-dir  --device-read-iops-sec /dev/sda,0

# virsh blkiotune r7  --device-read-bytes-sec /dev/sda,aaa
error: Unable to change blkio parameters
error: invalid argument: invalid value 'aaa' for parameter 'device_read_bytes_sec' of device '/dev/sda'

# virsh blkiotune r7  --device-write-iops-sec /dev/sda,10,/dev/sdb,-1
error: Unable to change blkio parameters
error: invalid argument: invalid value '-1' for parameter 'device_write_iops_sec' of device '/dev/sdb'

# virsh blkiotune r7  --device-write-bytes-sec /dev/sda,1000

# virsh blkiotune r7 
weight         : 500
device_weight  : 
device_read_iops_sec: 
device_write_iops_sec: 
device_read_bytes_sec: 
device_write_bytes_sec: /dev/sda,1000

can't set negative value any more , move this bug to verified.


and thanks for Martin's help , according to comment 7 and comment 12 .
open a new bug 1165580 on 7.2 to trace the question about properly working with the limits .

Comment 15 errata-xmlrpc 2015-03-05 07:42:39 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.