Exclude DPDK mapped VF device even if not present
As part of FFU from queens to train, os-net-config
will run after the RHEL update. At this point, DPDK
mapping file will have VF if it has been used as
part of NIC partitioning feature, but the physically
the VF will not be present as it is yet to be created.
During the active nic list creation (before creating
VFs), DPDK mapped VF will be used as regular nic,
which results in wrong nic numbering.
This patch excludes the VFs by checking the device
type in the sriov_config.yaml mapping file, so that
the nic numbering will be kept same.
Change-Id: I17d19715a1f7c231630416d6fea06fe9afe44e9b
(cherry picked from commit 4f2ebfd6bd
)
This commit is contained in:
parent
17c2abc9a5
commit
fa0fd2e354
|
@ -600,6 +600,30 @@ class TestUtils(base.TestCase):
|
|||
shutil.rmtree(tmpdir)
|
||||
shutil.rmtree(tmp_pci_dir)
|
||||
|
||||
def test_ordered_active_nics_with_dpdk_mapping_of_vf(self):
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
self.stub_out('os_net_config.utils._SYS_CLASS_NET', tmpdir)
|
||||
tmp_pci_dir = tempfile.mkdtemp()
|
||||
self.stub_out('os_net_config.utils._SYS_BUS_PCI_DEV', tmp_pci_dir)
|
||||
physfn_path = utils._SYS_BUS_PCI_DEV + '/0000:05:01.1/physfn'
|
||||
os.makedirs(physfn_path)
|
||||
|
||||
def test_is_available_nic(interface_name, check_active):
|
||||
return True
|
||||
self.stub_out('os_net_config.utils._is_available_nic',
|
||||
test_is_available_nic)
|
||||
|
||||
utils._update_dpdk_map('eth2_0', '0000:06:01.1', 'AA:02:03:04:05:FE',
|
||||
'vfio-pci')
|
||||
utils.update_sriov_vf_map('eth2', 0, 'eth2_0')
|
||||
|
||||
nics = utils.ordered_active_nics()
|
||||
|
||||
self.assertEqual(len(nics), 0)
|
||||
|
||||
shutil.rmtree(tmpdir)
|
||||
shutil.rmtree(tmp_pci_dir)
|
||||
|
||||
def test_interface_mac_raises(self):
|
||||
self.assertRaises(IOError, utils.interface_mac, 'ens20f2p3')
|
||||
|
||||
|
|
|
@ -167,9 +167,15 @@ def _is_vf(pci_address):
|
|||
return is_sriov_vf
|
||||
|
||||
|
||||
def _is_vf_by_name(interface_name):
|
||||
def _is_vf_by_name(interface_name, check_mapping_file=False):
|
||||
vf_path_check = _SYS_CLASS_NET + '/%s/device/physfn' % interface_name
|
||||
is_sriov_vf = os.path.isdir(vf_path_check)
|
||||
if not is_sriov_vf and check_mapping_file:
|
||||
sriov_map = _get_sriov_map()
|
||||
for item in sriov_map:
|
||||
if (item['name'] == interface_name and
|
||||
item['device_type'] == 'vf'):
|
||||
is_sriov_vf = True
|
||||
return is_sriov_vf
|
||||
|
||||
|
||||
|
@ -249,6 +255,8 @@ def _ordered_nics(check_active):
|
|||
nic = item['name']
|
||||
if _is_vf(item['pci_address']):
|
||||
logger.info("%s is a VF, skipping it for NIC ordering" % nic)
|
||||
elif _is_vf_by_name(nic, True):
|
||||
logger.info("%s is a VF, skipping it for NIC ordering" % nic)
|
||||
elif _is_embedded_nic(nic):
|
||||
logger.info("%s is an embedded DPDK bound nic" % nic)
|
||||
embedded_nics.append(nic)
|
||||
|
|
Loading…
Reference in New Issue