]> xenbits.xensource.com Git - libvirt.git/commitdiff
resctrl: Move virResctrlAllocCopyMemBW up in the file
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 11 Sep 2024 13:08:28 +0000 (15:08 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 13 Sep 2024 10:55:39 +0000 (12:55 +0200)
This way it can be used later in virResctrlAllocGetUnused().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virresctrl.c

index e0a7a3e12759b5eee481365dfce0815c4a62a2bf..000191c5d43158e2960bda20f55009a28374c89e 100644 (file)
@@ -1798,6 +1798,38 @@ virResctrlAllocNewFromInfo(virResctrlInfo *info)
     return g_steal_pointer(&ret);
 }
 
+
+static int
+virResctrlAllocCopyMemBW(virResctrlAlloc *dst,
+                         virResctrlAlloc *src)
+{
+    size_t i = 0;
+    virResctrlAllocMemBW *dst_bw = NULL;
+    virResctrlAllocMemBW *src_bw = src->mem_bw;
+
+    if (!src->mem_bw)
+        return 0;
+
+    if (!dst->mem_bw)
+        dst->mem_bw = g_new0(virResctrlAllocMemBW, 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);
+
+    for (i = 0; i < src_bw->nbandwidths; i++) {
+        if (dst_bw->bandwidths[i])
+            continue;
+        dst_bw->bandwidths[i] = g_new0(unsigned int, 1);
+        *dst_bw->bandwidths[i] = *src_bw->bandwidths[i];
+    }
+
+    return 0;
+}
+
+
 /*
  * This function creates an allocation that represents all unused parts of all
  * caches in the system.  It uses virResctrlInfo for creating a new full
@@ -2031,37 +2063,6 @@ virResctrlAllocMemoryBandwidth(virResctrlInfo *resctrl,
 }
 
 
-static int
-virResctrlAllocCopyMemBW(virResctrlAlloc *dst,
-                         virResctrlAlloc *src)
-{
-    size_t i = 0;
-    virResctrlAllocMemBW *dst_bw = NULL;
-    virResctrlAllocMemBW *src_bw = src->mem_bw;
-
-    if (!src->mem_bw)
-        return 0;
-
-    if (!dst->mem_bw)
-        dst->mem_bw = g_new0(virResctrlAllocMemBW, 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);
-
-    for (i = 0; i < src_bw->nbandwidths; i++) {
-        if (dst_bw->bandwidths[i])
-            continue;
-        dst_bw->bandwidths[i] = g_new0(unsigned int, 1);
-        *dst_bw->bandwidths[i] = *src_bw->bandwidths[i];
-    }
-
-    return 0;
-}
-
-
 static int
 virResctrlAllocCopyMasks(virResctrlAlloc *dst,
                          virResctrlAlloc *src)