Example #1
0
// SetAutostart configures the domain to be automatically started when the host
// machine boots.
func (dom Domain) SetAutostart(autostart bool) error {
	var cAutostart C.int
	if autostart {
		dom.log.Println("enabling domain autostart...")
		cAutostart = 1
	} else {
		dom.log.Println("disabling domain autostart...")
		cAutostart = 0
	}

	cRet := C.virDomainSetAutostart(dom.virDomain, cAutostart)
	ret := int32(cRet)

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

	if autostart {
		dom.log.Println("autostart enabled")
	} else {
		dom.log.Println("autostart disabled")
	}

	return nil
}
Example #2
0
func (d *VirDomain) SetAutostart(autostart bool) error {
	var cAutostart C.int
	switch autostart {
	case true:
		cAutostart = 1
	default:
		cAutostart = 0
	}
	result := C.virDomainSetAutostart(d.ptr, cAutostart)
	if result == -1 {
		return GetLastError()
	}
	return nil
}
Example #3
0
func (d *Domain) SetAutostart(autostart bool) error {
	var cautostart int
	if autostart {
		cautostart = 0
	} else {
		cautostart = 1
	}

	result := C.virDomainSetAutostart(d.cptr, C.int(cautostart))
	if result == -1 {
		return GetLastError()
	}

	return nil
}