예제 #1
0
func (c *VirConnection) IsAlive() (bool, error) {
	result := C.virConnectIsAlive(c.ptr)
	if result == -1 {
		return false, GetLastError()
	}
	if result == 1 {
		return true, nil
	}
	return false, nil
}
예제 #2
0
func (h *Hypervisor) IsConnectionAlive() (bool, error) {
	result := C.virConnectIsAlive(h.cptr)

	if result == -1 {
		return false, GetLastError()
	}

	if result == 1 {
		return true, nil
	}

	return false, nil
}
예제 #3
0
func (c *VirConnection) IsAlive() (bool, error) {
	switch result := int(C.virConnectIsAlive(c.ptr)); result {
	case -1:
		return false, errors.New(GetLastError())
	case 0:
		return false, nil
	case 1:
		return true, nil
	default:
		return false, nil
	}

}
예제 #4
0
// IsAlive determines if the connection to the hypervisor is still alive.
// If an error occurs, the function will also return "false" and the error
// message will be written to the log.
func (conn Connection) IsAlive() (bool, error) {
	conn.log.Println("checking whether connection is alive...")
	cRet := C.virConnectIsAlive(conn.virConnect)
	ret := int32(cRet)

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

	alive := (ret == 1)

	if alive {
		conn.log.Println("connection is alive")
	} else {
		conn.log.Println("connection is not alive")
	}

	return alive, nil
}