mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 06:47:45 +00:00
util: Introduce virResctrlAllocForeachMemory
Introduce an API that will traverse the memory bandwidth data calling a callback function for each defined bandwidth entry. Signed-off-by: Bing Niu <bing.niu@intel.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
f977ad89e0
commit
10e699dac9
@ -2648,6 +2648,7 @@ virResctrlAllocAddPID;
|
|||||||
virResctrlAllocCreate;
|
virResctrlAllocCreate;
|
||||||
virResctrlAllocDeterminePath;
|
virResctrlAllocDeterminePath;
|
||||||
virResctrlAllocForeachCache;
|
virResctrlAllocForeachCache;
|
||||||
|
virResctrlAllocForeachMemory;
|
||||||
virResctrlAllocFormat;
|
virResctrlAllocFormat;
|
||||||
virResctrlAllocGetID;
|
virResctrlAllocGetID;
|
||||||
virResctrlAllocGetUnused;
|
virResctrlAllocGetUnused;
|
||||||
|
@ -965,6 +965,39 @@ virResctrlAllocForeachCache(virResctrlAllocPtr alloc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* virResctrlAllocForeachMemory
|
||||||
|
* @alloc: Pointer to an active allocation
|
||||||
|
* @cb: Callback function
|
||||||
|
* @opaque: Opaque data to be passed to @cb
|
||||||
|
*
|
||||||
|
* If available, traverse the defined memory bandwidth allocations and
|
||||||
|
* call the @cb function.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, -1 and immediate failure if the @cb has any failure.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virResctrlAllocForeachMemory(virResctrlAllocPtr alloc,
|
||||||
|
virResctrlAllocForeachMemoryCallback cb,
|
||||||
|
void *opaque)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
virResctrlAllocMemBWPtr mem_bw;
|
||||||
|
|
||||||
|
if (!alloc || !alloc->mem_bw)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
mem_bw = alloc->mem_bw;
|
||||||
|
for (i = 0; i < mem_bw->nbandwidths; i++) {
|
||||||
|
if (mem_bw->bandwidths[i]) {
|
||||||
|
if (cb(i, *mem_bw->bandwidths[i], opaque) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virResctrlAllocSetID(virResctrlAllocPtr alloc,
|
virResctrlAllocSetID(virResctrlAllocPtr alloc,
|
||||||
const char *id)
|
const char *id)
|
||||||
|
@ -73,6 +73,10 @@ typedef int virResctrlAllocForeachCacheCallback(unsigned int level,
|
|||||||
unsigned long long size,
|
unsigned long long size,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
|
typedef int virResctrlAllocForeachMemoryCallback(unsigned int id,
|
||||||
|
unsigned int size,
|
||||||
|
void *opaque);
|
||||||
|
|
||||||
virResctrlAllocPtr
|
virResctrlAllocPtr
|
||||||
virResctrlAllocNew(void);
|
virResctrlAllocNew(void);
|
||||||
|
|
||||||
@ -91,6 +95,11 @@ virResctrlAllocForeachCache(virResctrlAllocPtr alloc,
|
|||||||
virResctrlAllocForeachCacheCallback cb,
|
virResctrlAllocForeachCacheCallback cb,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
|
int
|
||||||
|
virResctrlAllocForeachMemory(virResctrlAllocPtr resctrl,
|
||||||
|
virResctrlAllocForeachMemoryCallback cb,
|
||||||
|
void *opaque);
|
||||||
|
|
||||||
int
|
int
|
||||||
virResctrlAllocSetID(virResctrlAllocPtr alloc,
|
virResctrlAllocSetID(virResctrlAllocPtr alloc,
|
||||||
const char *id);
|
const char *id);
|
||||||
|
Loading…
Reference in New Issue
Block a user