Skip to content

Commit

Permalink
Add BlockStatsFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Akins authored and Alex Zorin committed Aug 2, 2014
1 parent f05ab1d commit 28aa9dd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 28aa9dd

Please sign in to comment.