Martin Polednik has uploaded a new change for review. Change subject: hostdev: report physfn ......................................................................
hostdev: report physfn Each sr-iov virtual function is actually a separate function on a pci bus. Libvirt reports these functions on the same level as physical functions, but sysfs provides us means of determining which pf does given vf belong to. This is useful in order to correctly construct the tree. Change-Id: Id1c41b1fd7e0cab51c869ae4a7882072be2c3fad Signed-off-by: Martin Polednik <mpoled...@redhat.com> --- M vdsm/hostdev.py 1 file changed, 18 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/35974/1 diff --git a/vdsm/hostdev.py b/vdsm/hostdev.py index 7823a9c..1bea63f 100644 --- a/vdsm/hostdev.py +++ b/vdsm/hostdev.py @@ -18,6 +18,8 @@ # Refer to the README and COPYING files for full details of the license # +import os + import xml.etree.ElementTree as etree from vdsm import libvirtconnection @@ -30,10 +32,20 @@ return device_name[4:].replace('_', '.').replace('.', ':', 2) +def _pci_path_to_name(pci_path): + return pci_path.replace(':', '_').replace('.', '_') + + def _sriov_totalvfs(device_name): with open('/sys/bus/pci/devices/{}/sriov_totalvfs'.format( _name_to_pci_path(device_name))) as f: return str(int(f.read())) + + +def _sriov_physfn(device_name): + return 'pci_' + _pci_path_to_name( + os.readlink('/sys/bus/pci/devices/{}/physfn'.format( + _name_to_pci_path(device_name))))[3:] def _parse_device_params(device_xml): @@ -69,6 +81,12 @@ # Device does not support sriov, we can safely go on pass + try: + params['physfn'] = _sriov_physfn(name) + except OSError: + # Device does not support sriov, we can safely go on + pass + return params -- To view, visit http://gerrit.ovirt.org/35974 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id1c41b1fd7e0cab51c869ae4a7882072be2c3fad Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Polednik <mpoled...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches