virtcontainers: Add func AvailableGuestProtections

Add functions to return guestProtection as a string slice, which
can be then used in `kata-runtime env` output.

Signed-off-by: Yujia Qiao <rapiz3142@gmail.com>
This commit is contained in:
Yujia Qiao 2021-08-24 17:51:57 +08:00
parent 3d0fe433c6
commit 2063b13805
No known key found for this signature in database
GPG Key ID: DC129173B148701B

View File

@ -177,6 +177,30 @@ const (
seProtection //nolint
)
var guestProtectionStr = [...]string{
noneProtection: "none",
tdxProtection: "tdx",
sevProtection: "sev",
pefProtection: "pef",
seProtection: "se",
}
func (gp guestProtection) String() string {
return guestProtectionStr[gp]
}
func genericAvailableGuestProtections() (protections []string) {
return
}
func AvailableGuestProtections() (protections []string) {
gp, err := availableGuestProtection()
if err != nil || gp == noneProtection {
return genericAvailableGuestProtections()
}
return []string{gp.String()}
}
type qemuArchBase struct {
qemuExePath string
qemuMachine govmmQemu.Machine