mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-22 05:28:25 +00:00
vfio: Introduce function to get vfio dev path
This function will be later used to get the vfio dev path. Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
1e304e6307
commit
c6390f2a2a
@ -268,6 +268,16 @@ func GetBDF(deviceSysStr string) string {
|
|||||||
return tokens[1]
|
return tokens[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetVFIODevPath(bdf string) (string, error) {
|
||||||
|
// Determine the iommu group that the device belongs to.
|
||||||
|
groupPath, err := os.Readlink(fmt.Sprintf(iommuGroupPath, bdf))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(vfioDevPath, filepath.Base(groupPath)), nil
|
||||||
|
}
|
||||||
|
|
||||||
// BindDevicetoVFIO binds the device to vfio driver after unbinding from host
|
// BindDevicetoVFIO binds the device to vfio driver after unbinding from host
|
||||||
// driver if present.
|
// driver if present.
|
||||||
// Will be called by a network interface or a generic pcie device.
|
// Will be called by a network interface or a generic pcie device.
|
||||||
@ -306,13 +316,7 @@ func BindDevicetoVFIO(bdf, hostDriver string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the iommu group that the device belongs to.
|
return GetVFIODevPath(bdf)
|
||||||
groupPath, err := os.Readlink(fmt.Sprintf(iommuGroupPath, bdf))
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf(vfioDevPath, filepath.Base(groupPath)), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BindDevicetoHost unbinds the device from vfio-pci driver and binds it to the
|
// BindDevicetoHost unbinds the device from vfio-pci driver and binds it to the
|
||||||
|
Loading…
Reference in New Issue
Block a user