Bug 1454709

Summary: delete the Qos settings for the interface on the fly makes no changes
Product: Red Hat Enterprise Linux 7 Reporter: yalzhang <yalzhang>
Component: libvirtAssignee: Laine Stump <laine>
Status: CLOSED ERRATA QA Contact: yalzhang <yalzhang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: chhu, jdenemar, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-4.3.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 09:49:58 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 yalzhang@redhat.com 2017-05-23 11:27:58 UTC
Description of problem:
Delete the Qos settings for the interface on the fly makes no changes, as the traffic control rules still exists.

Version-Release number of selected component (if applicable):
libvirt-3.2.0-5.el7.x86_64
qemu-kvm-rhev-2.9.0-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

1. bandwidth set in interface
# virsh dumpxml rhel7 | grep /interface -B11
    <interface type='network'>
      <mac address='52:54:00:1e:42:96'/>
      <source network='default' bridge='virbr0'/>
      <bandwidth>
        <inbound average='1000' peak='5000' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

# virsh net-dumpxml default
<network connections='1'>
  <name>default</name>
  <uuid>ec95afa8-2529-4e3f-b98c-82cfde363cfd</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:82:0b:86'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.100'/>
    </dhcp>
  </ip>
</network>

2. 
#  tc class show dev vnet0
class htb 1:1 root leaf 2: prio 0 rate 8000Kbit ceil 40000Kbit burst 1Mb cburst 1600b

#  tc filter show dev vnet0 parent ffff:
filter protocol all pref 49152 u32
filter protocol all pref 49152 u32 fh 800: ht divisor 1
filter protocol all pref 49152 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid :1
  match 00000000/00000000 at 0
 police 0xf rate 1024Kbit burst 256Kb mtu 64Kb action drop overhead 0b
ref 1 bind 1

3. delete the Qos settings by update-device, the command succeed.
# cat nobound.xml
  <interface type='network'>
      <mac address='52:54:00:1e:42:96'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

# virsh update-device rhel7 nobound.xml
Device updated successfully

# virsh dumpxml rhel7 | grep /interface -B7
    <interface type='network'>
      <mac address='52:54:00:1e:42:96'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

4. Even the command succeed, the rules still exists, and the bandwidth limitation still works.
#  tc filter show dev vnet0 parent ffff:
filter protocol all pref 49152 u32
filter protocol all pref 49152 u32 fh 800: ht divisor 1
filter protocol all pref 49152 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid :1
  match 00000000/00000000 at 0
 police 0xf rate 1024Kbit burst 256Kb mtu 64Kb action drop overhead 0b
ref 1 bind 1

#  tc class show dev vnet0
class htb 1:1 root leaf 2: prio 0 rate 8000Kbit ceil 40000Kbit burst 1Mb cburst 1600b

Actual results:
in step 4, all the rules still exists.

Expected results:
in step 4, all the rules should be deleted as there are no traffic control.

Additional info:
When there is no Qos settings for the interface, add Qos settings by update-device works.

Comment 2 yalzhang@redhat.com 2017-11-27 02:55:35 UTC
*** Bug 1516686 has been marked as a duplicate of this bug. ***

Comment 3 Laine Stump 2017-12-13 19:25:12 UTC
Fix posted upstream:

https://www.redhat.com/archives/libvir-list/2017-December/msg00481.html

Comment 4 Laine Stump 2017-12-14 19:44:33 UTC
Pushed upstream (will be in 4.0.0):

commit b21163bd119446dcbadab7523b1dc8dab487a571
Author: Laine Stump <laine>
Date:   Mon Dec 11 14:26:54 2017 -0500

    qemu: delete exist [sic] bandwidth restrictions when they are removed from config

Comment 6 yalzhang@redhat.com 2018-05-30 02:34:42 UTC
test on libvirt-4.3.0-1.el7.x86_64, the result is as expected, set this bug to be verified.

1. Prepare a running vm with network type interface defined with bandwidth just like comment 0, and check by tc, the rules exists;
2. Copy the interface section to a file, and delete the bandwidth section;
3. Do update-device with the xml in step2 to delete the Qos setting;
4. Check by tc, the rules are deleted as well.

And test below scenarios:
Delete the inbound and outbound one by one --> PASS
After delete the Qos setting, restart libvirtd ----> PASS
Test for direct type interface ---> PASS
Delete the Qos setting by domiftune ---> PASS
Add the Qos setting by domiftune ---> PASS
Add the Qos setting by update-device ---> PASS

Details:
1. # virsh dumpxml rhel | grep /interface -B12
<interface type='network'>
      <mac address='52:54:00:ab:8c:39'/>
      <source network='default' bridge='virbr0'/>
      <bandwidth>
        <inbound average='500' peak='600' burst='128'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
#  tc class show dev vnet0
class htb 1:1 root leaf 2: prio 0 rate 4Mbit ceil 4800Kbit burst 128Kb cburst 1599b 
# tc filter show dev vnet0 parent ffff: 
filter protocol all pref 49152 u32 
filter protocol all pref 49152 u32 fh 800: ht divisor 1 
filter protocol all pref 49152 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid :1 not_in_hw 
  match 00000000/00000000 at 0
 police 0x2 rate 1024Kbit burst 256Kb mtu 64Kb action drop overhead 0b 
	ref 1 bind 1

2. # cat  inter.xml
<interface type='network'>
      <mac address='52:54:00:ab:8c:39'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

3. # virsh update-device rhel inter.xml
Device updated successfully

4. # virsh dumpxml rhel | grep /interface -B12  
====> no bandwidth setting
# tc filter show dev vnet0 parent ffff:
#
#  tc class show dev vnet0
#

Comment 8 errata-xmlrpc 2018-10-30 09:49:58 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://access.redhat.com/errata/RHSA-2018:3113