Ejemplo n.º 1
0
func (d *VirDomain) GetAutostart() (bool, error) {
	var out C.int
	result := C.virDomainGetAutostart(d.ptr, (*C.int)(unsafe.Pointer(&out)))
	if result == -1 {
		return false, GetLastError()
	}
	switch out {
	case 1:
		return true, nil
	default:
		return false, nil
	}
}
Ejemplo n.º 2
0
func (d *Domain) GetAutostart() (bool, error) {
	var autostart C.int
	result := C.virDomainGetAutostart(d.cptr, &autostart)
	if result == -1 {
		return false, GetLastError()
	}

	if autostart == 0 {
		return true, nil
	}

	return false, nil
}
Ejemplo n.º 3
0
// Autostart provides a boolean value indicating whether the domain configured
// to be automatically started when the host machine boots.
func (dom Domain) Autostart() (bool, error) {
	var cAutostart C.int
	dom.log.Println("checking whether domain autostarts...")
	cRet := C.virDomainGetAutostart(dom.virDomain, &cAutostart)
	ret := int32(cRet)

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

	autostart := (int32(cAutostart) == 1)

	if autostart {
		dom.log.Println("domain autostarts")
	} else {
		dom.log.Println("domain does not autostart")
	}

	return autostart, nil
}