func (d *VirDomain) GetInfo() (VirDomainInfo, error) { di := VirDomainInfo{} var ptr C.virDomainInfo result := C.virDomainGetInfo(d.ptr, (*C.virDomainInfo)(unsafe.Pointer(&ptr))) if result == -1 { return di, errors.New(GetLastError()) } di.ptr = ptr return di, nil }
// InfoMemory extracts the memory in KBytes used by the domain. func (dom Domain) InfoMemory() (uint64, error) { var cInfo C.virDomainInfo cRet := C.virDomainGetInfo(dom.virDomain, &cInfo) ret := int32(cRet) if ret == -1 { return 0, LastError() } return uint64(cInfo.memory), nil }
// InfoVCPUs extracts the number of virtual CPUs for the domain. func (dom Domain) InfoVCPUs() (uint16, error) { var cInfo C.virDomainInfo cRet := C.virDomainGetInfo(dom.virDomain, &cInfo) ret := int32(cRet) if ret == -1 { return 0, LastError() } return uint16(cInfo.nrVirtCpu), nil }
// InfoState extracts the state of the domain. func (dom Domain) InfoState() (DomainState, error) { var cInfo C.virDomainInfo cRet := C.virDomainGetInfo(dom.virDomain, &cInfo) ret := int32(cRet) if ret == -1 { return 0, LastError() } return DomainState(cInfo.state), nil }
func (d *Domain) GetInfo() (DomainInfo, error) { var cDomainInfo C.virDomainInfo result := C.virDomainGetInfo(d.cptr, &cDomainInfo) if result == -1 { return DomainInfo{}, GetLastError() } return DomainInfo{ State: uint(cDomainInfo.state), MaxMemory: uint64(cDomainInfo.maxMem), Memory: uint64(cDomainInfo.memory), Vcpus: uint8(cDomainInfo.nrVirtCpu), CpuTime: uint64(cDomainInfo.cpuTime), }, nil }