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