diff options
| author | Jeff Carr <[email protected]> | 2024-10-27 05:44:29 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-27 05:44:29 -0500 |
| commit | 065b9439a13ac6ea07eafde08fdb49af7b661c0e (patch) | |
| tree | d8c44e317181df2a5ca3e8194417095682ccdda6 /spice.go | |
| parent | e23c99d7717524114dc0ad00570cd6403229db75 (diff) | |
set spice port
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'spice.go')
| -rw-r--r-- | spice.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spice.go b/spice.go new file mode 100644 index 0000000..b5334b3 --- /dev/null +++ b/spice.go @@ -0,0 +1,37 @@ +// Copyright 2024 WIT.COM Inc Licensed GPL 3.0 + +package virtigoxml + +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 +} |
