Skip to content

Commit c793bfa

Browse files
committed
virt: fix partial QoS removal
Since commit 50cd770, vdsm uses the old bandwidth value when updating (the QoS) on the NIC. Now lets say we have the following active on a VM NIC: <bandwidth> <inbound average="128000" peak="384000" burst="1024000" /> <outbound average="128000" burst="1024000" peak="384000" /> </bandwidth> And we pass the following update from the engine: <bandwidth> <outbound average="128000" burst="1024000" peak="384000"/> </bandwidth> Then it will preserve the inbound QoS, which is not something we want. This is a leftover from pre 'libvirt XML' oVirt era. Cause before it needed an empty 'inbound' tag to make the inbound QoS to get removed. See the notes in the above commit: 'It is deleted if it is in specParams but empty ({'inbound':{}}).' But as the complete XML is now passed to vdsm, we can just rely on the data coming from the engine, without the need to parse the old bandwidth data. Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
1 parent d0edfe6 commit c793bfa

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

lib/vdsm/virt/vmdevices/network.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,12 @@ def _filter_parameter_map(self):
302302
yield parameter['name'], parameter['value']
303303

304304
@staticmethod
305-
def get_bandwidth_xml(specParams, oldBandwidth=None):
305+
def get_bandwidth_xml(specParams):
306306
"""Returns a valid libvirt xml dom element object."""
307307
bandwidth = vmxml.Element('bandwidth')
308-
old = {} if oldBandwidth is None else dict(
309-
(vmxml.tag(elem), elem)
310-
for elem in vmxml.children(oldBandwidth))
311308
for key in ('inbound', 'outbound'):
312309
elem = specParams.get(key)
313-
if elem is None: # Use the old setting if present
314-
if key in old:
315-
bandwidth.appendChild(etree_element=old[key])
316-
elif elem:
310+
if elem:
317311
# Convert the values to string for adding them to the XML def
318312
attrs = dict((key, str(value)) for key, value in elem.items())
319313
bandwidth.appendChildWithArgs(key, **attrs)
@@ -487,7 +481,7 @@ def update_bandwidth_xml(iface, vnicXML, specParams=None):
487481
vmxml.remove_child(vnicXML, oldBandwidth)
488482
if (specParams and
489483
('inbound' in specParams or 'outbound' in specParams)):
490-
newBandwidth = iface.get_bandwidth_xml(specParams, oldBandwidth)
484+
newBandwidth = iface.get_bandwidth_xml(specParams)
491485
vmxml.append_child(vnicXML, newBandwidth)
492486

493487

tests/virt/device_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def testInterfaceXMLBandwidthUpdate(self):
126126
iface = vmdevices.network.Interface(self.log, **dev)
127127
orig_bandwidth = iface.getXML().findall('bandwidth')[0]
128128
self.assert_dom_xml_equal(orig_bandwidth, originalBwidthXML)
129-
bandwith = iface.get_bandwidth_xml(NEW_OUT, orig_bandwidth)
129+
bandwith = iface.get_bandwidth_xml(NEW_OUT)
130130
self.assert_dom_xml_equal(bandwith, updatedBwidthXML)
131131

132132
def testInterfaceFilterUpdate(self):

0 commit comments

Comments
 (0)