Fix sensitivity to the initial device driver

Previously it was expected that all devices are initially
binded on kernel driver. In case of userspace driver it
caused an incorrect behavior.

This patch makes sriov binding driver insensitive for
initial device driver.

Change-Id: I1be19aceb9176d1bdf7f0f712a4a02ec2cd3ce8d
Closes-Bug: 1842446
Signed-off-by: Danil Golov <d.golov@samsung.com>
This commit is contained in:
Danil Golov 2019-09-03 16:59:31 +03:00
parent 6d4deb7446
commit 323f01b9a4
2 changed files with 11 additions and 6 deletions

View File

@ -128,7 +128,7 @@ class VIFSriovDriver(object):
def _compute_pci(self, pci, driver, pod_link, vif, ifname, netns):
port_id = vif.id
vf_name, vf_index, pf, pci_info = self._get_vf_info(pci)
vf_name, vf_index, pf, pci_info = self._get_vf_info(pci, driver)
if driver in constants.USERSPACE_DRIVERS:
LOG.info("PCI device %s will be rebinded to userspace network "
"driver %s", pci, driver)
@ -165,10 +165,15 @@ class VIFSriovDriver(object):
return pci_info
def _get_vf_info(self, pci):
def _get_vf_info(self, pci, driver):
vf_sys_path = '/sys/bus/pci/devices/{}/net/'.format(pci)
vf_names = os.listdir(vf_sys_path)
vf_name = vf_names[0]
if not os.path.exists(vf_sys_path):
if driver not in constants.USERSPACE_DRIVERS:
raise OSError(_("No vf name for device {}").format(pci))
vf_name = None
else:
vf_names = os.listdir(vf_sys_path)
vf_name = vf_names[0]
pfysfn_path = '/sys/bus/pci/devices/{}/physfn/net/'.format(pci)
pf_names = os.listdir(pfysfn_path)

View File

@ -330,7 +330,7 @@ class TestSriovDriver(TestDriverMixin, test_base.TestCase):
self.vif,
self.ifname,
self.netns))
m_driver._get_vf_info.assert_called_once_with(self.pci)
m_driver._get_vf_info.assert_called_once_with(self.pci, new_driver)
m_driver._set_vf_mac.assert_called_once_with(pf, vf_index,
self.vif.address)
m_driver._bind_device.assert_called_once_with(self.pci, new_driver)
@ -359,7 +359,7 @@ class TestSriovDriver(TestDriverMixin, test_base.TestCase):
self.ifname,
self.netns))
m_driver._get_vf_info.assert_called_once_with(self.pci)
m_driver._get_vf_info.assert_called_once_with(self.pci, new_driver)
m_driver._move_to_netns.assert_called_once_with(self.pci, self.ifname,
self.netns, self.vif,
vf_name, vf_index, pf,