Skip to content

Commit

Permalink
virt: remove bandwidth limit on nic update
Browse files Browse the repository at this point in the history
This patch fixes some logic error in the update_bandwidth_xml function.
If you have a running VM with a NIC that has a QoS, it will contain a
bandwidth setting in the XML.
Now if you change the NIC to a vNIC Profile without QoS, it will not
contain the 'inbound' and 'outbound' specParams, and the old QoS will
never get removed (only after stop/start).

So we take the removal of the bandwidth out of the if so the limit gets
cleared correctly.

Also adds test for this case.

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
  • Loading branch information
dupondje authored and mz-pdm committed May 27, 2024
1 parent d206f0b commit ade627e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/vdsm/virt/vmdevices/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,12 @@ def update_port_xml(vnicXML, port_isolated):


def update_bandwidth_xml(iface, vnicXML, specParams=None):
oldBandwidth = vmxml.find_first(vnicXML, 'bandwidth', None)
if oldBandwidth is not None:
vmxml.remove_child(vnicXML, oldBandwidth)
if (specParams and
('inbound' in specParams or 'outbound' in specParams)):
oldBandwidth = vmxml.find_first(vnicXML, 'bandwidth', None)
newBandwidth = iface.get_bandwidth_xml(specParams, oldBandwidth)
if oldBandwidth is not None:
vmxml.remove_child(vnicXML, oldBandwidth)
vmxml.append_child(vnicXML, newBandwidth)


Expand Down
11 changes: 11 additions & 0 deletions tests/virt/devicexml_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ def test_update_bandwidth_xml(self, base_spec_params):
vmdevices.network.update_bandwidth_xml(dev, vnic_xml, specParams)
self.assertXMLEqual(xmlutils.tostring(vnic_xml), XML)

specParams = {}
XML = u"""
<interface type='network'>
<mac address="fake" />
<source bridge='default'/>
<link state="up"/>
</interface>
"""
vmdevices.network.update_bandwidth_xml(dev, vnic_xml, specParams)
self.assertXMLEqual(xmlutils.tostring(vnic_xml), XML)


@expandPermutations
class ParsingHelperTests(XMLTestCase):
Expand Down

0 comments on commit ade627e

Please sign in to comment.