more migrations done

This commit is contained in:
Matthew Stobbs 2024-03-20 15:45:25 -06:00
parent 3862e3d4e9
commit 99fcb2b360

View File

@ -303,58 +303,46 @@ func (h *Host) getDomainInfo() {
log.Println(err) log.Println(err)
} }
if len(doms) > 0 { if len(doms) > 0 {
h.VMList = make([]VMInfo, len(doms)) h.VMList = make([]*libvirtxml.Domain, len(doms))
for i, d := range doms { for i, d := range doms {
// Just going to log errors here, and free the dom after getting what we can func() {
if h.VMList[i].Name, err = d.GetName(); err != nil { defer d.Free()
log.Println(err) rawxml, err := d.GetXMLDesc(0)
if err != nil {
log.Printf("error getting domain XML: %s", err)
} }
if h.VMList[i].UUID, err = d.GetUUID(); err != nil { h.VMList[i] = &libvirtxml.Domain{}
log.Println(err) if err = h.VMList[i].Unmarshal(rawxml); err != nil {
} log.Printf("error parsing domain XML: %s", err)
if h.VMList[i].ID, err = d.GetID(); err != nil {
log.Println(err)
}
if h.VMList[i].XML, err = d.GetXMLDesc(0); err != nil {
log.Println(err)
}
vmXML := &libvirtxml.Domain{}
if err = vmXML.Unmarshal(h.VMList[i].XML); err != nil {
log.Println(err)
}
h.VMList[i].VCPUs = vmXML.VCPU.Value
h.VMList[i].Memory = vmXML.CurrentMemory.Value
if h.VMList[i].Active, err = d.IsActive(); err != nil {
log.Println(err)
} }
}()
d.Free()
} }
} }
} }
func (h *Host) getIfaceInfo() { func (h *Host) getIfaceInfo() {
// getIfaceInfo // getIfaceInfo
ifaces, err := h.conn.ListInterfaces() ifaces, err := h.conn.ListAllInterfaces(0)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
if len(ifaces) > 0 { if len(ifaces) > 0 {
h.NetIfFList = make([]NetIfInfo, len(ifaces)) h.NetIfFList = make([]*libvirtxml.Interface, len(ifaces))
for i, ni := range ifaces { for i, ni := range ifaces {
h.NetIfFList[i].Name = ni func() {
iface, err := h.conn.LookupInterfaceByName(ni) defer ni.Free()
rawxml, err := ni.GetXMLDesc(0)
if err != nil { if err != nil {
log.Println(err) log.Printf("error getting interface XML: %s")
return
} }
if h.NetIfFList[i].MacAddr, err = iface.GetMACString(); err != nil { h.NetIfFList[i] = &libvirtxml.Interface{}
log.Println(err) if err = h.NetIfFList[i].Unmarshal(rawxml); err != nil {
log.Printf("error parsing interface XML: %s")
return
} }
if h.NetIfFList[i].XML, err = iface.GetXMLDesc(0); err != nil { }()
log.Println(err)
}
iface.Free()
} }
} }
} }