From 9b5bf4cde89c7042ba16872f3a663e1be5d86638 Mon Sep 17 00:00:00 2001 From: Kris Alder Date: Tue, 23 Aug 2022 09:11:43 -0700 Subject: pkg/gce, vm/gce: add param to enable nested virtualization This is needed for Cuttlefish-on-GCE. It adds the field 'nested_virt' to the config file and then passes it through to the relevant field in the call to gce.CreateInstance(). --- pkg/gce/gce.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/gce/gce.go b/pkg/gce/gce.go index 4e797ade6..542cf1650 100644 --- a/pkg/gce/gce.go +++ b/pkg/gce/gce.go @@ -43,6 +43,12 @@ type Context struct { apiRateGate <-chan time.Time } +type CreateArgs struct { + Preemptible bool + DisplayDevice bool + NestedVirt bool +} + func NewContext(customZoneID string) (*Context, error) { ctx := &Context{ apiRateGate: time.NewTicker(time.Second).C, @@ -103,7 +109,7 @@ func NewContext(customZoneID string) (*Context, error) { } func (ctx *Context) CreateInstance(name, machineType, image, sshkey string, - preemptible, displayDevice bool) (string, error) { + args CreateArgs) (string, error) { prefix := "https://www.googleapis.com/compute/v1/projects/" + ctx.ProjectID sshkeyAttr := "syzkaller:" + sshkey oneAttr := "1" @@ -143,11 +149,14 @@ func (ctx *Context) CreateInstance(name, machineType, image, sshkey string, }, Scheduling: &compute.Scheduling{ AutomaticRestart: &falseAttr, - Preemptible: preemptible, + Preemptible: args.Preemptible, OnHostMaintenance: "TERMINATE", }, DisplayDevice: &compute.DisplayDevice{ - EnableDisplay: displayDevice, + EnableDisplay: args.DisplayDevice, + }, + AdvancedMachineFeatures: &compute.AdvancedMachineFeatures{ + EnableNestedVirtualization: args.NestedVirt, }, } retry: -- cgit mrf-deployment