mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-24 01:24:26 +01:00
virtcontainers/utils: Implement function to check vsocks support
Implement function to check if the system has support for vsocks. This function looks for vsock and vhost-vsock devices returning true if those exist, otherwise false. Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com> Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
@@ -23,6 +23,12 @@ const fileMode0755 = os.FileMode(0755)
|
||||
// See unix(7).
|
||||
const MaxSocketPathLen = 107
|
||||
|
||||
// VSockDevicePath path to vsock device
|
||||
var VSockDevicePath = "/dev/vsock"
|
||||
|
||||
// VHostVSockDevicePath path to vhost-vsock device
|
||||
var VHostVSockDevicePath = "/dev/vhost-vsock"
|
||||
|
||||
// FileCopy copys files from srcPath to dstPath
|
||||
func FileCopy(srcPath, dstPath string) error {
|
||||
if srcPath == "" {
|
||||
@@ -200,3 +206,16 @@ func BuildSocketPath(elements ...string) (string, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SupportsVsocks returns true if vsocks are supported, otherwise false
|
||||
func SupportsVsocks() bool {
|
||||
if _, err := os.Stat(VSockDevicePath); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if _, err := os.Stat(VHostVSockDevicePath); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user