mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-03-18 02:32:26 +00:00
If we have a VFIO device and cold-plug is enabled we mark each device as ColdPlug=true and let the VFIO module do the attaching. Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// Copyright (c) 2017-2018 Intel Corporation
|
|
// Copyright (c) 2018 Huawei Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package manager
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
|
)
|
|
|
|
const (
|
|
vfioPath = "/dev/vfio/"
|
|
)
|
|
|
|
// IsVFIO checks if the device provided is a vfio group.
|
|
func IsVFIO(hostPath string) bool {
|
|
// Ignore /dev/vfio/vfio character device
|
|
if strings.HasPrefix(hostPath, filepath.Join(vfioPath, "vfio")) {
|
|
return false
|
|
}
|
|
|
|
if strings.HasPrefix(hostPath, vfioPath) && len(hostPath) > len(vfioPath) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// isBlock checks if the device is a block device.
|
|
func isBlock(devInfo config.DeviceInfo) bool {
|
|
return devInfo.DevType == "b"
|
|
}
|
|
|
|
// isVhostUserBlk checks if the device is a VhostUserBlk device.
|
|
func isVhostUserBlk(devInfo config.DeviceInfo) bool {
|
|
return devInfo.DevType == "b" && devInfo.Major == config.VhostUserBlkMajor
|
|
}
|
|
|
|
// isVhostUserSCSI checks if the device is a VhostUserSCSI device.
|
|
func isVhostUserSCSI(devInfo config.DeviceInfo) bool {
|
|
return devInfo.DevType == "b" && devInfo.Major == config.VhostUserSCSIMajor
|
|
}
|