diff --git a/domain.go b/domain.go index e2515c0..dee4a7e 100644 --- a/domain.go +++ b/domain.go @@ -473,3 +473,29 @@ func (d *VirDomain) SendKey(codeset, holdtime uint, keycodes []uint, flags uint) return nil } + +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, errors.New(GetLastError()) + } + + if cParamsLen > 0 && params != nil { + params.loadFromCPtr(cParams, nParams) + } + + return int(cParamsLen), nil +} \ No newline at end of file