Skip to content

Commit 3f56e44

Browse files
committed
vif: Resolve a TODO and update another
Once TODO noted that a block could be removed once we bump to libvirt 1.3.8 or greater. We require 3.0.0 now so that's resolved. Another one looks like it should be resolved in 3.2.0 so the TODO is updated to highlight this for future reviewers. Change-Id: I5235751b1dbc77ecc919eec7f3e022cd70085051 Signed-off-by: Stephen Finucane <[email protected]>
1 parent b4f3b2b commit 3f56e44

File tree

2 files changed

+14
-30
lines changed

2 files changed

+14
-30
lines changed

nova/tests/unit/virt/libvirt/test_vif.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -975,38 +975,29 @@ def test_generic_driver_bridge(self):
975975
@mock.patch.object(pci_utils, 'get_vf_num_by_pci_address', return_value=1)
976976
@mock.patch('nova.privsep.linux_net.set_device_macaddr')
977977
@mock.patch('nova.privsep.linux_net.set_device_macaddr_and_vlan')
978-
def _test_hw_veb_op(self, op, vlan, mock_set_macaddr_and_vlan,
979-
mock_set_macaddr, mock_get_vf_num,
980-
mock_get_ifname):
978+
def test_unplug_hw_veb(self, mock_set_macaddr_and_vlan,
979+
mock_set_macaddr, mock_get_vf_num,
980+
mock_get_ifname):
981+
d = vif.LibvirtGenericVIFDriver()
981982
mock_get_ifname.side_effect = ['eth1', 'eth13']
982-
port_state = 'up' if vlan > 0 else 'down'
983-
mac = ('00:00:00:00:00:00' if op.__name__ == 'unplug'
984-
else self.vif_hw_veb_macvtap['address'])
985983
calls = {
986984
'get_ifname':
987985
[mock.call(self.vif_hw_veb_macvtap['profile']['pci_slot'],
988986
pf_interface=True),
989987
mock.call(self.vif_hw_veb_macvtap['profile']['pci_slot'])],
990988
'get_vf_num':
991989
[mock.call(self.vif_hw_veb_macvtap['profile']['pci_slot'])],
992-
'set_macaddr': [mock.call('eth13', mac, port_state=port_state)]
990+
'set_macaddr': [mock.call(
991+
'eth13', '00:00:00:00:00:00', port_state='down')]
993992
}
994-
op(self.instance, self.vif_hw_veb_macvtap)
993+
994+
d.unplug(self.instance, self.vif_hw_veb_macvtap)
995+
995996
mock_get_ifname.assert_has_calls(calls['get_ifname'])
996997
mock_get_vf_num.assert_has_calls(calls['get_vf_num'])
997998
mock_set_macaddr.assert_has_calls(calls['set_macaddr'])
998999
mock_set_macaddr_and_vlan.assert_called_once_with(
999-
'eth1', 1, mock.ANY, vlan)
1000-
1001-
def test_plug_hw_veb(self):
1002-
d = vif.LibvirtGenericVIFDriver()
1003-
self._test_hw_veb_op(
1004-
d.plug,
1005-
self.vif_hw_veb_macvtap['details'][network_model.VIF_DETAILS_VLAN])
1006-
1007-
def test_unplug_hw_veb(self):
1008-
d = vif.LibvirtGenericVIFDriver()
1009-
self._test_hw_veb_op(d.unplug, 0)
1000+
'eth1', 1, mock.ANY, 0)
10101001

10111002
@mock.patch('nova.network.linux_net.set_vf_trusted')
10121003
def test_plug_hw_veb_trusted(self, mset_vf_trusted):

nova/virt/libvirt/vif.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ def set_vf_interface_vlan(pci_addr, mac_addr, vlan=0):
110110

111111
# Bring up/down the VF's interface
112112
# TODO(edand): The mac is assigned as a workaround for the following issue
113-
# https://bugzilla.redhat.com/show_bug.cgi?id=1372944
114-
# once resolved it will be removed
113+
# https://bugzilla.redhat.com/show_bug.cgi?id=1415609 and should be removed
114+
# once we bump the libvirt minimum to 3.2.0, as noted in
115+
# https://bugzilla.redhat.com/show_bug.cgi?id=1372944
115116
port_state = 'up' if vlan > 0 else 'down'
116117
nova.privsep.linux_net.set_device_macaddr(vf_ifname, mac_addr,
117118
port_state=port_state)
@@ -640,15 +641,7 @@ def plug_ib_hostdev(self, instance, vif):
640641
instance=instance)
641642

642643
def plug_hw_veb(self, instance, vif):
643-
# TODO(vladikr): This code can be removed once the minimum version of
644-
# Libvirt is incleased above 1.3.5, as vlan will be set by libvirt
645-
if vif['vnic_type'] == network_model.VNIC_TYPE_MACVTAP:
646-
set_vf_interface_vlan(
647-
vif['profile']['pci_slot'],
648-
mac_addr=vif['address'],
649-
vlan=vif['details'][network_model.VIF_DETAILS_VLAN])
650-
651-
elif vif['vnic_type'] == network_model.VNIC_TYPE_DIRECT:
644+
if vif['vnic_type'] == network_model.VNIC_TYPE_DIRECT:
652645
trusted = strutils.bool_from_string(
653646
vif['profile'].get('trusted', "False"))
654647
if trusted:

0 commit comments

Comments
 (0)