mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-26 02:24:21 +01:00
gometalinter is deprecated and will be archived April '19. The suggestion is to switch to golangci-lint which is apparently 5x faster than gometalinter. Partially Fixes: #1377 Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
38 lines
758 B
Go
38 lines
758 B
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/runtime/virtcontainers/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"
|
|
}
|