Merge "Fix sensitivity to the initial device driver"
This commit is contained in:
commit
3e5e4950db
|
@ -128,7 +128,7 @@ class VIFSriovDriver(object):
|
||||||
|
|
||||||
def _compute_pci(self, pci, driver, pod_link, vif, ifname, netns):
|
def _compute_pci(self, pci, driver, pod_link, vif, ifname, netns):
|
||||||
port_id = vif.id
|
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:
|
if driver in constants.USERSPACE_DRIVERS:
|
||||||
LOG.info("PCI device %s will be rebinded to userspace network "
|
LOG.info("PCI device %s will be rebinded to userspace network "
|
||||||
"driver %s", pci, driver)
|
"driver %s", pci, driver)
|
||||||
|
@ -165,10 +165,15 @@ class VIFSriovDriver(object):
|
||||||
|
|
||||||
return pci_info
|
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_sys_path = '/sys/bus/pci/devices/{}/net/'.format(pci)
|
||||||
vf_names = os.listdir(vf_sys_path)
|
if not os.path.exists(vf_sys_path):
|
||||||
vf_name = vf_names[0]
|
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)
|
pfysfn_path = '/sys/bus/pci/devices/{}/physfn/net/'.format(pci)
|
||||||
pf_names = os.listdir(pfysfn_path)
|
pf_names = os.listdir(pfysfn_path)
|
||||||
|
|
|
@ -330,7 +330,7 @@ class TestSriovDriver(TestDriverMixin, test_base.TestCase):
|
||||||
self.vif,
|
self.vif,
|
||||||
self.ifname,
|
self.ifname,
|
||||||
self.netns))
|
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,
|
m_driver._set_vf_mac.assert_called_once_with(pf, vf_index,
|
||||||
self.vif.address)
|
self.vif.address)
|
||||||
m_driver._bind_device.assert_called_once_with(self.pci, new_driver)
|
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.ifname,
|
||||||
self.netns))
|
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,
|
m_driver._move_to_netns.assert_called_once_with(self.pci, self.ifname,
|
||||||
self.netns, self.vif,
|
self.netns, self.vif,
|
||||||
vf_name, vf_index, pf,
|
vf_name, vf_index, pf,
|
||||||
|
|
Loading…
Reference in New Issue