]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virresctrl: Fix updating the mask for a cache resource
authorVinayak Kale <vkale@nvidia.com>
Fri, 2 Jul 2021 07:23:15 +0000 (12:53 +0530)
committerJán Tomko <jtomko@redhat.com>
Wed, 7 Jul 2021 14:19:40 +0000 (16:19 +0200)
In 'virResctrlAllocUpdateMask', mask is updated only if 'previous mask' is NULL.

By default, the bitmask for a cache resource for a VM is initialized with
'default-resctrl-group' bitmask. So the 'previous mask' would not be NULL and
mask won't get updated if cachetune is configured for a VM. This causes libvirt
to use same bitmask as 'default-resctrl-group' bitmask for a cache resource for
a VM. This patch fixes the issue.

Fixes: d8a354954aba9cd45ab0317915a0a2be27c04767
Signed-off-by: Vinayak Kale <vkale@nvidia.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/util/virresctrl.c

index 35e92022dbde25e0c13eeac7182f98ea8178d57f..a7d36f492cd2a1096c6754da60663d48062fe576 100644 (file)
@@ -1104,8 +1104,10 @@ virResctrlAllocUpdateMask(virResctrlAlloc *alloc,
         VIR_EXPAND_N(a_type->masks, a_type->nmasks,
                      cache - a_type->nmasks + 1);
 
-    if (!a_type->masks[cache])
-        a_type->masks[cache] = virBitmapNewCopy(mask);
+    if (a_type->masks[cache])
+        virBitmapFree(a_type->masks[cache]);
+
+    a_type->masks[cache] = virBitmapNewCopy(mask);
 
     return 0;
 }