Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
vfio: Change the way the driver is fetched
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
amshinde committed Oct 23, 2018
1 parent 40ee885 commit 31cf6fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions virtcontainers/physical_endpoint.go
Expand Up @@ -8,6 +8,7 @@ package virtcontainers
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 31cf6fb

Please sign in to comment.