Beispiel #1
0
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
}
Beispiel #2
0
// 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
}
Beispiel #3
0
// 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
}
Beispiel #4
0
// 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
}
Beispiel #5
0
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
}