|
|
0a7476 |
From 32abc89753dc271ae469609af416fb8cd0e4e875 Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <32abc89753dc271ae469609af416fb8cd0e4e875@dist-git>
|
|
|
0a7476 |
From: Bing Niu <bing.niu@intel.com>
|
|
|
0a7476 |
Date: Mon, 15 Apr 2019 17:32:53 +0200
|
|
|
0a7476 |
Subject: [PATCH] util: Introduce virResctrlAllocSetMemoryBandwidth
|
|
|
0a7476 |
MIME-Version: 1.0
|
|
|
0a7476 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0a7476 |
Content-Transfer-Encoding: 8bit
|
|
|
0a7476 |
|
|
|
0a7476 |
Introduce an API to allow setting of the MBA from domain XML.
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Bing Niu <bing.niu@intel.com>
|
|
|
0a7476 |
Reviewed-by: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit 5b66c6cc85d30c85606088d458fbff6ef064dd3a)
|
|
|
0a7476 |
|
|
|
0a7476 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1468650
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
0a7476 |
Message-Id: <2d676721246084d1050b5cfad665637645bf9689.1555342313.git.phrdina@redhat.com>
|
|
|
0a7476 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/libvirt_private.syms | 1 +
|
|
|
0a7476 |
src/util/virresctrl.c | 48 ++++++++++++++++++++++++++++++++++++++++
|
|
|
0a7476 |
src/util/virresctrl.h | 5 +++++
|
|
|
0a7476 |
3 files changed, 54 insertions(+)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
0a7476 |
index de328d7d22..af9b61fbdc 100644
|
|
|
0a7476 |
--- a/src/libvirt_private.syms
|
|
|
0a7476 |
+++ b/src/libvirt_private.syms
|
|
|
0a7476 |
@@ -2666,6 +2666,7 @@ virResctrlAllocNew;
|
|
|
0a7476 |
virResctrlAllocRemove;
|
|
|
0a7476 |
virResctrlAllocSetCacheSize;
|
|
|
0a7476 |
virResctrlAllocSetID;
|
|
|
0a7476 |
+virResctrlAllocSetMemoryBandwidth;
|
|
|
0a7476 |
virResctrlInfoGetCache;
|
|
|
0a7476 |
virResctrlInfoNew;
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
|
|
|
0a7476 |
index 45fc6fc847..adf36a7c0a 100644
|
|
|
0a7476 |
--- a/src/util/virresctrl.c
|
|
|
0a7476 |
+++ b/src/util/virresctrl.c
|
|
|
0a7476 |
@@ -965,6 +965,54 @@ virResctrlAllocForeachCache(virResctrlAllocPtr alloc,
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
|
|
|
0a7476 |
+/* virResctrlAllocSetMemoryBandwidth
|
|
|
0a7476 |
+ * @alloc: Pointer to an active allocation
|
|
|
0a7476 |
+ * @id: node id of MBA to be set
|
|
|
0a7476 |
+ * @memory_bandwidth: new memory bandwidth value
|
|
|
0a7476 |
+ *
|
|
|
0a7476 |
+ * Set the @memory_bandwidth for the node @id entry in the @alloc.
|
|
|
0a7476 |
+ *
|
|
|
0a7476 |
+ * Returns 0 on success, -1 on failure with error message set.
|
|
|
0a7476 |
+ */
|
|
|
0a7476 |
+int
|
|
|
0a7476 |
+virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr alloc,
|
|
|
0a7476 |
+ unsigned int id,
|
|
|
0a7476 |
+ unsigned int memory_bandwidth)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ virResctrlAllocMemBWPtr mem_bw = alloc->mem_bw;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (memory_bandwidth > 100) {
|
|
|
0a7476 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
0a7476 |
+ _("Memory Bandwidth value exceeding 100 is invalid."));
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (!mem_bw) {
|
|
|
0a7476 |
+ if (VIR_ALLOC(mem_bw) < 0)
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+ alloc->mem_bw = mem_bw;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (mem_bw->nbandwidths <= id &&
|
|
|
0a7476 |
+ VIR_EXPAND_N(mem_bw->bandwidths, mem_bw->nbandwidths,
|
|
|
0a7476 |
+ id - mem_bw->nbandwidths + 1) < 0)
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (mem_bw->bandwidths[id]) {
|
|
|
0a7476 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
0a7476 |
+ _("Memory Bandwidth already defined for node %u"),
|
|
|
0a7476 |
+ id);
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (VIR_ALLOC(mem_bw->bandwidths[id]) < 0)
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ *(mem_bw->bandwidths[id]) = memory_bandwidth;
|
|
|
0a7476 |
+ return 0;
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
/* virResctrlAllocForeachMemory
|
|
|
0a7476 |
* @alloc: Pointer to an active allocation
|
|
|
0a7476 |
* @cb: Callback function
|
|
|
0a7476 |
diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
|
|
|
0a7476 |
index 5ea5b27d3b..8d62517aa1 100644
|
|
|
0a7476 |
--- a/src/util/virresctrl.h
|
|
|
0a7476 |
+++ b/src/util/virresctrl.h
|
|
|
0a7476 |
@@ -95,6 +95,11 @@ virResctrlAllocForeachCache(virResctrlAllocPtr alloc,
|
|
|
0a7476 |
virResctrlAllocForeachCacheCallback cb,
|
|
|
0a7476 |
void *opaque);
|
|
|
0a7476 |
|
|
|
0a7476 |
+int
|
|
|
0a7476 |
+virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr alloc,
|
|
|
0a7476 |
+ unsigned int id,
|
|
|
0a7476 |
+ unsigned int memory_bandwidth);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
int
|
|
|
0a7476 |
virResctrlAllocForeachMemory(virResctrlAllocPtr resctrl,
|
|
|
0a7476 |
virResctrlAllocForeachMemoryCallback cb,
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|