From 28aa9dd70103c03101d005467bc9070b8946fd80 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/domain.go b/domain.go index 24be4b1..45956f3 100644 --- a/domain.go +++ b/domain.go @@ -428,3 +428,30 @@ 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) // incompatible 0.9 + C.free(unsafe.Pointer(cParams)) + } 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 +}