From 83ab4a196f1b7d31aa092edcc21da6ee28e967ca Mon Sep 17 00:00:00 2001 From: Jaganathan Palanisamy Date: Wed, 28 Nov 2018 00:05:46 -0500 Subject: [PATCH] Adding pci address in SRIOV config This change is to store pci address in SRIOV config. In Nova PCI passthrough whitelist automation, Planning to use SRIOV config to find the already used pci addresses. Change-Id: Ifecc341ce652c638f06b540df4bf17aa6674db02 --- os_net_config/objects.py | 16 ++- os_net_config/tests/test_cli.py | 11 ++ os_net_config/tests/test_impl_ifcfg.py | 31 +++- os_net_config/tests/test_objects.py | 134 +++++++++++++++++- os_net_config/tests/test_utils.py | 21 ++- os_net_config/utils.py | 11 +- ...ress-in-sriov-config-06016e4e69b322ca.yaml | 5 + 7 files changed, 207 insertions(+), 22 deletions(-) create mode 100644 releasenotes/notes/add-pci-address-in-sriov-config-06016e4e69b322ca.yaml diff --git a/os_net_config/objects.py b/os_net_config/objects.py index 5ce855aa..179b8099 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -639,7 +639,8 @@ class OvsBridge(_BaseOpts): vlan_id=iface.vlan_id, qos=iface.qos, spoofcheck=iface.spoofcheck, trust=iface.trust, state=iface.state, - macaddr=iface.macaddr, promisc=iface.promisc) + macaddr=iface.macaddr, promisc=iface.promisc, + pci_address=iface.pci_address) @staticmethod def from_json(json): @@ -1005,7 +1006,8 @@ class LinuxBond(_BaseOpts): vlan_id=iface.vlan_id, qos=iface.qos, spoofcheck=iface.spoofcheck, trust=iface.trust, state=iface.state, - macaddr=iface.macaddr, promisc=iface.promisc) + macaddr=iface.macaddr, promisc=iface.promisc, + pci_address=iface.pci_address) @staticmethod def from_json(json): @@ -1264,7 +1266,8 @@ class OvsDpdkPort(_BaseOpts): vlan_id=iface.vlan_id, qos=iface.qos, spoofcheck=iface.spoofcheck, trust=iface.trust, state=iface.state, - macaddr=iface.macaddr, promisc=iface.promisc) + macaddr=iface.macaddr, promisc=iface.promisc, + pci_address=iface.pci_address) @staticmethod def from_json(json): @@ -1362,8 +1365,12 @@ class SriovVF(_BaseOpts): self.spoofcheck = spoofcheck self.trust = trust self.state = state + pci_address = utils.get_pci_address(name, False) + if pci_address is None: + pci_address = utils.get_stored_pci_address(name, False) self.macaddr = macaddr self.promisc = promisc + self.pci_address = pci_address utils.update_sriov_vf_map(device, self.vfid, name, vlan_id=self.vlan_id, qos=self.qos, @@ -1371,7 +1378,8 @@ class SriovVF(_BaseOpts): trust=trust, state=state, macaddr=macaddr, - promisc=promisc) + promisc=promisc, + pci_address=pci_address) @staticmethod def get_on_off(config): diff --git a/os_net_config/tests/test_cli.py b/os_net_config/tests/test_cli.py index d2800c80..b667a2a9 100644 --- a/os_net_config/tests/test_cli.py +++ b/os_net_config/tests/test_cli.py @@ -212,11 +212,16 @@ class TestCli(base.TestCase): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + def test_interface_mac(name): return 'AA:BB:CC:DD:EE:FF' self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) self.stub_out('os_net_config.utils.interface_mac', test_interface_mac) ivs_yaml = os.path.join(SAMPLE_BASE, 'sriov_pf.yaml') @@ -248,8 +253,14 @@ class TestCli(base.TestCase): def test_sriov_vf_with_dpdk_noop_output(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) ivs_yaml = os.path.join(SAMPLE_BASE, 'sriov_pf_ovs_dpdk.yaml') ivs_json = os.path.join(SAMPLE_BASE, 'sriov_pf_ovs_dpdk.json') stdout_yaml, stderr = self.run_cli('ARG0 --provider=ifcfg --noop ' diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index b01e47d2..dc8982f0 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -1259,7 +1259,8 @@ DOMAIN=openstack.local def test_update_sriov_vf_map(pf_name, vfid, vf_name, vlan_id=None, qos=None, spoofcheck=None, trust=None, - state=None, macaddr=None, promisc=None): + state=None, macaddr=None, promisc=None, + pci_address=None): self.assertEqual(pf_name, 'eth2') self.assertEqual(vfid, 7) self.assertEqual(vlan_id, 0) @@ -1268,14 +1269,22 @@ DOMAIN=openstack.local self.assertEqual(trust, None) self.assertEqual(state, None) self.assertEqual(macaddr, None) + self.assertEqual(pci_address, '0000:79:10.2') self.stub_out('os_net_config.utils.update_sriov_vf_map', test_update_sriov_vf_map) def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) + vf = objects.SriovVF(device='nic3', vfid=7, addresses=addresses) self.provider.add_sriov_vf(vf) vf_config = """# This file is autogenerated by os-net-config @@ -1297,7 +1306,8 @@ NETMASK=255.255.255.0 def test_update_sriov_vf_map(pf_name, vfid, vf_name, vlan_id=None, qos=None, spoofcheck=None, trust=None, - state=None, macaddr=None, promisc=None): + state=None, macaddr=None, promisc=None, + pci_address=None): self.assertEqual(pf_name, 'eth2') self.assertEqual(vf_name, 'eth2_7') self.assertEqual(vfid, 7) @@ -1308,15 +1318,22 @@ NETMASK=255.255.255.0 self.assertEqual(state, "auto") self.assertEqual(macaddr, "AA:BB:CC:DD:EE:FF") self.assertTrue(promisc) + self.assertEqual(pci_address, '0000:80:10.1') self.stub_out('os_net_config.utils.update_sriov_vf_map', test_update_sriov_vf_map) def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + def test_get_pci_address(ifname, noop): + return '0000:80:10.1' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) + vf = objects.SriovVF(device='nic3', vfid=7, addresses=addresses, vlan_id='100', qos='10', spoofcheck=True, trust=True, state="auto", @@ -1342,7 +1359,8 @@ NETMASK=255.255.255.0 def test_update_sriov_vf_map(pf_name, vfid, vf_name, vlan_id=None, qos=None, spoofcheck=None, trust=None, - state=None, macaddr=None, promisc=None): + state=None, macaddr=None, promisc=None, + pci_address=None): self.assertEqual(pf_name, 'eth2') self.assertEqual(vf_name, 'eth2_7') self.assertEqual(vfid, 7) @@ -1353,15 +1371,22 @@ NETMASK=255.255.255.0 self.assertEqual(state, "enable") self.assertEqual(macaddr, "AA:BB:CC:DD:EE:FF") self.assertFalse(promisc) + self.assertEqual(pci_address, '0000:82:00.2') self.stub_out('os_net_config.utils.update_sriov_vf_map', test_update_sriov_vf_map) def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + def test_get_pci_address(ifname, noop): + return '0000:82:00.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) + vf = objects.SriovVF(device='nic3', vfid=7, addresses=addresses, vlan_id='100', qos='10', spoofcheck=False, trust=False, state="enable", diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py index 81f23ef8..8a056dd4 100644 --- a/os_net_config/tests/test_objects.py +++ b/os_net_config/tests/test_objects.py @@ -436,12 +436,18 @@ class TestBridge(base.TestCase): 'device': {'name': 'em1', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, 'spoofcheck': 'off', 'trust': 'on', - 'promisc': 'on'}] + 'promisc': 'on', 'pci_address': '0000:79:10.2'}] def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) bridge = objects.object_from_json(json.loads(data)) self.assertEqual("br-foo", bridge.name) @@ -495,8 +501,14 @@ class TestBridge(base.TestCase): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) bridge = objects.object_from_json(json.loads(data)) self.assertEqual("br-foo", bridge.name) @@ -558,8 +570,14 @@ class TestBridge(base.TestCase): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) objects.object_from_json(json.loads(data)) @@ -587,14 +605,20 @@ class TestBridge(base.TestCase): vf_final = [{'device_type': 'vf', 'name': 'em1_1', 'device': {'name': 'em1', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, + 'pci_address': '0000:79:10.2', 'spoofcheck': 'off', 'trust': 'off', 'promisc': 'off'}] def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) - + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) bridge = objects.object_from_json(json.loads(data)) self.assertEqual("br-foo", bridge.name) self.assertTrue(bridge.use_dhcp) @@ -630,13 +654,20 @@ class TestBridge(base.TestCase): vf_final = [{'device_type': 'vf', 'name': 'em1_1', 'device': {'name': 'em1', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, - 'spoofcheck': 'off', 'trust': 'on' + 'spoofcheck': 'off', 'trust': 'on', + 'pci_address': '0000:79:10.2' }] def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) bridge = objects.object_from_json(json.loads(data)) self.assertEqual("br-foo", bridge.name) @@ -676,13 +707,20 @@ class TestBridge(base.TestCase): vf_final = [{'device_type': 'vf', 'name': 'em1_1', 'device': {'name': 'em1', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, - 'spoofcheck': 'off', 'trust': 'off' + 'spoofcheck': 'off', 'trust': 'off', + 'pci_address': '0000:79:10.2' }] def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) bridge = objects.object_from_json(json.loads(data)) self.assertEqual("br-foo", bridge.name) @@ -1177,18 +1215,29 @@ class TestLinuxBond(base.TestCase): vf_final = [{'device_type': 'vf', 'name': 'em1_1', 'device': {'name': 'em1', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, + 'pci_address': '0000:79:10.1', 'spoofcheck': 'on', 'trust': 'on', 'promisc': 'off'}, {'device_type': 'vf', 'name': 'em2_1', 'device': {'name': 'em2', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, + 'pci_address': '0000:79:10.2', 'spoofcheck': 'on', 'trust': 'on', 'promisc': 'off'}] def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + if ifname == 'em1_1': + return '0000:79:10.1' + elif ifname == 'em2_1': + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) bond = objects.object_from_json(json.loads(data)) self.assertEqual("bond1", bond.name) @@ -1233,18 +1282,29 @@ class TestLinuxBond(base.TestCase): vf_final = [{'device_type': 'vf', 'name': 'em1_1', 'device': {'name': 'em1', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, + 'pci_address': '0000:79:10.1', 'spoofcheck': 'off', 'trust': 'off', 'promisc': 'off'}, {'device_type': 'vf', 'name': 'em2_1', 'device': {'name': 'em2', 'vfid': 1}, 'vlan_id': 111, 'qos': 1, + 'pci_address': '0000:79:10.2', 'spoofcheck': 'off', 'trust': 'off', 'promisc': 'off'}] def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + if ifname == 'em1_1': + return '0000:79:10.1' + elif ifname == 'em2_1': + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) objects.object_from_json(json.loads(data)) contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE) @@ -1787,8 +1847,14 @@ class TestSriovVF(base.TestCase): def test_from_json_vfid(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) data = '{"type": "sriov_vf", "device": "em1", "vfid": 16,' \ '"use_dhcp": false}' vf = objects.object_from_json(json.loads(data)) @@ -1800,8 +1866,14 @@ class TestSriovVF(base.TestCase): def test_from_json_name_ignored(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) data = '{"type": "sriov_vf", "device": "em1", "vfid": 16,' \ '"use_dhcp": false, "name": "em1_7"}' vf = objects.object_from_json(json.loads(data)) @@ -1813,8 +1885,14 @@ class TestSriovVF(base.TestCase): def test_from_json_vfid_configs_enabled(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) data = '{"type": "sriov_vf", "device": "em4", "vfid": 16,' \ '"use_dhcp": false, "vlan_id": 100, "qos": 2, "trust": true,' \ @@ -1836,8 +1914,14 @@ class TestSriovVF(base.TestCase): def test_from_json_vfid_configs_disabled(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) data = '{"type": "sriov_vf", "device": "em4", "vfid": 16,' \ '"use_dhcp": false, "vlan_id": 0, "qos": 0, "trust": false,' \ @@ -1859,8 +1943,14 @@ class TestSriovVF(base.TestCase): def test_from_json_vfid_invalid_state(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) data = '{"type": "sriov_vf", "device": "em4", "vfid": 16,' \ '"use_dhcp": false, "vlan_id": 0, "qos": 0, "trust": false,' \ @@ -1875,8 +1965,14 @@ class TestSriovVF(base.TestCase): def test_from_json_vfid_invalid_qos(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) data = '{"type": "sriov_vf", "device": "em4", "vfid": 16,' \ '"use_dhcp": false, "vlan_id": 0, "qos": 10, "trust": false,' \ @@ -1890,8 +1986,14 @@ class TestSriovVF(base.TestCase): def test_from_json_vfid_nic1(self): def test_get_vf_devname(device, vfid): return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return '0000:79:10.2' + self.stub_out('os_net_config.utils.get_vf_devname', test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) def dummy_mapped_nics(nic_mapping=None): return {"nic1": "em4"} @@ -1906,6 +2008,30 @@ class TestSriovVF(base.TestCase): self.assertFalse(vf.use_dhcp) self.assertEqual("em4_16", vf.name) + def test_from_json_pci_address_none(self): + def test_get_vf_devname(device, vfid): + return device + '_' + str(vfid) + + def test_get_pci_address(ifname, noop): + return None + + def test_get_stored_pci_address(ifname, noop): + return '0000:79:10.2' + + self.stub_out('os_net_config.utils.get_vf_devname', + test_get_vf_devname) + self.stub_out('os_net_config.utils.get_pci_address', + test_get_pci_address) + self.stub_out('os_net_config.utils.get_stored_pci_address', + test_get_stored_pci_address) + data = '{"type": "sriov_vf", "device": "em1", "vfid": 16,' \ + '"use_dhcp": false}' + vf = objects.object_from_json(json.loads(data)) + self.assertEqual("em1", vf.device) + self.assertEqual(16, vf.vfid) + self.assertFalse(vf.use_dhcp) + self.assertEqual("em1_16", vf.name) + class TestOvsDpdkBond(base.TestCase): diff --git a/os_net_config/tests/test_utils.py b/os_net_config/tests/test_utils.py index 2043e824..d6a71229 100644 --- a/os_net_config/tests/test_utils.py +++ b/os_net_config/tests/test_utils.py @@ -176,7 +176,8 @@ class TestUtils(base.TestCase): def test_update_sriov_vf_map_complete_new(self): utils.update_sriov_vf_map('eth1', 2, 'eth1_2', vlan_id=10, qos=5, spoofcheck="on", trust="on", state="enable", - macaddr="AA:BB:CC:DD:EE:FF", promisc="off") + macaddr="AA:BB:CC:DD:EE:FF", promisc="off", + pci_address="0000:80:00.1") contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE) sriov_vf_map = yaml.safe_load(contents) if contents else [] self.assertEqual(1, len(sriov_vf_map)) @@ -186,7 +187,8 @@ class TestUtils(base.TestCase): 'spoofcheck': 'on', 'trust': 'on', 'state': 'enable', 'macaddr': 'AA:BB:CC:DD:EE:FF', - 'promisc': 'off'}] + 'promisc': 'off', + 'pci_address': "0000:80:00.1"}] self.assertListEqual(test_sriov_vf_map, sriov_vf_map) def test_update_sriov_vf_map_exist(self): @@ -196,14 +198,16 @@ class TestUtils(base.TestCase): utils.update_sriov_vf_map('eth1', 2, 'eth1_2', vlan_id=10, qos=5, spoofcheck="on", trust="on", state="enable", - macaddr="AA:BB:CC:DD:EE:FF", promisc="off") + macaddr="AA:BB:CC:DD:EE:FF", promisc="off", + pci_address="0000:80:00.1") vf_final = [{'device_type': 'vf', 'name': 'eth1_2', 'device': {'name': 'eth1', 'vfid': 2}, 'vlan_id': 10, 'qos': 5, 'spoofcheck': 'on', 'trust': 'on', 'state': 'enable', 'macaddr': 'AA:BB:CC:DD:EE:FF', - 'promisc': 'off'}] + 'promisc': 'off', + 'pci_address': '0000:80:00.1'}] contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE) vf_map = yaml.safe_load(contents) if contents else [] @@ -217,19 +221,22 @@ class TestUtils(base.TestCase): 'spoofcheck': 'on', 'trust': 'on', 'state': 'enable', 'macaddr': 'AA:BB:CC:DD:EE:FF', - 'promisc': 'off'}] + 'promisc': 'off', + 'pci_address': "0000:80:00.1"}] utils.write_yaml_config(sriov_config._SRIOV_CONFIG_FILE, vf_initial) utils.update_sriov_vf_map('eth1', 2, 'eth1_2', vlan_id=100, qos=15, spoofcheck="off", trust="off", state="auto", - macaddr="BB:BB:CC:DD:EE:FF", promisc="on") + macaddr="BB:BB:CC:DD:EE:FF", promisc="on", + pci_address="0000:80:00.1") vf_final = [{'device_type': 'vf', 'name': 'eth1_2', 'device': {'name': 'eth1', 'vfid': 2}, 'vlan_id': 100, 'qos': 15, 'spoofcheck': 'off', 'trust': 'off', 'state': 'auto', 'macaddr': 'BB:BB:CC:DD:EE:FF', - 'promisc': 'on'}] + 'promisc': 'on', + 'pci_address': '0000:80:00.1'}] contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE) vf_map = yaml.safe_load(contents) if contents else [] diff --git a/os_net_config/utils.py b/os_net_config/utils.py index 5af682c5..b0469d28 100644 --- a/os_net_config/utils.py +++ b/os_net_config/utils.py @@ -445,7 +445,7 @@ def _get_sriov_map(): def _set_vf_fields(vf_name, vlan_id, qos, spoofcheck, trust, state, macaddr, - promisc): + promisc, pci_address): vf_configs = {} vf_configs['name'] = vf_name if vlan_id != 0: @@ -461,6 +461,7 @@ def _set_vf_fields(vf_name, vlan_id, qos, spoofcheck, trust, state, macaddr, vf_configs['state'] = state vf_configs['macaddr'] = macaddr vf_configs['promisc'] = promisc + vf_configs['pci_address'] = pci_address return vf_configs @@ -472,14 +473,15 @@ def _clear_empty_values(vf_config): def update_sriov_vf_map(pf_name, vfid, vf_name, vlan_id=0, qos=0, spoofcheck=None, trust=None, state=None, macaddr=None, - promisc=None): + promisc=None, pci_address=None): sriov_map = _get_sriov_map() for item in sriov_map: if (item['device_type'] == 'vf' and item['device'].get('name') == pf_name and item['device'].get('vfid') == vfid): item.update(_set_vf_fields(vf_name, vlan_id, qos, spoofcheck, - trust, state, macaddr, promisc)) + trust, state, macaddr, promisc, + pci_address)) _clear_empty_values(item) break else: @@ -487,7 +489,8 @@ def update_sriov_vf_map(pf_name, vfid, vf_name, vlan_id=0, qos=0, new_item['device_type'] = 'vf' new_item['device'] = {"name": pf_name, "vfid": vfid} new_item.update(_set_vf_fields(vf_name, vlan_id, qos, spoofcheck, - trust, state, macaddr, promisc)) + trust, state, macaddr, promisc, + pci_address)) _clear_empty_values(new_item) sriov_map.append(new_item) diff --git a/releasenotes/notes/add-pci-address-in-sriov-config-06016e4e69b322ca.yaml b/releasenotes/notes/add-pci-address-in-sriov-config-06016e4e69b322ca.yaml new file mode 100644 index 00000000..7a403cc1 --- /dev/null +++ b/releasenotes/notes/add-pci-address-in-sriov-config-06016e4e69b322ca.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Adding PCI address of each VF to sriov_config.yaml. This information + could be used in deriving the PCI passthrough whitelist.