From 51246525d7ebe38e0b6baa87ea4847968e254d48 Mon Sep 17 00:00:00 2001 From: Edan David Date: Thu, 18 Aug 2016 16:56:56 +0300 Subject: [PATCH] Allow SR-IOV agent to start when number of vf is 0 Remove number of vf validation from scan_vf_devices method in the eswitch manager module, to allow the SR-IOV agent to load when using PF passthrough. Closes-Bug: #1614086 Change-Id: Iff5bf3a5542d5b19f45637e954a72a14402a30ae (cherry picked from commit f2b33b67272962abd7d6e61ab3d2b7aca3428dc5) --- .../ml2/drivers/mech_sriov/agent/eswitch_manager.py | 4 ---- .../drivers/mech_sriov/agent/test_eswitch_manager.py | 10 ++++------ .../notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml | 3 +++ 3 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py index e1d03ae10a5..43edad0f9d4 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py @@ -59,10 +59,6 @@ class PciOsWrapper(object): file_link = os.readlink(file_path) pci_slot = os.path.basename(file_link) vf_list.append((pci_slot, vf_index)) - if not vf_list: - raise exc.InvalidDeviceError( - dev_name=dev_name, - reason=_("Device has no virtual functions")) return vf_list @classmethod diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py index 385a1cd21f5..66499e70f2a 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py @@ -479,17 +479,15 @@ class TestPciOsWrapper(base.BaseTestCase): def test_scan_vf_devices_no_content(self): with mock.patch("os.path.isdir", return_value=True),\ mock.patch("os.listdir", return_value=[]): - self.assertRaises(exc.InvalidDeviceError, - esm.PciOsWrapper.scan_vf_devices, - self.DEV_NAME) + self.assertEqual([], + esm.PciOsWrapper.scan_vf_devices(self.DEV_NAME)) def test_scan_vf_devices_no_match(self): with mock.patch("os.path.isdir", return_value=True),\ mock.patch("os.listdir", return_value=self.DIR_CONTENTS_NO_MATCH): - self.assertRaises(exc.InvalidDeviceError, - esm.PciOsWrapper.scan_vf_devices, - self.DEV_NAME) + self.assertEqual([], + esm.PciOsWrapper.scan_vf_devices(self.DEV_NAME)) @mock.patch("os.listdir", side_effect=OSError()) def test_is_assigned_vf_true(self, *args): diff --git a/releasenotes/notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml b/releasenotes/notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml new file mode 100644 index 00000000000..b65b657ed66 --- /dev/null +++ b/releasenotes/notes/sriov-agent-num-vf-0-0c06424247e7efe0.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Allow SR-IOV agent to run with 0 vfs