From 1b51e9a3ba38bfe09679fe437cece6645a6105d5 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Thu, 15 Jan 2026 13:32:54 +0100 Subject: pkg/gce: vm/gce: allow specifying instance tags in manager config GCE instance tags can be used for various purposes, such as applying network firewall rules or filtering VMs for scheduling onto specific hosts. To support these use cases, syzkaller needs the ability to set instance tags during VM creation. This patch introduces a new tags field to the gce VM configuration that allows users to specify a list of tags to be attached to GCE instances created by syz-manager. --- pkg/gce/gce.go | 3 ++- vm/gce/gce.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/gce/gce.go b/pkg/gce/gce.go index 7100665ef..4a5491e25 100644 --- a/pkg/gce/gce.go +++ b/pkg/gce/gce.go @@ -118,7 +118,7 @@ func NewContext(customZoneID string) (*Context, error) { } func (ctx *Context) CreateInstance(name, machineType, image, sshkey string, - preemptible, displayDevice bool) (string, error) { + tags []string, preemptible, displayDevice bool) (string, error) { prefix := "https://www.googleapis.com/compute/v1/projects/" + ctx.ProjectID sshkeyAttr := "syzkaller:" + sshkey oneAttr := "1" @@ -165,6 +165,7 @@ func (ctx *Context) CreateInstance(name, machineType, image, sshkey string, DisplayDevice: &compute.DisplayDevice{ EnableDisplay: displayDevice, }, + Tags: &compute.Tags{Items: tags}, } retry: if !instance.Scheduling.Preemptible && strings.HasPrefix(machineType, "e2-") { diff --git a/vm/gce/gce.go b/vm/gce/gce.go index a830a9889..90b12c89f 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -59,7 +59,8 @@ type Config struct { // Leave empty for non-OS Login GCP projects. // Otherwise generate one and upload it: // `gcloud compute os-login ssh-keys add --key-file some-key.pub`. - SerialPortKey string `json:"serial_port_key"` + SerialPortKey string `json:"serial_port_key"` + Tags []string `json:"tags"` // GCE instance tags } type Pool struct { @@ -195,7 +196,7 @@ func (pool *Pool) Create(_ context.Context, workdir string, index int) (vmimpl.I } log.Logf(0, "creating instance: %v", name) ip, err := pool.GCE.CreateInstance(name, pool.cfg.MachineType, pool.cfg.GCEImage, - string(gceKeyPub), pool.cfg.Preemptible, pool.cfg.DisplayDevice) + string(gceKeyPub), pool.cfg.Tags, pool.cfg.Preemptible, pool.cfg.DisplayDevice) if err != nil { return nil, err } -- cgit mrf-deployment