@@ -24,11 +24,22 @@ const (
2424 MetalQEMUSNPGPU
2525 // MetalQEMUTDXGPU is the generic platform for bare-metal TDX deployments with GPU passthrough.
2626 MetalQEMUTDXGPU
27+ // MetalQEMUSNPInsecure is the platform for bare-metal SNP deployments with a non-CC runtime class.
28+ MetalQEMUSNPInsecure
29+ // MetalQEMUTDXInsecure is the platform for bare-metal TDX deployments with a non-CC runtime class.
30+ MetalQEMUTDXInsecure
31+ // MetalQEMUSNPGPUInsecure is the platform for bare-metal SNP deployments with GPU passthrough and a non-CC runtime class.
32+ MetalQEMUSNPGPUInsecure
33+ // MetalQEMUTDXGPUInsecure is the platform for bare-metal TDX deployments with GPU passthrough and a non-CC runtime class.
34+ MetalQEMUTDXGPUInsecure
2735)
2836
2937// All returns a list of all available platforms.
3038func All () []Platform {
31- return []Platform {MetalQEMUSNP , MetalQEMUTDX , MetalQEMUSNPGPU , MetalQEMUTDXGPU }
39+ return []Platform {
40+ MetalQEMUSNP , MetalQEMUTDX , MetalQEMUSNPGPU , MetalQEMUTDXGPU ,
41+ MetalQEMUSNPInsecure , MetalQEMUTDXInsecure , MetalQEMUSNPGPUInsecure , MetalQEMUTDXGPUInsecure ,
42+ }
3243}
3344
3445// AllStrings returns a list of all available platforms as strings.
@@ -51,11 +62,36 @@ func (p Platform) String() string {
5162 return "Metal-QEMU-TDX"
5263 case MetalQEMUTDXGPU :
5364 return "Metal-QEMU-TDX-GPU"
65+ case MetalQEMUSNPInsecure :
66+ return "Metal-QEMU-SNP-Insecure"
67+ case MetalQEMUTDXInsecure :
68+ return "Metal-QEMU-TDX-Insecure"
69+ case MetalQEMUSNPGPUInsecure :
70+ return "Metal-QEMU-SNP-GPU-Insecure"
71+ case MetalQEMUTDXGPUInsecure :
72+ return "Metal-QEMU-TDX-GPU-Insecure"
5473 default :
5574 return "Unknown"
5675 }
5776}
5877
78+ // InsecureVariant returns the insecure (non-CC) variant of the
79+ // platform, or Unknown if there is no such variant.
80+ func (p Platform ) InsecureVariant () Platform {
81+ switch p {
82+ case MetalQEMUSNP :
83+ return MetalQEMUSNPInsecure
84+ case MetalQEMUTDX :
85+ return MetalQEMUTDXInsecure
86+ case MetalQEMUSNPGPU :
87+ return MetalQEMUSNPGPUInsecure
88+ case MetalQEMUTDXGPU :
89+ return MetalQEMUTDXGPUInsecure
90+ default :
91+ return Unknown
92+ }
93+ }
94+
5995// MarshalJSON marshals a Platform type to a JSON string.
6096func (p Platform ) MarshalJSON () ([]byte , error ) {
6197 return fmt .Appendf (nil , `"%s"` , p .String ()), nil
@@ -99,6 +135,14 @@ func FromString(s string) (Platform, error) {
99135 return MetalQEMUTDX , nil
100136 case "metal-qemu-tdx-gpu" :
101137 return MetalQEMUTDXGPU , nil
138+ case "metal-qemu-snp-insecure" :
139+ return MetalQEMUSNPInsecure , nil
140+ case "metal-qemu-tdx-insecure" :
141+ return MetalQEMUTDXInsecure , nil
142+ case "metal-qemu-snp-gpu-insecure" :
143+ return MetalQEMUSNPGPUInsecure , nil
144+ case "metal-qemu-tdx-gpu-insecure" :
145+ return MetalQEMUTDXGPUInsecure , nil
102146 default :
103147 return Unknown , fmt .Errorf ("unknown platform: %s" , s )
104148 }
@@ -121,10 +165,18 @@ func FromRuntimeClassString(s string) (Platform, error) {
121165 return MetalQEMUSNPGPU , nil
122166 case strings .HasPrefix (s , "contrast-cc-metal-qemu-snp" ):
123167 return MetalQEMUSNP , nil
168+ case strings .HasPrefix (s , "contrast-insecure-metal-qemu-snp-gpu" ):
169+ return MetalQEMUSNPGPUInsecure , nil
170+ case strings .HasPrefix (s , "contrast-insecure-metal-qemu-snp" ):
171+ return MetalQEMUSNPInsecure , nil
124172 case strings .HasPrefix (s , "contrast-cc-metal-qemu-tdx-gpu" ):
125173 return MetalQEMUTDXGPU , nil
126174 case strings .HasPrefix (s , "contrast-cc-metal-qemu-tdx" ):
127175 return MetalQEMUTDX , nil
176+ case strings .HasPrefix (s , "contrast-insecure-metal-qemu-tdx-gpu" ):
177+ return MetalQEMUTDXGPUInsecure , nil
178+ case strings .HasPrefix (s , "contrast-insecure-metal-qemu-tdx" ):
179+ return MetalQEMUTDXInsecure , nil
128180 default :
129181 return Unknown , fmt .Errorf ("unknown platform: %s" , s )
130182 }
@@ -133,7 +185,7 @@ func FromRuntimeClassString(s string) (Platform, error) {
133185// DefaultMemoryInMebiBytes returns the desired VM overhead for the given platform.
134186func DefaultMemoryInMebiBytes (p Platform ) int {
135187 switch p {
136- case MetalQEMUSNPGPU , MetalQEMUTDXGPU :
188+ case MetalQEMUSNPGPU , MetalQEMUTDXGPU , MetalQEMUSNPGPUInsecure , MetalQEMUTDXGPUInsecure :
137189 // Guest components contribute around 600MiB with GPU enabled.
138190 return 1024
139191 default :
@@ -144,6 +196,16 @@ func DefaultMemoryInMebiBytes(p Platform) int {
144196 }
145197}
146198
199+ // IsInsecure returns true if the platform is an insecure (non-CC) platform.
200+ func IsInsecure (p Platform ) bool {
201+ switch p {
202+ case MetalQEMUSNPInsecure , MetalQEMUTDXInsecure , MetalQEMUSNPGPUInsecure , MetalQEMUTDXGPUInsecure :
203+ return true
204+ default :
205+ return false
206+ }
207+ }
208+
147209// IsSNP returns true if the platform is a SEV-SNP platform.
148210func IsSNP (p Platform ) bool {
149211 switch p {
@@ -167,7 +229,7 @@ func IsTDX(p Platform) bool {
167229// IsGPU returns true if the platform supports GPUs.
168230func IsGPU (p Platform ) bool {
169231 switch p {
170- case MetalQEMUSNPGPU , MetalQEMUTDXGPU :
232+ case MetalQEMUSNPGPU , MetalQEMUTDXGPU , MetalQEMUSNPGPUInsecure , MetalQEMUTDXGPUInsecure :
171233 return true
172234 default :
173235 return false
@@ -177,7 +239,8 @@ func IsGPU(p Platform) bool {
177239// IsQEMU returns true if the platform uses QEMU as the hypervisor.
178240func IsQEMU (p Platform ) bool {
179241 switch p {
180- case MetalQEMUSNP , MetalQEMUSNPGPU , MetalQEMUTDX , MetalQEMUTDXGPU :
242+ case MetalQEMUSNP , MetalQEMUSNPGPU , MetalQEMUTDX , MetalQEMUTDXGPU ,
243+ MetalQEMUSNPInsecure , MetalQEMUTDXInsecure , MetalQEMUSNPGPUInsecure , MetalQEMUTDXGPUInsecure :
181244 return true
182245 default :
183246 return false
@@ -191,6 +254,10 @@ func (p Platform) WithGPU() Platform {
191254 return MetalQEMUSNPGPU
192255 case MetalQEMUTDX , MetalQEMUTDXGPU :
193256 return MetalQEMUTDXGPU
257+ case MetalQEMUSNPInsecure , MetalQEMUSNPGPUInsecure :
258+ return MetalQEMUSNPGPUInsecure
259+ case MetalQEMUTDXInsecure , MetalQEMUTDXGPUInsecure :
260+ return MetalQEMUTDXGPUInsecure
194261 default :
195262 return Unknown
196263 }
0 commit comments