diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2017-03-08 08:45:50 +0000 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2017-04-11 14:38:19 +0000 |
commit | e6829f872aca03af6181557260637c8b601e476a (patch) | |
tree | b011243a75011b712a7b3a828d850e8ed3f330cf /nova/pci | |
parent | 3092d2adcb6bab0bf39b01ea0561ec7e6a3990fd (diff) | |
download | nova-e6829f872aca03af6181557260637c8b601e476a.tar.gz |
Read NIC features in libvirt
Reads the NIC feature information from the 'net' devices
given by 'libvirt'. This information is added to
pci_devices.extra_info dictionary under a dictionary
labeled 'capabilities'; this dictionary will contain a key
labeled 'network' with the list of capabilities. E.g.:
extra_info: {'capabilities':
{'network': ['gso', 'sg', 'tso', 'tx']}
}
'libvirt' implemented the NIC feature discovery in version
1.2.14 (https://libvirt.org/news-2015.html)
blueprint enable-sriov-nic-features
Change-Id: Ia5b6abbbf4e5f762e0df04167c32c6135781d305
Diffstat (limited to 'nova/pci')
-rw-r--r-- | nova/pci/utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nova/pci/utils.py b/nova/pci/utils.py index c68eaf7dea..489853e2c3 100644 --- a/nova/pci/utils.py +++ b/nova/pci/utils.py @@ -171,3 +171,27 @@ def get_vf_num_by_pci_address(pci_addr): if vf_num is None: raise exception.PciDeviceNotFoundById(id=pci_addr) return vf_num + + +def get_net_name_by_vf_pci_address(vfaddress): + """Given the VF PCI address, returns the net device name. + + Every VF is associated to a PCI network device. This function + returns the libvirt name given to this network device; e.g.: + + <device> + <name>net_enp8s0f0_90_e2_ba_5e_a6_40</name> + ... + + In the libvirt parser information tree, the network device stores the + network capabilities associated to this device. + """ + try: + mac = get_mac_by_pci_address(vfaddress).split(':') + ifname = get_ifname_by_pci_address(vfaddress) + return ("net_%(ifname)s_%(mac)s" % + {'ifname': ifname, 'mac': '_'.join(mac)}) + except Exception: + LOG.warning("No net device was found for VF %(vfaddress)s", + {'vfaddress': vfaddress}) + return |