From 30c04daaa6f5ce8908b77251946500953a40faa9 Mon Sep 17 00:00:00 2001 From: Brian Akins Date: Thu, 31 Jul 2014 12:09:58 -0400 Subject: [PATCH] Add BlockStatsFlags --- domain.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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