mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-17 14:58:16 +00:00
runtime: Add proper IOMMUFD parsing
With newer kernels we have a new backend for VFIO called IOMMUFD this is a departure from VFIO IOMMU Groups since it has only one device associated with an IOMMUFD entry. Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
@@ -792,11 +792,25 @@ func (q *qemu) createPCIeTopology(qemuConfig *govmmQemu.Config, hypervisorConfig
|
||||
return fmt.Errorf("Cannot get host path for device: %v err: %v", dev, err)
|
||||
}
|
||||
|
||||
devicesPerIOMMUGroup, err := drivers.GetAllVFIODevicesFromIOMMUGroup(dev)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Cannot get all VFIO devices from IOMMU group with device: %v err: %v", dev, err)
|
||||
vfioDevices := []*config.VFIODev{}
|
||||
// This works for IOMMUFD enabled kernels > 6.x
|
||||
// In the case of IOMMUFD the device.HostPath will look like
|
||||
// /dev/vfio/devices/vfio0
|
||||
// (1) Check if we have the new IOMMUFD or old container based VFIO
|
||||
if strings.HasPrefix(dev.HostPath, drivers.IommufdDevPath) {
|
||||
q.Logger().Infof("### IOMMUFD Path: %s", dev.HostPath)
|
||||
vfioDevices, err = drivers.GetDeviceFromVFIODev(dev)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Cannot get VFIO device from IOMMUFD with device: %v err: %v", dev, err)
|
||||
}
|
||||
} else {
|
||||
vfioDevices, err = drivers.GetAllVFIODevicesFromIOMMUGroup(dev)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Cannot get all VFIO devices from IOMMU group with device: %v err: %v", dev, err)
|
||||
}
|
||||
}
|
||||
for _, vfioDevice := range devicesPerIOMMUGroup {
|
||||
|
||||
for _, vfioDevice := range vfioDevices {
|
||||
if drivers.IsPCIeDevice(vfioDevice.BDF) {
|
||||
numOfPluggablePorts = numOfPluggablePorts + 1
|
||||
}
|
||||
|
Reference in New Issue
Block a user