// IsVFIOLargeBarSpaceDevice checks if the device is a large bar space device.
IsVFIOLargeBarSpaceDevice checks if the device is a large bar space device.
// IsVFIOLargeBarSpaceDevice checks if the device is a large bar space device .
func IsVFIOLargeBarSpaceDevice(hostPath string) (bool, error) {
	if !isVFIO(hostPath) {
		return false, nil
	}
	iommuDevicesPath := filepath.Join(config.SysIOMMUPath, filepath.Base(hostPath), "devices")
	deviceFiles, err := ioutil.ReadDir(iommuDevicesPath)
	if err != nil {
		return false, err
	}
	for _, deviceFile := range deviceFiles {
		vfioDeviceType := drivers.GetVFIODeviceType(deviceFile.Name())
		var isLarge bool
		switch vfioDeviceType {
		case config.VFIODeviceNormalType:
			sysfsResource := filepath.Join(iommuDevicesPath, deviceFile.Name(), "resource")
			if isLarge, err = isLargeBarSpace(sysfsResource); err != nil {
				return false, err
			}
			deviceLogger().WithFields(logrus.Fields{
				"device-file":     deviceFile.Name(),
				"device-type":     vfioDeviceType,
				"resource":        sysfsResource,
				"large-bar-space": isLarge,
			}).Info("Detect large bar space device")
			return isLarge, nil
		case config.VFIODeviceMediatedType:
			deviceLogger().WithFields(logrus.Fields{
				"device-file": deviceFile.Name(),
				"device-type": vfioDeviceType,
			}).Warn("Detect large bar space device is not yet supported for VFIODeviceMediatedType")
		default:
			deviceLogger().WithFields(logrus.Fields{
				"device-file": deviceFile.Name(),
				"device-type": vfioDeviceType,
			}).Warn("Incorrect token found when detecting large bar space devices")
		}
	}
	return false, nil
}
func IsVFIOLargeBarSpaceDevice ( hostPath string ) ( bool , error ) { if ! isVFIO ( hostPath ) { return false , nil } iommuDevicesPath := filepath . Join ( config . SysIOMMUPath , filepath . Base ( hostPath ) , " " ) deviceFiles , err := ioutil . ReadDir ( iommuDevicesPath ) if err != nil { return false , err } for _ , deviceFile := range deviceFiles { vfioDeviceType := drivers . GetVFIODeviceType ( deviceFile . Name ( ) ) var isLarge bool switch vfioDeviceType { case config . VFIODeviceNormalType : sysfsResource := filepath . Join ( iommuDevicesPath , deviceFile . Name ( ) , " " ) if isLarge , err = isLargeBarSpace ( sysfsResource ) ; err != nil { return false , err } deviceLogger ( ) . WithFields ( logrus . Fields { " " : deviceFile . Name ( ) , " " : vfioDeviceType , " " : sysfsResource , " " : isLarge , } ) . Info ( " " ) return isLarge , nil case config . VFIODeviceMediatedType : deviceLogger ( ) . WithFields ( logrus . Fields { " " : deviceFile . Name ( ) , " " : vfioDeviceType , } ) . Warn ( " " ) default : deviceLogger ( ) . WithFields ( logrus . Fields { " " : deviceFile . Name ( ) , " " : vfioDeviceType , } ) . Warn ( " " ) } } return false , nil }
IsVFIOLargeBarSpaceDevice checks if the device is a large bar space device.
IsVFIOLargeBarSpaceDevice checks if the device is a large bar space device .
// Pass all devices in iommu group //TODO: support VFIODeviceMediatedType