puts the spice port in the protobuf
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
57fdc99855
commit
a1593b0b88
|
@ -115,6 +115,26 @@ func updateDroplet(d *DropletT, domcfg *libvirtxml.Domain) bool {
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update spice port
|
||||||
|
if domcfg.Devices.Graphics != nil {
|
||||||
|
for _, g := range domcfg.Devices.Graphics {
|
||||||
|
if g.Spice == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var s *libvirtxml.DomainGraphicSpice
|
||||||
|
s = g.Spice
|
||||||
|
// fmt.Printf("Spice: %d %+v %s\n", i, s, s.AutoPort)
|
||||||
|
if s.AutoPort == "yes" {
|
||||||
|
// should ignore either way
|
||||||
|
} else {
|
||||||
|
// print out, but ignore the port number
|
||||||
|
d.pb.SpicePort = int64(s.Port)
|
||||||
|
fmt.Printf("Spice Port set to = %d\n", s.Port)
|
||||||
|
me.changed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check type
|
// check type
|
||||||
if domcfg.Type != "kvm" {
|
if domcfg.Type != "kvm" {
|
||||||
fmt.Printf("not kvm. Virt type == %s\n", domcfg.Type)
|
fmt.Printf("not kvm. Virt type == %s\n", domcfg.Type)
|
||||||
|
@ -139,6 +159,10 @@ func updateMemory(d *DropletT, domcfg *libvirtxml.Domain) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if domcfg.Memory == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// check memory
|
// check memory
|
||||||
if domcfg.Memory.Unit == "KiB" {
|
if domcfg.Memory.Unit == "KiB" {
|
||||||
var m int64
|
var m int64
|
||||||
|
@ -185,6 +209,11 @@ func updateNetwork(d *DropletT, domcfg *libvirtxml.Domain) bool {
|
||||||
var macs []string
|
var macs []string
|
||||||
// Iterate over the network interfaces and print the MAC addresses
|
// Iterate over the network interfaces and print the MAC addresses
|
||||||
for _, iface := range domcfg.Devices.Interfaces {
|
for _, iface := range domcfg.Devices.Interfaces {
|
||||||
|
// fmt.Printf("iface: %+v\n", iface)
|
||||||
|
// fmt.Printf("MAC: %+v\n", iface.MAC)
|
||||||
|
// fmt.Printf("Source: %+v\n", iface.Source)
|
||||||
|
// fmt.Printf("Bridge: %+v\n", iface.Source.Bridge)
|
||||||
|
// fmt.Printf("Model: %+v\n", iface.Model)
|
||||||
if iface.MAC != nil {
|
if iface.MAC != nil {
|
||||||
// iface.MAC.Address = "aa:bb:aa:bb:aa:ff"
|
// iface.MAC.Address = "aa:bb:aa:bb:aa:ff"
|
||||||
// fmt.Printf("MAC Address: %+v\n", iface.MAC)
|
// fmt.Printf("MAC Address: %+v\n", iface.MAC)
|
||||||
|
|
73
xml.go
73
xml.go
|
@ -160,6 +160,8 @@ func clearEthernet(domcfg *libvirtxml.Domain) {
|
||||||
// add a new ethernet interface with mac assigned to bridge name
|
// add a new ethernet interface with mac assigned to bridge name
|
||||||
func addEthernet(domcfg *libvirtxml.Domain, mac string, brname string) {
|
func addEthernet(domcfg *libvirtxml.Domain, mac string, brname string) {
|
||||||
// Define a new disk with "mynew.qcow2"
|
// Define a new disk with "mynew.qcow2"
|
||||||
|
type DomainInterfaceType string
|
||||||
|
|
||||||
newNet := libvirtxml.DomainInterface{
|
newNet := libvirtxml.DomainInterface{
|
||||||
MAC: &libvirtxml.DomainInterfaceMAC{
|
MAC: &libvirtxml.DomainInterfaceMAC{
|
||||||
Address: mac,
|
Address: mac,
|
||||||
|
@ -304,9 +306,12 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
|
||||||
domcfg.Memory = nil
|
domcfg.Memory = nil
|
||||||
domcfg.CurrentMemory = nil
|
domcfg.CurrentMemory = nil
|
||||||
domcfg.VCPU = nil
|
domcfg.VCPU = nil
|
||||||
if domcfg.CPU.Mode == "host-model" {
|
switch domcfg.CPU.Mode {
|
||||||
|
case "host-passthrough":
|
||||||
domcfg.CPU = nil
|
domcfg.CPU = nil
|
||||||
} else {
|
case "host-model":
|
||||||
|
domcfg.CPU = nil
|
||||||
|
default:
|
||||||
fmt.Printf("? CPU Mode: %+v\n", domcfg.CPU.Mode)
|
fmt.Printf("? CPU Mode: %+v\n", domcfg.CPU.Mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +356,7 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
|
||||||
case "usb":
|
case "usb":
|
||||||
switch controller.Model {
|
switch controller.Model {
|
||||||
case "ich9-ehci1":
|
case "ich9-ehci1":
|
||||||
|
case "qemu-xhci":
|
||||||
// fmt.Printf("OK USB: %s, %d\n", controller.Model, *controller.Index)
|
// fmt.Printf("OK USB: %s, %d\n", controller.Model, *controller.Index)
|
||||||
case "ich9-uhci1":
|
case "ich9-uhci1":
|
||||||
// fmt.Printf("OK USB: %s, %d\n", controller.Model, *controller.Index)
|
// fmt.Printf("OK USB: %s, %d\n", controller.Model, *controller.Index)
|
||||||
|
@ -370,6 +376,9 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
|
||||||
// fmt.Printf("IGNORE IDE\n")
|
// fmt.Printf("IGNORE IDE\n")
|
||||||
case "virtio-serial":
|
case "virtio-serial":
|
||||||
// fmt.Printf("IGNORE virtio-serial\n")
|
// fmt.Printf("IGNORE virtio-serial\n")
|
||||||
|
case "sata":
|
||||||
|
// fmt.Printf("SATA: %s, %d\n", controller.Model, *controller.Index)
|
||||||
|
// fmt.Printf("SATA: %+v\n", controller)
|
||||||
case "scsi":
|
case "scsi":
|
||||||
switch controller.Model {
|
switch controller.Model {
|
||||||
case "lsilogic":
|
case "lsilogic":
|
||||||
|
@ -379,14 +388,23 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
|
||||||
normalPCI = false
|
normalPCI = false
|
||||||
}
|
}
|
||||||
case "pci":
|
case "pci":
|
||||||
fmt.Printf("PCI: %s, %d\n", controller.Model, *controller.Index)
|
switch controller.Model {
|
||||||
// Domain:0xc0002d2760 Bus:0xc0002d2768 Slot:0xc0002d2770 Function:0xc0002d2778 MultiFunction:
|
case "pcie-root":
|
||||||
pci := controller.Address.PCI
|
// pcie-root
|
||||||
fmt.Printf("PCI: Domain: %+v Slot %d Function %d\n", *pci.Domain, *pci.Slot, *pci.Function)
|
case "pcie-root-port":
|
||||||
normalPCI = false
|
// pcie-root
|
||||||
keepPCI = append(keepPCI, controller)
|
case "pcie-to-pci-bridge":
|
||||||
|
// pcie-root
|
||||||
|
default:
|
||||||
|
fmt.Printf("PCI: %s, %d\n", controller.Model, *controller.Index)
|
||||||
|
// Domain:0xc0002d2760 Bus:0xc0002d2768 Slot:0xc0002d2770 Function:0xc0002d2778 MultiFunction:
|
||||||
|
pci := controller.Address.PCI
|
||||||
|
fmt.Printf("PCI: Domain: %+v Slot %d Function %d\n", *pci.Domain, *pci.Slot, *pci.Function)
|
||||||
|
normalPCI = false
|
||||||
|
keepPCI = append(keepPCI, controller)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
fmt.Printf("? %s: %+v\n", controller.Type, controller)
|
fmt.Printf("? controllerType: %s: %+v\n", controller.Type, controller)
|
||||||
normalPCI = false
|
normalPCI = false
|
||||||
keepPCI = append(keepPCI, controller)
|
keepPCI = append(keepPCI, controller)
|
||||||
}
|
}
|
||||||
|
@ -419,17 +437,25 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
|
||||||
// ignore Graphics == Spice when AutoPort = 'yes'
|
// ignore Graphics == Spice when AutoPort = 'yes'
|
||||||
var normalSpice bool = true
|
var normalSpice bool = true
|
||||||
if domcfg.Devices.Graphics != nil {
|
if domcfg.Devices.Graphics != nil {
|
||||||
for _, g := range domcfg.Devices.Graphics {
|
for i, g := range domcfg.Devices.Graphics {
|
||||||
if g.Spice != nil {
|
if g.Spice == nil {
|
||||||
// fmt.Printf("Graphics: %d %+v\n", i, g)
|
// figure out what to do with non-spice stuff
|
||||||
var s *libvirtxml.DomainGraphicSpice
|
fmt.Printf("Graphics: %d %+v\n", i, g)
|
||||||
s = g.Spice
|
|
||||||
// fmt.Printf("Spice: %d %+v %s\n", i, s, s.AutoPort)
|
|
||||||
if s.AutoPort != "yes" {
|
|
||||||
normalSpice = false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
normalSpice = false
|
normalSpice = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// this is a spice definition, just ignore it
|
||||||
|
// because port mappings and network access will be handled
|
||||||
|
// somewhere else someday
|
||||||
|
// fmt.Printf("Graphics: %d %+v\n", i, g)
|
||||||
|
var s *libvirtxml.DomainGraphicSpice
|
||||||
|
s = g.Spice
|
||||||
|
// fmt.Printf("Spice: %d %+v %s\n", i, s, s.AutoPort)
|
||||||
|
if s.AutoPort == "yes" {
|
||||||
|
// should ignore either way
|
||||||
|
} else {
|
||||||
|
// print out, but ignore the port number
|
||||||
|
fmt.Printf("Spice Port = %d\n", s.Port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,6 +572,15 @@ func dumpLibvirtxmlDomainNames() {
|
||||||
field := t.Field(i)
|
field := t.Field(i)
|
||||||
fmt.Println("DomainDeviceList:", field.Name)
|
fmt.Println("DomainDeviceList:", field.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var iface libvirtxml.DomainInterface
|
||||||
|
t = reflect.TypeOf(iface)
|
||||||
|
|
||||||
|
fmt.Println("Fields in libvirtxml.DomainInterface:")
|
||||||
|
for i := 0; i < t.NumField(); i++ {
|
||||||
|
field := t.Field(i)
|
||||||
|
fmt.Println("DomainInterface:", field.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump out all the fields in libvirtxml.DomainDeviceList
|
// dump out all the fields in libvirtxml.DomainDeviceList
|
||||||
|
|
Loading…
Reference in New Issue