Merge pull request #851 from amshinde/modify-driver-fetch

vfio: Change the way the driver is fetched
This commit is contained in:
Sebastien Boeuf 2018-10-26 14:03:32 -07:00 committed by GitHub
commit 2c2a60faf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ package virtcontainers
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -148,12 +149,15 @@ func createPhysicalEndpoint(netInfo NetworkInfo) (*PhysicalEndpoint, error) {
return nil, err
}
// Get Driver
driver, err := ethHandle.DriverName(netInfo.Iface.Name)
// Get driver by following symlink /sys/bus/pci/devices/$bdf/driver
driverPath := filepath.Join(sysPCIDevicesPath, bdf, "driver")
link, err := os.Readlink(driverPath)
if err != nil {
return nil, err
}
driver := filepath.Base(link)
// Get vendor and device id from pci space (sys/bus/pci/devices/$bdf)
ifaceDevicePath := filepath.Join(sysPCIDevicesPath, bdf, "device")