Skip to content

Commit ade627e

Browse files
dupondjemz-pdm
authored andcommitted
virt: remove bandwidth limit on nic update
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 <[email protected]>
1 parent d206f0b commit ade627e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/vdsm/virt/vmdevices/network.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,12 @@ def update_port_xml(vnicXML, port_isolated):
482482

483483

484484
def update_bandwidth_xml(iface, vnicXML, specParams=None):
485+
oldBandwidth = vmxml.find_first(vnicXML, 'bandwidth', None)
486+
if oldBandwidth is not None:
487+
vmxml.remove_child(vnicXML, oldBandwidth)
485488
if (specParams and
486489
('inbound' in specParams or 'outbound' in specParams)):
487-
oldBandwidth = vmxml.find_first(vnicXML, 'bandwidth', None)
488490
newBandwidth = iface.get_bandwidth_xml(specParams, oldBandwidth)
489-
if oldBandwidth is not None:
490-
vmxml.remove_child(vnicXML, oldBandwidth)
491491
vmxml.append_child(vnicXML, newBandwidth)
492492

493493

tests/virt/devicexml_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ def test_update_bandwidth_xml(self, base_spec_params):
162162
vmdevices.network.update_bandwidth_xml(dev, vnic_xml, specParams)
163163
self.assertXMLEqual(xmlutils.tostring(vnic_xml), XML)
164164

165+
specParams = {}
166+
XML = u"""
167+
<interface type='network'>
168+
<mac address="fake" />
169+
<source bridge='default'/>
170+
<link state="up"/>
171+
</interface>
172+
"""
173+
vmdevices.network.update_bandwidth_xml(dev, vnic_xml, specParams)
174+
self.assertXMLEqual(xmlutils.tostring(vnic_xml), XML)
175+
165176

166177
@expandPermutations
167178
class ParsingHelperTests(XMLTestCase):

0 commit comments

Comments
 (0)