From 31cf6fbe00d5ff505324ab256dce6b978a56a96c Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Mon, 22 Oct 2018 18:16:28 -0700 Subject: [PATCH] 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 --- virtcontainers/physical_endpoint.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/virtcontainers/physical_endpoint.go b/virtcontainers/physical_endpoint.go index 57c5f510eb..ba1f93d6fb 100644 --- a/virtcontainers/physical_endpoint.go +++ b/virtcontainers/physical_endpoint.go @@ -8,6 +8,7 @@ package virtcontainers import ( "fmt" "io/ioutil" + "os" "path/filepath" "strings" @@ -143,12 +144,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")