func (c *VirConnection) GetSysinfo(flags uint) (string, error) { cStr := C.virConnectGetSysinfo(c.ptr, C.uint(flags)) if cStr == nil { return "", GetLastError() } info := C.GoString(cStr) C.free(unsafe.Pointer(cStr)) return info, nil }
func (h *Hypervisor) GetSysInfo(flags uint8) (string, error) { result := C.virConnectGetSysinfo(h.cptr, C.uint(flags)) if result == nil { return "", GetLastError() } sysinfo := C.GoString(result) defer C.free(unsafe.Pointer(result)) return sysinfo, nil }
// Sysinfo returns the XML description of the sysinfo details for the host on // which the hypervisor is running, in the same format as the <sysinfo> element // of a domain XML. This information is generally available only for // hypervisors running with root privileges. func (conn Connection) Sysinfo() (string, error) { conn.log.Println("reading system info...") cSysinfo := C.virConnectGetSysinfo(conn.virConnect, 0) if cSysinfo == nil { err := LastError() conn.log.Printf("an error occurred: %v\n", err) return "", err } defer C.free(unsafe.Pointer(cSysinfo)) sysinfo := C.GoString(cSysinfo) conn.log.Printf("system info XML length: %v runes\n", utf8.RuneCountInString(sysinfo)) return sysinfo, nil }