Bug 1177723

Summary: libvirt should set the old value if set the new failed when use domiftune
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, honzhang, mprivozn, mzhan, rbalakri
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.13-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:05:59 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 Luyao Huang 2014-12-30 05:29:57 UTC
description of problem:
libvirt should set the old value if set the new failed when use domiftune

Version-Release number of selected component (if applicable):
libvirt-1.2.8-11.el7.x86_64
iproute-3.10.0-21.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
 
1.prepare a running guest with NIC:
# virsh list
 Id    Name                            State
----------------------------------------------------
 2     test4                          running

2.use domiftune set inbound bandwidth to vm iface:
# virsh domiftune test4 vnet1 400,200,100
# virsh domiftune test4 vnet1
inbound.average: 400
inbound.peak   : 200
inbound.burst  : 100
outbound.average: 0
outbound.peak  : 0
outbound.burst : 0

3.check the rules via tc
# tc class show dev vnet1
class htb 1:1 root leaf 2: prio 0 rate 3200Kbit ceil 1600Kbit burst 100Kb cburst 1600b

4.set a invalid number via domiftune(make command failed)
# virsh domiftune test4 vnet1 400111111,200,100
error: Unable to set interface parameters
error: internal error: Child process (/sbin/tc class add dev vnet1 parent 1: classid 1:1 htb rate 400111111kbps ceil 200kbps burst 100kb) unexpected exit status 1: Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
...

5.old rules have been cleanup,but we still can get the old settings via domiftune:
# tc class show dev vnet1

# virsh domiftune test4 vnet1
inbound.average: 400
inbound.peak   : 200
inbound.burst  : 100
outbound.average: 0
outbound.peak  : 0
outbound.burst : 0

Actual results:
libvirt should set the old value if set the new failed when use domiftune
      
Expected results:
after set failed

# tc class show dev vnet1
class htb 1:1 root leaf 2: prio 0 rate 3200Kbit ceil 1600Kbit burst 100Kb cburst 1600b

Additional info:

Comment 1 Michal Privoznik 2015-01-06 12:39:30 UTC
I've just pushed the patch upstream:

commit 565d049fd1a4f3264a12001467a0bbf3b87a6421
Author:     Luyao Huang <lhuang>
AuthorDate: Wed Dec 31 09:34:39 2014 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Jan 6 13:27:43 2015 +0100

    qemu: Restore old bandwidth rules when setting new fails
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1177723
    
    When setting new bandwidth limits via
    virDomainSetInterfaceParameters, the old ones are cleared first.
    However, if setting the new ones fails, the old are already gone
    and interface is left in inconsistent state.  Therefore, right
    before failing we ought to try to restore the old bandwidth.
    
    Signed-off-by: Luyao Huang <lhuang>

Comment 3 hongming 2015-07-06 10:10:06 UTC
Verify it as follows. Move its status to VERIFIED.

[root@localhost images]# rpm -q libvirt
libvirt-1.2.17-1.el7.x86_64

[root@localhost images]# virsh start rhel7.0
Domain rhel7.0 started

[root@localhost images]# virsh domiflist rhel7.0
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    virtio      52:54:00:68:ce:60


[root@localhost images]# virsh domiftune rhel7.0 vnet0 400,200,100

[root@localhost images]# tc class show dev vnet0
class htb 1:1 root leaf 2: prio 0 rate 3200Kbit ceil 1600Kbit burst 100Kb cburst 1600b 


[root@localhost images]# virsh domiftune rhel7.0 vnet0 400111111,200,100
error: Unable to set interface parameters
error: internal error: Child process (/sbin/tc class add dev vnet0 parent 1: classid 1:1 htb rate 400111111kbps ceil 200kbps burst 100kb) unexpected exit status 1: Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio

[root@localhost images]# virsh domiftune rhel7.0 vnet0 400,200,45464646546
error: inbound rate larger than maximum 4294967295


[root@localhost images]# virsh domiftune rhel7.0 vnet0 400,400111111,100
error: Unable to set interface parameters
error: internal error: Child process (/sbin/tc class add dev vnet0 parent 1: classid 1:1 htb rate 400kbps ceil 400111111kbps burst 100kb) unexpected exit status 1: Illegal "ceil"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio


[root@localhost images]# virsh domiftune rhel7.0 vnet0
inbound.average: 400
inbound.peak   : 200
inbound.burst  : 100
outbound.average: 0
outbound.peak  : 0
outbound.burst : 0


[root@localhost images]# tc class show dev vnet0
class htb 1:1 root leaf 2: prio 0 rate 3200Kbit ceil 1600Kbit burst 100Kb cburst 1600b

Comment 5 errata-xmlrpc 2015-11-19 06:05:59 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