// Copyright 2024 WIT.COM Inc Licensed GPL 3.0 package virtigolib import ( "errors" "fmt" pb "go.wit.com/lib/protobuf/virtbuf" "libvirt.org/go/libvirtxml" ) func SetSpicePort(d *pb.Droplet, domcfg *libvirtxml.Domain) error { if domcfg.Devices.Graphics == nil { return errors.New("no graphics") } for i, g := range domcfg.Devices.Graphics { if g.VNC != nil { // ignore vnc settings fmt.Printf("Ignore Graphics VNC settings: %d %+v\n", i, g) continue } if g.Spice != nil { var s *libvirtxml.DomainGraphicSpice s = g.Spice if s.AutoPort == "yes" { s.AutoPort = "no" } s.Port = int(d.SpicePort) fmt.Printf("setting spice port to %d\n", d.SpicePort) continue } // figure out what to do with non-spice stuff fmt.Printf("Unknown Graphics: %d %+v\n", i, g) } return nil }