summaryrefslogtreecommitdiff
path: root/xml.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-23 17:49:15 -0500
committerJeff Carr <[email protected]>2024-10-23 17:49:15 -0500
commita1593b0b88ec416e9dd2b3f62fcfebdc7957c5db (patch)
tree1c2a944a52325bf779848fd3e281ddddd9534437 /xml.go
parent57fdc99855caf7fe2abb9224abe6f980cc215079 (diff)
puts the spice port in the protobuf
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'xml.go')
-rw-r--r--xml.go73
1 files changed, 54 insertions, 19 deletions
diff --git a/xml.go b/xml.go
index 8ccd6d4..d50a368 100644
--- a/xml.go
+++ b/xml.go
@@ -160,6 +160,8 @@ func clearEthernet(domcfg *libvirtxml.Domain) {
// add a new ethernet interface with mac assigned to bridge name
func addEthernet(domcfg *libvirtxml.Domain, mac string, brname string) {
// Define a new disk with "mynew.qcow2"
+ type DomainInterfaceType string
+
newNet := libvirtxml.DomainInterface{
MAC: &libvirtxml.DomainInterfaceMAC{
Address: mac,
@@ -304,9 +306,12 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
domcfg.Memory = nil
domcfg.CurrentMemory = nil
domcfg.VCPU = nil
- if domcfg.CPU.Mode == "host-model" {
+ switch domcfg.CPU.Mode {
+ case "host-passthrough":
domcfg.CPU = nil
- } else {
+ case "host-model":
+ domcfg.CPU = nil
+ default:
fmt.Printf("? CPU Mode: %+v\n", domcfg.CPU.Mode)
}
@@ -351,6 +356,7 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
case "usb":
switch controller.Model {
case "ich9-ehci1":
+ case "qemu-xhci":
// fmt.Printf("OK USB: %s, %d\n", controller.Model, *controller.Index)
case "ich9-uhci1":
// 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")
case "virtio-serial":
// 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":
switch controller.Model {
case "lsilogic":
@@ -379,14 +388,23 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
normalPCI = false
}
case "pci":
- 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)
+ switch controller.Model {
+ case "pcie-root":
+ // pcie-root
+ case "pcie-root-port":
+ // pcie-root
+ 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:
- fmt.Printf("? %s: %+v\n", controller.Type, controller)
+ fmt.Printf("? controllerType: %s: %+v\n", controller.Type, controller)
normalPCI = false
keepPCI = append(keepPCI, controller)
}
@@ -419,17 +437,25 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) {
// ignore Graphics == Spice when AutoPort = 'yes'
var normalSpice bool = true
if domcfg.Devices.Graphics != nil {
- for _, g := range domcfg.Devices.Graphics {
- if g.Spice != nil {
- // 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" {
- normalSpice = false
- }
- } else {
+ for i, g := range domcfg.Devices.Graphics {
+ if g.Spice == nil {
+ // figure out what to do with non-spice stuff
+ fmt.Printf("Graphics: %d %+v\n", i, g)
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)
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