From: Vinayak Kale Date: Fri, 2 Jul 2021 07:23:15 +0000 (+0530) Subject: virresctrl: Fix updating the mask for a cache resource X-Git-Tag: v7.6.0-rc1~244 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9c7da6126750da3b4e6357080a1ee66ed8d5b57;p=thirdparty%2Flibvirt.git virresctrl: Fix updating the mask for a cache resource 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 Reviewed-by: Ján Tomko Reviewed-by: Daniel Henrique Barboza Signed-off-by: Ján Tomko --- diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 35e92022db..a7d36f492c 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -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; }