diff --git a/xml.go b/xml.go index e1a2aa5..85d2c66 100644 --- a/xml.go +++ b/xml.go @@ -427,14 +427,42 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) { domcfg.Devices.Channels = nil } - var domain libvirtxml.DomainDeviceList - t := reflect.TypeOf(domain) - - fmt.Println("Fields in libvirtxml.DomainDeviceList:") - for i := 0; i < t.NumField(); i++ { - field := t.Field(i) - fmt.Println(field.Name) + // this is probably for spice to have keyboard and mouse input + normalSpice = true + if domcfg.Devices.RedirDevs != nil { + for _, c := range domcfg.Devices.RedirDevs { + s := c.Source + if s != nil { + if s.SpiceVMC != nil { + // this is the normal USB redirection (I guess) + } else { + normalSpice = false + } + } else { + normalSpice = false + } + // fmt.Printf("? RedirDevs: %+v\n", c) + // fmt.Printf("? RedirDevs Source: %+v\n", s) + // fmt.Printf("? RedirDevs SpiceVMC: %d\n", *s.SpiceVMC) + // fmt.Printf("? RedirDevs Address: %+v\n", c.Address) + // fmt.Printf("? RedirDevs USB: %+v\n", c.Address.USB) + } } + if normalSpice { + domcfg.Devices.RedirDevs = nil + } + + // this is probably for spice to have keyboard and mouse input + var normalVideo bool = true + if domcfg.Devices.Videos != nil { + fmt.Printf("? Video: %+v\n", domcfg.Devices.Videos) + normalVideo = false + } + if normalVideo { + domcfg.Devices.Videos = nil + } + + // dumpLibvirtxmlDomain() updatedXML, err := xml.MarshalIndent(domcfg, "", " ") if err != nil { @@ -446,3 +474,15 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) { fmt.Println(string(updatedXML)) os.Exit(-1) } + +// dump out all the fields in libvirtxml.DomainDeviceList +func dumpLibvirtxmlDomain() { + var domain libvirtxml.DomainDeviceList + t := reflect.TypeOf(domain) + + fmt.Println("Fields in libvirtxml.DomainDeviceList:") + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + fmt.Println(field.Name) + } +}