From 51da92f418e6150b239b731a173dc59b182304aa Mon Sep 17 00:00:00 2001 From: Wang Huaqiang Date: Tue, 20 Aug 2019 18:06:03 +0800 Subject: [PATCH] conf: resctrl object is not properly handled 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 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 12 +++++------- tests/genericxml2xmlindata/memorytune.xml | 4 ++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 617ccac4a5..604e006dab 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19590,7 +19590,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL; ssize_t i = 0; int n; - int ret = -1; ctxt->node = node; @@ -19632,14 +19631,13 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, 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; } diff --git a/tests/genericxml2xmlindata/memorytune.xml b/tests/genericxml2xmlindata/memorytune.xml index ea03e22fc2..7486b542c5 100644 --- a/tests/genericxml2xmlindata/memorytune.xml +++ b/tests/genericxml2xmlindata/memorytune.xml @@ -5,6 +5,10 @@ 219136 4 + + + +