Bug 1022292 - libvirt should check the value range of average element in <outbound> before updating interface device
libvirt should check the value range of average element in <outbound> before ...
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: Michal Privoznik
Virtualization Bugs
:
Depends On:
Blocks: 1022293
  Show dependency treegraph
 
Reported: 2013-10-22 21:48 EDT by Hu Jianwei
Modified: 2016-04-26 10:52 EDT (History)
5 users (show)

See Also:
Fixed In Version: libvirt-1.2.17-5.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1022293 (view as bug list)
Environment:
Last Closed: 2015-11-19 00:44:18 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)

  None (edit)
Description Hu Jianwei 2013-10-22 21:48:34 EDT
Description of problem:
During testing, libvirt should check the value range of average element in <outbound> before updating device, also the values of average element in <outbound> should be consistent with <inbound>, libvirt had better report "error: internal error: cannot set bandwidth limits on vnet0". 

Version-Release number of selected component (if applicable):
libvirt-1.1.1-9.el7.x86_64
qemu-kvm-rhev-1.5.3-9.el7.x86_64
kernel-3.10.0-34.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. [root@localhost ~]# cat nic.xml 
<interface type='network'>
      <mac address='52:54:00:90:06:7a'/>
      <source network='default'/>
      <model type='virtio'/>
      <bandwidth>
          <outbound average='-1' peak='5000' burst='1024'/>           <===set negative for <outbound>, same value in <inbound> will be failed.
      </bandwidth>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
[root@localhost ~]# virsh update-device r6 nic.xml 
Device updated successfully

[root@localhost ~]# virsh dumpxml r6 | grep interface -A10
    <interface type='network'>
      <mac address='52:54:00:90:06:7a'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <bandwidth>
        <outbound average='18446744073709551615' peak='5000' burst='1024'/>        <======libvirt will convert the negative to positive number. 
      </bandwidth>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
...

2. [root@localhost ~]# cat nic.xml 
<interface type='network'>
      <mac address='52:54:00:90:06:7a'/>
      <source network='default'/>
      <model type='virtio'/>
      <bandwidth>
          <outbound average='10000000000000000' peak='5000' burst='1024'/>   <===========set a huge value for average of <outbound>, same value in <inbound> will be failed.
      </bandwidth>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
[root@localhost ~]# virsh update-device r6 nic.xml 
Device updated successfully

[root@localhost ~]# virsh dumpxml r6 | grep interface -A10
    <interface type='network'>
      <mac address='52:54:00:90:06:7a'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <bandwidth>
        <outbound average='10000000000000000' peak='5000' burst='1024'/>
      </bandwidth>
...

Actual results:
As above steps.

Expected results:
Same behavior with <inbound> element, see below [other info].

Other info:
1. Negative value
[root@localhost ~]# cat nic.xml 
<interface type='network'>
      <mac address='52:54:00:90:06:7a'/>
      <source network='default'/>
      <model type='virtio'/>
      <bandwidth>
          <inbound average='-1' peak='5000' burst='1024'/>
      </bandwidth>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

[root@localhost ~]# virsh update-device r6 nic.xml 
error: Failed to update device from nic.xml
error: internal error: cannot set bandwidth limits on vnet0

2.huge value
[root@localhost ~]# cat nic.xml 
<interface type='network'>
      <mac address='52:54:00:90:06:7a'/>
      <source network='default'/>
      <model type='virtio'/>
      <bandwidth>
          <inbound average='10000000000000000' peak='5000' burst='1024'/>
      </bandwidth>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
[root@localhost ~]# virsh update-device r6 nic.xml 
error: Failed to update device from nic.xml
error: internal error: cannot set bandwidth limits on vnet0
Comment 3 Michal Privoznik 2013-11-28 06:12:25 EST
BTW I think this bug is not limited to <outbound> only. Any xml knob that takes an integer is affected.
Comment 8 Michal Privoznik 2015-08-07 11:31:58 EDT
Patch has been proposed upstream:

https://www.redhat.com/archives/libvir-list/2015-August/msg00232.html
Comment 11 hongming 2015-09-02 02:42:42 EDT
Verify it as follows. The result is expected. Move its status to VERIFIED.


1.Test every value of QoS attribute using the negative value. 

# virsh edit r7.1

    <interface type='network'>
      <mac address='52:54:00:5a:ab:c5'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='-1000' peak='5000' floor='200' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>


error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]: 

2.
# cat nic.xml 
<interface type='network'>
      <mac address='52:54:00:5a:ab:c5'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='1000' peak='5000' floor='-200' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>


# virsh list
 Id    Name                           State
----------------------------------------------------
 5     r7.1                           running

# virsh update-device r7.1 nic.xml 
error: Failed to update device from nic.xml
error: unsupported configuration: could not convert bandwidth floor value '-200'


3. 
# cat r7.1-n.xml|grep /interface -B11
    <interface type='network'>
      <mac address='52:54:00:5a:ab:c5'/>
      <source network='default' bridge='virbr0'/>
      <bandwidth>
        <inbound average='-1000' peak='5000' floor='200' 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 define r7.1-n.xml
error: Failed to define domain from r7.1-n.xml
error: unsupported configuration: could not convert bandwidth average value '-1000'
Comment 13 errata-xmlrpc 2015-11-19 00:44:18 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/RHBA-2015-2202.html

Note You need to log in before you can comment on or make changes to this bug.