コード例 #1
0
ファイル: domain.go プロジェクト: rgbkrk/libvirt-go
func (d *VirDomain) BlockStatsFlags(disk string, params *VirTypedParameters, nParams int, flags uint32) (int, error) {
	var cParams C.virTypedParameterPtr
	cDisk := C.CString(disk)
	defer C.free(unsafe.Pointer(cDisk))

	cParamsLen := C.int(nParams)

	if params != nil && nParams > 0 {
		cParams = (C.virTypedParameterPtr)(C.calloc(C.size_t(nParams), C.size_t(unsafe.Sizeof(C.struct__virTypedParameter{}))))
		defer C.virTypedParamsFree(cParams, cParamsLen)
	} else {
		cParams = nil
	}

	result := int(C.virDomainBlockStatsFlags(d.ptr, cDisk, (C.virTypedParameterPtr)(cParams), &cParamsLen, C.uint(flags)))
	if result == -1 {
		return result, GetLastError()
	}

	if cParamsLen > 0 && params != nil {
		params.loadFromCPtr(cParams, nParams)
	}

	return int(cParamsLen), nil
}
コード例 #2
0
ファイル: domain.go プロジェクト: rgbkrk/libvirt-go
func (d *VirDomain) GetCPUStats(params *VirTypedParameters, nParams int, startCpu int, nCpus uint32, flags uint32) (int, error) {
	var cParams C.virTypedParameterPtr
	var cParamsLen int

	cParamsLen = int(nCpus) * nParams

	if params != nil && cParamsLen > 0 {
		cParams = (C.virTypedParameterPtr)(C.calloc(C.size_t(cParamsLen), C.size_t(unsafe.Sizeof(C.struct__virTypedParameter{}))))
		defer C.virTypedParamsFree(cParams, C.int(cParamsLen))
	} else {
		cParamsLen = 0
		cParams = nil
	}

	result := int(C.virDomainGetCPUStats(d.ptr, (C.virTypedParameterPtr)(cParams), C.uint(nParams), C.int(startCpu), C.uint(nCpus), C.uint(flags)))
	if result == -1 {
		return result, GetLastError()
	}

	if cParamsLen > 0 {
		params.loadFromCPtr(cParams, cParamsLen)
	}

	return result, nil
}
コード例 #3
0
ファイル: domain_1.2.14.go プロジェクト: rgbkrk/libvirt-go
func (d *VirDomain) BlockCopy(disk string, destXML string, params VirTypedParameters, flags uint32) error {

	cDisk := C.CString(disk)
	defer C.free(unsafe.Pointer(cDisk))
	cDestXML := C.CString(destXML)
	defer C.free(unsafe.Pointer(cDestXML))
	if cParams, cnParams, err := params.loadToCPtr(); err != nil {
		C.virTypedParamsFree(cParams, cnParams)
		return err
	} else {
		defer C.virTypedParamsFree(cParams, cnParams)

		result := int(C.virDomainBlockCopy(d.ptr, cDisk, cDestXML, cParams, cnParams, C.uint(flags)))
		if result == -1 {
			return GetLastError()
		}
	}
	return nil
}
コード例 #4
0
ファイル: typed_parameter.go プロジェクト: hooklift/golibvirt
func NewTypedParameters(nparams int) *TypedParameters {
	t := new(TypedParameters)
	if nparams > 0 {
		t.cptr = C.virTypedParameterAllocate(C.int(nparams))
		t.capacity = C.int(nparams)
	}
	runtime.SetFinalizer(t, func(t *TypedParameters) {
		if t.cptr != nil {
			C.virTypedParamsFree(t.cptr, t.length)
		}
	})
	return t
}
コード例 #5
0
ファイル: domain.go プロジェクト: juito/hyper
// Warning: No test written for this function
func (d *VirDomain) GetInterfaceParameters(device string, params *VirTypedParameters, nParams *int, flags uint32) (int, error) {
	var cParams C.virTypedParameterPtr

	if params != nil && *nParams > 0 {
		cParams = (C.virTypedParameterPtr)(C.calloc(C.size_t(*nParams), C.size_t(unsafe.Sizeof(C.struct__virTypedParameter{}))))
		defer C.virTypedParamsFree(cParams, C.int(*nParams))
	} else {
		cParams = nil
	}

	result := int(C.virDomainGetInterfaceParameters(d.ptr, C.CString(device), (C.virTypedParameterPtr)(cParams), (*C.int)(unsafe.Pointer(nParams)), C.uint(flags)))
	if result == -1 {
		return result, GetLastError()
	}

	if params != nil && *nParams > 0 {
		params.loadFromCPtr(cParams, *nParams)
	}

	return result, nil
}