vfio: Change the way the driver is fetched

Instead of using ethtool for getting the driver for network
devices, use sysfs instead. This is because in case of virtio
devices, ethtool returns virtio-net instead of virtio-pci for
virtio network devices. We need to bind/unbind from virtio-pci
driver in case of virtio-net devices.

Fixes #612

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2018-10-22 18:16:28 -07:00
parent 40ee885e8e
commit 31cf6fbe00

View File

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