func (d *Domain) GetState(flags uint16) (int, int, error) { var cstate, creason C.int result := C.virDomainGetState(d.cptr, &cstate, &creason, C.uint(flags)) if result == -1 { return 0, 0, GetLastError() } return int(cstate), int(creason), nil }
func (d *VirDomain) GetState() ([]int, error) { var cState C.int var cReason C.int result := C.virDomainGetState(d.ptr, (*C.int)(unsafe.Pointer(&cState)), (*C.int)(unsafe.Pointer(&cReason)), 0) if int(result) == -1 { return []int{}, errors.New(GetLastError()) } return []int{int(cState), int(cReason)}, nil }
// State extracts domain state. Each state can be accompanied with a reason // (if known) which led to the state. func (dom Domain) State() (DomainState, int32, error) { var cState, cReason C.int dom.log.Println("reading domain state...") cRet := C.virDomainGetState(dom.virDomain, &cState, &cReason, 0) ret := int32(cRet) if ret == -1 { err := LastError() dom.log.Printf("an error occurred: %v\n", err) return 0, 0, err } state := DomainState(cState) reason := int32(cReason) dom.log.Printf("state: %v (reason = %v)\n", state, reason) return state, reason, nil }