Esempio n. 1
0
func (c *VirConnection) GetNodeInfo() (VirNodeInfo, error) {
	ni := VirNodeInfo{}
	var ptr C.virNodeInfo
	result := C.virNodeGetInfo(c.ptr, (*C.virNodeInfo)(unsafe.Pointer(&ptr)))
	if result == -1 {
		return ni, GetLastError()
	}
	ni.ptr = ptr
	return ni, nil
}
Esempio n. 2
0
func (h *Hypervisor) GetNodeInfo() (NodeInfo, error) {
	var cNodeInfo C.virNodeInfo
	result := C.virNodeGetInfo(h.cptr, &cNodeInfo)
	if result == -1 {
		return NodeInfo{}, GetLastError()
	}

	return NodeInfo{
		Model:   C.GoString(&cNodeInfo.model[0]),
		Memory:  uint64(cNodeInfo.memory),
		Cpus:    uint(cNodeInfo.cpus),
		Mhz:     uint(cNodeInfo.mhz),
		Nodes:   uint(cNodeInfo.nodes),
		Sockets: uint(cNodeInfo.sockets),
		Cores:   uint(cNodeInfo.cores),
		Threads: uint(cNodeInfo.threads),
	}, nil
}