parent
e23c99d771
commit
065b9439a1
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue