resctrl object stored in def->resctrls is shared by cachetune and
memorytune. The domain xml configuration is parsed firstly for
cachetune then memorytune, and the resctrl object will not be created
in parsing settings for memorytune once it found sharing exists.
But resctrl is improperly freed when sharing happens.
Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
ssize_t i = 0;
int n;
- int ret = -1;
ctxt->node = node;
if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
return -1;
- if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0)
- goto cleanup;
+ if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0) {
+ virDomainResctrlDefFree(resctrl);
+ return -1;
+ }
}
- ret = 0;
- cleanup:
- virDomainResctrlDefFree(resctrl);
- return ret;
+ return 0;
}
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>4</vcpu>
<cputune>
+ <cachetune vcpus='0-1'>
+ <cache id='0' level='3' type='both' size='768' unit='KiB'/>
+ <cache id='1' level='3' type='both' size='768' unit='KiB'/>
+ </cachetune>
<memorytune vcpus='0-1'>
<node id='0' bandwidth='20'/>
<node id='1' bandwidth='30'/>