Skip to content

Commit db803c3

Browse files
HuijingHeidustymabe
authored andcommitted
mantle: Support AMD SEV-SNP confidential instances on GCP
Fix #3556
1 parent 9b70c51 commit db803c3

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

mantle/cmd/kola/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func init() {
125125
sv(&kola.GCPOptions.ServiceAcct, "gcp-service-account", "", "GCP service account to attach to instance (default project default)")
126126
bv(&kola.GCPOptions.ServiceAuth, "gcp-service-auth", false, "for non-interactive auth when running within GCP")
127127
sv(&kola.GCPOptions.JSONKeyFile, "gcp-json-key", "", "use a service account's JSON key for authentication (default \"~/"+auth.GCPConfigPath+"\")")
128-
bv(&kola.GCPOptions.Confidential, "gcp-confidential-vm", false, "create confidential instances")
128+
sv(&kola.GCPOptions.ConfidentialType, "gcp-confidential-type", "", "create confidential instances: sev, sev_snp")
129129

130130
// openstack-specific options
131131
sv(&kola.OpenStackOptions.ConfigPath, "openstack-config-file", "", "Path to a clouds.yaml formatted OpenStack config file. The underlying library defaults to ./clouds.yaml")
@@ -245,9 +245,9 @@ func syncOptionsImpl(useCosa bool) error {
245245
if kolaPlatform == "gcp" && kola.GCPOptions.MachineType == "" {
246246
switch kola.Options.CosaBuildArch {
247247
case "x86_64":
248-
if kola.GCPOptions.Confidential {
248+
if kola.GCPOptions.ConfidentialType != "" {
249249
// https://cloud.google.com/compute/confidential-vm/docs/locations
250-
fmt.Print("Setting instance type for confidential computing")
250+
fmt.Printf("Setting instance type for confidential computing\n")
251251
kola.GCPOptions.MachineType = "n2d-standard-2"
252252
} else {
253253
kola.GCPOptions.MachineType = "n1-standard-1"

mantle/platform/api/gcloud/api.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ var (
3333
)
3434

3535
type Options struct {
36-
Image string
37-
Project string
38-
Zone string
39-
MachineType string
40-
DiskType string
41-
Network string
42-
ServiceAcct string
43-
JSONKeyFile string
44-
ServiceAuth bool
45-
Confidential bool
36+
Image string
37+
Project string
38+
Zone string
39+
MachineType string
40+
DiskType string
41+
Network string
42+
ServiceAcct string
43+
JSONKeyFile string
44+
ServiceAuth bool
45+
ConfidentialType string
4646
*platform.Options
4747
}
4848

mantle/platform/api/gcloud/compute.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,18 @@ func (a *API) mkinstance(userdata, name string, keys []*agent.Key, opts platform
147147
})
148148
}
149149
// create confidential instance
150-
if a.options.Confidential {
150+
ConfidentialType := strings.ToUpper(a.options.ConfidentialType)
151+
ConfidentialType = strings.Replace(ConfidentialType, "-", "_", -1)
152+
if ConfidentialType == "SEV" || ConfidentialType == "SEV_SNP" {
153+
fmt.Printf("Using confidential type for confidential computing %s\n", ConfidentialType)
151154
instance.ConfidentialInstanceConfig = &compute.ConfidentialInstanceConfig{
152-
EnableConfidentialCompute: true,
155+
ConfidentialInstanceType: ConfidentialType,
153156
}
154157
instance.Scheduling = &compute.Scheduling{
155158
OnHostMaintenance: "TERMINATE",
156159
}
160+
} else {
161+
return nil, fmt.Errorf("Does not support confidential type %s, should be: sev, sev_snp\n", a.options.ConfidentialType)
157162
}
158163
// attach aditional disk
159164
for _, spec := range opts.AdditionalDisks {

0 commit comments

Comments
 (0)