mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-06 01:57:31 +03:00
util: Introduce virResctrlAllocSetMemoryBandwidth
Introduce an API to allow setting of the MBA from domain XML. Signed-off-by: Bing Niu <bing.niu@intel.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
10e699dac9
commit
5b66c6cc85
@ -2656,6 +2656,7 @@ virResctrlAllocNew;
|
|||||||
virResctrlAllocRemove;
|
virResctrlAllocRemove;
|
||||||
virResctrlAllocSetCacheSize;
|
virResctrlAllocSetCacheSize;
|
||||||
virResctrlAllocSetID;
|
virResctrlAllocSetID;
|
||||||
|
virResctrlAllocSetMemoryBandwidth;
|
||||||
virResctrlInfoGetCache;
|
virResctrlInfoGetCache;
|
||||||
virResctrlInfoNew;
|
virResctrlInfoNew;
|
||||||
|
|
||||||
|
@ -965,6 +965,54 @@ virResctrlAllocForeachCache(virResctrlAllocPtr alloc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* virResctrlAllocSetMemoryBandwidth
|
||||||
|
* @alloc: Pointer to an active allocation
|
||||||
|
* @id: node id of MBA to be set
|
||||||
|
* @memory_bandwidth: new memory bandwidth value
|
||||||
|
*
|
||||||
|
* Set the @memory_bandwidth for the node @id entry in the @alloc.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, -1 on failure with error message set.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr alloc,
|
||||||
|
unsigned int id,
|
||||||
|
unsigned int memory_bandwidth)
|
||||||
|
{
|
||||||
|
virResctrlAllocMemBWPtr mem_bw = alloc->mem_bw;
|
||||||
|
|
||||||
|
if (memory_bandwidth > 100) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("Memory Bandwidth value exceeding 100 is invalid."));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mem_bw) {
|
||||||
|
if (VIR_ALLOC(mem_bw) < 0)
|
||||||
|
return -1;
|
||||||
|
alloc->mem_bw = mem_bw;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mem_bw->nbandwidths <= id &&
|
||||||
|
VIR_EXPAND_N(mem_bw->bandwidths, mem_bw->nbandwidths,
|
||||||
|
id - mem_bw->nbandwidths + 1) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (mem_bw->bandwidths[id]) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Memory Bandwidth already defined for node %u"),
|
||||||
|
id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VIR_ALLOC(mem_bw->bandwidths[id]) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*(mem_bw->bandwidths[id]) = memory_bandwidth;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virResctrlAllocForeachMemory
|
/* virResctrlAllocForeachMemory
|
||||||
* @alloc: Pointer to an active allocation
|
* @alloc: Pointer to an active allocation
|
||||||
* @cb: Callback function
|
* @cb: Callback function
|
||||||
|
@ -95,6 +95,11 @@ virResctrlAllocForeachCache(virResctrlAllocPtr alloc,
|
|||||||
virResctrlAllocForeachCacheCallback cb,
|
virResctrlAllocForeachCacheCallback cb,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
|
int
|
||||||
|
virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr alloc,
|
||||||
|
unsigned int id,
|
||||||
|
unsigned int memory_bandwidth);
|
||||||
|
|
||||||
int
|
int
|
||||||
virResctrlAllocForeachMemory(virResctrlAllocPtr resctrl,
|
virResctrlAllocForeachMemory(virResctrlAllocPtr resctrl,
|
||||||
virResctrlAllocForeachMemoryCallback cb,
|
virResctrlAllocForeachMemoryCallback cb,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user