init.go 676 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
package libenclave // import "github.com/opencontainers/runc/libenclave"

import (
	"github.com/opencontainers/runc/libcontainer/configs"
	"github.com/opencontainers/runc/libenclave/intelsgx"
)

var (
	enclaveHwType string = ""
)

func IsEnclaveEnabled(e *configs.Enclave) bool {
	if e == nil {
		return false
	}

	if !IsEnclaveHwEnabled(e.Type) {
		return false
	}

	return true
}

// Check whether enclave-based hardware is supported or not
func IsEnclaveHwEnabled(etype string) bool {
	if etype == "" && enclaveHwType != "" {
		return true
	}

	return etype == enclaveHwType
}

func init() {
	if intelsgx.IsSgxSupported() {
		enclaveHwType = configs.EnclaveHwIntelSgx
	}
}