[PATCH 2/2] resctrl: Set MBA defaults properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Similarly to CAT, when you set some values in an group, remove the group and
recreate it, the previous values will be kept there.  In order to not get values
from a previous setting (a previous VM, for example), we need to set them to
sensible defaults.  The same way we do that for CAT, just set the same values as
the default group has.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/util/virresctrl.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 4a812d7a8be8..ab977b995c4d 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -2143,6 +2143,42 @@ virResctrlAllocMemoryBandwidth(virResctrlInfoPtr resctrl,
 }
 
 
+static int
+virResctrlAllocCopyMemBW(virResctrlAllocPtr dst,
+                         virResctrlAllocPtr src)
+{
+    size_t i = 0;
+    virResctrlAllocMemBWPtr dst_bw = NULL;
+    virResctrlAllocMemBWPtr src_bw = src->mem_bw;
+
+    if (!src->mem_bw)
+        return 0;
+
+    if (!dst->mem_bw &&
+        VIR_ALLOC(dst->mem_bw) < 0)
+        return -1;
+
+    dst_bw = dst->mem_bw;
+
+    if (src_bw->nbandwidths > dst_bw->nbandwidths &&
+        VIR_EXPAND_N(dst_bw->bandwidths, dst_bw->nbandwidths,
+                     src_bw->nbandwidths - dst_bw->nbandwidths) < 0)
+        return -1;
+
+    for (i = 0; i < src_bw->nbandwidths; i++) {
+        if (dst_bw->bandwidths[i]) {
+            *dst_bw->bandwidths[i] = 123;
+            continue;
+        }
+        if (VIR_ALLOC(dst_bw->bandwidths[i]) < 0)
+            return -1;
+        *dst_bw->bandwidths[i] = *src_bw->bandwidths[i];
+    }
+
+    return 0;
+}
+
+
 static int
 virResctrlAllocCopyMasks(virResctrlAllocPtr dst,
                          virResctrlAllocPtr src)
@@ -2210,6 +2246,9 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl,
     if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0)
         goto cleanup;
 
+    if (virResctrlAllocCopyMemBW(alloc, alloc_default) < 0)
+        goto cleanup;
+
     for (level = 0; level < alloc->nlevels; level++) {
         virResctrlAllocPerLevelPtr a_level = alloc->levels[level];
         virResctrlAllocPerLevelPtr f_level = NULL;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux