aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/gce
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-08-08 11:55:31 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-08-08 11:16:27 +0000
commitec891e3f8645fb1e5090bff887366c6c57b21e58 (patch)
tree56a59dcdd50d7965f9f7a5f608fbdaf3cbbba350 /pkg/gce
parent009315f7208df39036fe2bac7c9b2ec910e6a5c6 (diff)
pkg/gce: set GVNIC feature for Compute images
Google Cloud cannot automatically infer it from our images, so we need to explicitly set it. The flag is required to create a GVNIC-based GCE instance (the only type for C4A machines).
Diffstat (limited to 'pkg/gce')
-rw-r--r--pkg/gce/gce.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/gce/gce.go b/pkg/gce/gce.go
index 20aee4c7c..7100665ef 100644
--- a/pkg/gce/gce.go
+++ b/pkg/gce/gce.go
@@ -22,6 +22,7 @@ import (
"strings"
"time"
+ "github.com/google/syzkaller/sys/targets"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
@@ -254,7 +255,15 @@ func (ctx *Context) IsInstanceRunning(name string) bool {
return inst.Status == "RUNNING"
}
-func (ctx *Context) CreateImage(imageName, gcsFile string) error {
+func (ctx *Context) CreateImage(imageName, gcsFile, OS string) error {
+ var features []*compute.GuestOsFeature
+ if OS == targets.Linux {
+ features = []*compute.GuestOsFeature{
+ {
+ Type: "GVNIC",
+ },
+ }
+ }
image := &compute.Image{
Name: imageName,
RawDisk: &compute.ImageRawDisk{
@@ -263,6 +272,7 @@ func (ctx *Context) CreateImage(imageName, gcsFile string) error {
Licenses: []string{
"https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx",
},
+ GuestOsFeatures: features,
}
var op *compute.Operation
err := ctx.apiCall(func() (err error) {