예제 #1
0
func (d *VirDomain) IsActive() bool {
	result := C.virDomainIsActive(d.ptr)
	if result == -1 {
		return false
	}
	if result == 1 {
		return true
	}
	return false
}
예제 #2
0
파일: domain.go 프로젝트: rgbkrk/libvirt-go
func (d *VirDomain) IsActive() (bool, error) {
	result := C.virDomainIsActive(d.ptr)
	if result == -1 {
		return false, GetLastError()
	}
	if result == 1 {
		return true, nil
	}
	return false, nil
}
예제 #3
0
// IsActive determines if the domain is currently running.
func (dom Domain) IsActive() (bool, error) {
	dom.log.Println("checking whether domain is active...")
	cRet := C.virDomainIsActive(dom.virDomain)
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		dom.log.Printf("an error occurred: %v\n", err)
		return false, err
	}

	active := (ret == 1)

	if active {
		dom.log.Println("domain is active")
	} else {
		dom.log.Println("domain is not active")
	}

	return active, nil
}