// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSave
198052
func (d *Domain) Save(destFile string) error {
	cPath := C.CString(destFile)
	defer C.free(unsafe.Pointer(cPath))
	var err C.virError
	result := C.virDomainSaveWrapper(d.ptr, cPath, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
796477
func (d *Domain) GetIOThreadInfo(flags DomainModificationImpact) ([]DomainIOThreadInfo, error) {
	if C.LIBVIR_VERSION_NUMBER < 1002014 {
		return []DomainIOThreadInfo{}, makeNotImplementedError("virDomaingetIOThreadInfo")
	}
	var cinfolist **C.virDomainIOThreadInfo

	var err C.virError
	ret := C.virDomainGetIOThreadInfoWrapper(d.ptr, (**C.virDomainIOThreadInfoPtr)(unsafe.Pointer(&cinfolist)), C.uint(flags), &err)
	if ret == -1 {
		return []DomainIOThreadInfo{}, makeError(&err)
	}

	info := make([]DomainIOThreadInfo, int(ret))

	for i := 0; i < int(ret); i++ {
		cinfo := (*(**C.virDomainIOThreadInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(cinfolist)) + (unsafe.Sizeof(*cinfolist) * uintptr(i)))))

		ncpus := int(cinfo.cpumaplen * 8)
		cpumap := make([]bool, ncpus)
		for j := 0; j < ncpus; j++ {
			byte := j / 8
			bit := j % 8

			cpumapbyte := *(*C.uchar)(unsafe.Pointer(uintptr(unsafe.Pointer(cinfo.cpumap)) + (unsafe.Sizeof(*cinfo.cpumap) * uintptr(byte))))
			cpumap[j] = (cpumapbyte & (1 << uint(bit))) != 0
		}

		info[i] = DomainIOThreadInfo{
			IOThreadID: uint(cinfo.iothread_id),
			CpuMap:     cpumap,
		}

		C.virDomainIOThreadInfoFreeWrapper(cinfo)
	}
	C.free(unsafe.Pointer(cinfolist))

	return info, nil
}
517592
func (d *Domain) IsActive() (bool, error) {
	var err C.virError
	result := C.virDomainIsActiveWrapper(d.ptr, &err)
	if result == -1 {
		return false, makeError(&err)
	}
	if result == 1 {
		return true, nil
	}
	return false, nil
}
1145705
func (dct *DjangoContentType) Save(db XODB) error {
	if dct.Exists() {
		return dct.Update(db)
	}

	return dct.Insert(db)
}
1364508
func (d *Domain) Reset(flags uint32) error {
	var err C.virError
	ret := C.virDomainResetWrapper(d.ptr, C.uint(flags), &err)
	if ret == -1 {
		return makeError(&err)
	}

	return nil
}
1367036
func (c *Connect) DomainSaveImageGetXMLDesc(file string, flags DomainSaveImageXMLFlags) (string, error) {
	cfile := C.CString(file)
	defer C.free(unsafe.Pointer(cfile))

	var err C.virError
	ret := C.virDomainSaveImageGetXMLDescWrapper(c.ptr, cfile, C.uint(flags), &err)

	if ret == nil {
		return "", makeError(&err)
	}

	defer C.free(unsafe.Pointer(ret))

	return C.GoString(ret), nil
}
856535
func (d *Domain) SnapshotCurrent(flags uint32) (*DomainSnapshot, error) {
	var err C.virError
	result := C.virDomainSnapshotCurrentWrapper(d.ptr, C.uint(flags), &err)
	if result == nil {
		return nil, makeError(&err)
	}
	return &DomainSnapshot{ptr: result}, nil

}
22806
func domainEventBalloonChangeCallback(c C.virConnectPtr, d C.virDomainPtr,
	actual uint64, opaque int) {

	domain := VirDomain{ptr: d}
	connection := VirConnection{ptr: c}

	eventDetails := DomainBalloonChangeEvent{
		Actual: actual,
	}

	callDomainCallbackId(opaque, &connection, &domain, eventDetails)
}
1235332
func (c *Client) RecoverVirtualMachine(p *RecoverVirtualMachineParameter) (*VirtualMachine, error) {
	obj, err := c.Request("recoverVirtualMachine", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*VirtualMachine), err
}
712895
func domainEventReasonCallback(c C.virConnectPtr, d C.virDomainPtr,
	reason int, opaque int) {

	domain := VirDomain{ptr: d}
	connection := VirConnection{ptr: c}

	eventDetails := DomainReasonEvent{
		Reason: reason,
	}

	callDomainCallbackId(opaque, &connection, &domain, eventDetails)
}
1122808
func domainEventMetadataChangeCallback(c C.virConnectPtr, d C.virDomainPtr,
	mtype int, nsuri *C.char, goCallbackId int) {

	domain := &Domain{ptr: d}
	connection := &Connect{ptr: c}

	eventDetails := &DomainEventMetadataChange{
		Type:  (int)(mtype),
		NSURI: C.GoString(nsuri),
	}
	callbackFunc := getCallbackId(goCallbackId)
	callback, ok := callbackFunc.(DomainEventMetadataChangeCallback)
	if !ok {
		panic("Inappropriate callback type called")
	}
	callback(connection, domain, eventDetails)

}
225076
func (d *Domain) Destroy() error {
	var err C.virError
	result := C.virDomainDestroyWrapper(d.ptr, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
932628
func (_class VIFClass) GetVM(sessionID SessionRef, self VIFRef) (_retval VMRef, _err error) {
	_method := "VIF.get_VM"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVIFRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertVMRefToGo(_method + " -> ", _result.Value)
	return
}
515282
func (pvKey FilePVKey) Save() {
	outFile := pvKey.filePath
	if outFile == "" {
		panic("cannot save PrivValidator key: filePath not set")
	}

	jsonBytes, err := cdc.MarshalJSONIndent(pvKey, "", "  ")
	if err != nil {
		panic(err)
	}
	err = cmn.WriteFileAtomic(outFile, jsonBytes, 0600)
	if err != nil {
		panic(err)
	}

}
1193103
func (s *sessionV8) Save() *probe.Error {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	if s.DataFP.dirty {
		if err := s.DataFP.Sync(); err != nil {
			return probe.NewError(err)
		}
		s.DataFP.dirty = false
	}

	qs, e := quick.NewConfig(s.Header, nil)
	if e != nil {
		return probe.NewError(e).Trace(s.SessionID)
	}

	sessionFile, err := getSessionFile(s.SessionID)
	if err != nil {
		return err.Trace(s.SessionID)
	}
	e = qs.Save(sessionFile)
	if e != nil {
		return probe.NewError(e).Trace(sessionFile)
	}
	return nil
}
674638
func (c *Connect) IsAlive() (bool, error) {
	var err C.virError
	result := C.virConnectIsAliveWrapper(c.ptr, &err)
	if result == -1 {
		return false, makeError(&err)
	}
	if result == 1 {
		return true, nil
	}
	return false, nil
}
484868
func (d *Domain) Create() error {
	var err C.virError
	result := C.virDomainCreateWrapper(d.ptr, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}