more migrations done

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

View File

@ -176,10 +176,10 @@ func (h *Host) memoryInfo() {
log.Println(err) log.Println(err)
} }
h.NodeMemory = &NodeMemoryInfo{ h.NodeMemory = &NodeMemoryInfo{
Total: mi.Total, Total: mi.Total,
Free: mi.Free, Free: mi.Free,
Buffers: mi.Buffers, Buffers: mi.Buffers,
Cached: mi.Cached, Cached: mi.Cached,
} }
h.SysInfo, err = h.conn.GetSysinfo(0) h.SysInfo, err = h.conn.GetSysinfo(0)
@ -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 {
if h.VMList[i].UUID, err = d.GetUUID(); err != nil { log.Printf("error getting domain XML: %s", err)
log.Println(err) }
} h.VMList[i] = &libvirtxml.Domain{}
if h.VMList[i].ID, err = d.GetID(); err != nil { if err = h.VMList[i].Unmarshal(rawxml); err != nil {
log.Println(err) log.Printf("error parsing domain XML: %s", 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()
if err != nil { rawxml, err := ni.GetXMLDesc(0)
log.Println(err) if err != nil {
} log.Printf("error getting interface XML: %s")
if h.NetIfFList[i].MacAddr, err = iface.GetMACString(); err != nil { return
log.Println(err) }
} h.NetIfFList[i] = &libvirtxml.Interface{}
if h.NetIfFList[i].XML, err = iface.GetXMLDesc(0); err != nil { if err = h.NetIfFList[i].Unmarshal(rawxml); err != nil {
log.Println(err) log.Printf("error parsing interface XML: %s")
} return
}
iface.Free() }()
} }
} }
} }