virtcontainers: Add func AvailableGuestProtections
Add functions to return guestProtection as a string slice, which
can be then used in `kata-runtime env` output.
@@ -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
