// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetState
199350
func (d *Domain) GetState() (DomainState, int, error) {
	var cState C.int
	var cReason C.int
	var err C.virError
	result := C.virDomainGetStateWrapper(d.ptr,
		(*C.int)(unsafe.Pointer(&cState)),
		(*C.int)(unsafe.Pointer(&cReason)),
		0, &err)
	if int(result) == -1 {
		return 0, 0, makeError(&err)
	}
	return DomainState(cState), int(cReason), nil
}
74797
func genState() uint64 {
	prime, err := rand.Prime(rand.Reader, 64)
	if err != nil {
		panic(err)
	}
	return prime.Uint64()
}
775386
func (vm *VM) GetState() (string, error) {
	server, err := getServer(vm)
	if err != nil {
		return "", err
	}

	if server == nil {
		// VM state "unknown"
		return "", lvm.ErrVMInfoFailed
	}

	if server.Status == StateActive {
		return lvm.VMRunning, nil
	} else if server.Status == StateShutOff {
		return lvm.VMHalted, nil
	} else if server.Status == StateError {
		return lvm.VMError, nil
	}
	return lvm.VMUnknown, nil
}
1246887
func (u *UserMigration) GetState() string {
	if u == nil || u.State == nil {
		return ""
	}
	return *u.State
}
961108
func (vm *VM) GetState() (string, error) {

	if vm.ID == "" {
		return "", fmt.Errorf("Need an ID to get virtual machine state")
	}

	if err := vm.updateInfo(); err != nil {
		return "", err
	}

	return vm.state, nil
}
948643
func (c Client) GetDatasetState(datasetID string) (*DatasetState, error) {
	resp, err := c.get(c.getURL("state/datasets"))
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	var states []datasetStatePayload
	if err = json.NewDecoder(resp.Body).Decode(&states); err == nil {
		for _, s := range states {
			if s.DatasetID == datasetID {
				return s.DatasetState, nil
			}
		}
		return nil, errStateNotFound
	}

	return nil, err
}
586541
func (d dynamicSystemView) ReplicationState() consts.ReplicationState {
	state := d.core.ReplicationState()
	if d.core.perfStandby {
		state |= consts.ReplicationPerformanceStandby
	}
	return state
}
1135176
func (vm *VM) GetState() (string, error) {
	id := fmt.Sprintf("%v", vm.Droplet.ID)
	if id == "" {
		return "", ErrNoInstanceID
	}

	client := &http.Client{}
	req, err := BuildRequest(vm.APIToken, "GET", apiBaseURL+apiDropletURL+"/"+id, nil)
	if err != nil {
		return "", err
	}
	rsp, err := client.Do(req)
	if err != nil {
		return "", err
	}
	defer rsp.Body.Close()
	b, err := ioutil.ReadAll(rsp.Body)
	if err != nil {
		return "", err
	}
	if rsp.StatusCode == StatusNotFound {
		return "not_found", nil
	}
	if rsp.Status[0] != StatusOk {
		return "", fmt.Errorf("Error: %s: %s", rsp.Status, string(b))
	}

	// Fill out vm.Droplet with data on droplet
	r := &DropletResponse{}
	err = json.Unmarshal(b, r)
	if err != nil {
		return "", err
	}
	vm.Droplet = r.Droplet
	return vm.Droplet.Status, nil
}
926574
func (d *Driver) GetState() (state.State, error) {
	if err := d.verifyRootPermissions(); err != nil {
		return state.Error, err
	}

	pid := d.getPid()
	log.Debugf("hyperkit pid from json: %d", pid)
	return pidState(pid)
}
604697
func (client *Client) ResetState() error {
	resp, err := http.Post(client.endpoint+"/reset", "text/plain", bytes.NewReader([]byte{}))
	if err != nil {
		return err
	}

	return checkError(resp, http.StatusNoContent, "ResetState")
}
656626
func (c *Client) GetAllocState(allocID string) (*arstate.State, error) {
	ar, err := c.getAllocRunner(allocID)
	if err != nil {
		return nil, err
	}

	return ar.AllocState(), nil
}
1356056
func GetStateSchema() string {
	return fmt.Sprintf(services.V2SchemaTemplate, services.MetadataSchema, fmt.Sprintf(StateSpecV2Schema, services.RotationSchema), services.DefaultDefinitions)
}
491434
func (cs *ChannelState) FetchState() (endorsement.State, error) {
	qe, err := cs.NewQueryExecutor()
	if err != nil {
		return nil, err
	}

	return &StateContext{
		QueryExecutor: qe,
		Store:         cs.Store,
	}, nil
}
1009787
func GetState(conn client.Connection, req StateRequest) (*State, error) {
	logger := plog.WithFields(log.Fields{
		"hostid":     req.HostID,
		"serviceid":  req.ServiceID,
		"instanceid": req.InstanceID,
	})

	basepth := "/"
	if req.PoolID != "" {
		basepth = path.Join("/pools", req.PoolID)
	}

	// Get the current host state
	hspth := path.Join(basepth, "/hosts", req.HostID, "instances", req.StateID())
	hsdat := &HostState{}
	if err := conn.Get(hspth, hsdat); err != nil {

		logger.WithError(err).Debug("Could not look up host state")
		return nil, &StateError{
			Request:   req,
			Operation: "get",
			Message:   "could not look up host state",
		}
	}

	logger.Debug("Found the host state")

	// Get the current service state
	sspth := path.Join(basepth, "/services", req.ServiceID, req.StateID())
	ssdat := &ServiceState{}
	if err := conn.Get(sspth, ssdat); err != nil {

		logger.WithError(err).Debug("Could not look up service state")
		return nil, &StateError{
			Request:   req,
			Operation: "get",
			Message:   "could not look up service state",
		}
	}

	logger.Debug("Found the service state")

	// Get the current state (status)
	cspth := path.Join(sspth, "current")
	cstate := &CurrentStateContainer{}
	if err := conn.Get(cspth, cstate); err != nil {
		logger.WithError(err).Debug("Could not look up current state (status)")
		return nil, &StateError{
			Request:   req,
			Operation: "get",
			Message:   "could not look up current state (status)",
		}
	}

	return &State{
		HostState:             *hsdat,
		ServiceState:          *ssdat,
		CurrentStateContainer: *cstate,
		HostID:                req.HostID,
		ServiceID:             req.ServiceID,
		InstanceID:            req.InstanceID,
	}, nil
}
971584
func (d *DismissedReview) GetState() string {
	if d == nil || d.State == nil {
		return ""
	}
	return *d.State
}
471752
func (rcvr *Receiver) FetchInitialState(stateUrl string) error {
	rcvr.StateLock.Lock()
	defer rcvr.StateLock.Unlock()

	log.Info("Fetching initial state on startup...")
	state, err := FetchState(stateUrl)
	if err != nil {
		return err
	} else {
		log.Info("Successfully retrieved state")
		rcvr.CurrentState = state
		if rcvr.OnUpdate == nil {
			log.Error("OnUpdate() callback not defined!")
		} else {
			rcvr.OnUpdate(state)
		}
	}

	return nil
}
685283
func (fbo *folderBlockOps) GetState(
	lState *kbfssync.LockState) overallBlockState {
	fbo.blockLock.RLock(lState)
	defer fbo.blockLock.RUnlock(lState)
	if len(fbo.dirtyFiles) == 0 && len(fbo.dirtyDirs) == 0 &&
		fbo.dirtyRootDirEntry == nil {
		return cleanState
	}
	return dirtyState
}