Let 'virDomainResctrlVcpuMatch' return a pointer of @virDomainResctrlDefPtr in its third parameter. Signed-off-by: Wang Huaqiang <huaqiang.wang@xxxxxxxxx> --- src/conf/domain_conf.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dcfd2dd..b0f5d80 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18992,7 +18992,7 @@ virDomainResctrlParseVcpus(virDomainDefPtr def, static int virDomainResctrlVcpuMatch(virDomainDefPtr def, virBitmapPtr vcpus, - virResctrlAllocPtr *alloc) + virDomainResctrlDefPtr *resctrl) { ssize_t i = 0; @@ -19001,7 +19001,7 @@ virDomainResctrlVcpuMatch(virDomainDefPtr def, * Just updating memory allocation information of that group */ if (virBitmapEqual(def->resctrls[i]->vcpus, vcpus)) { - *alloc = virObjectRef(def->resctrls[i]->alloc); + *resctrl = def->resctrls[i]; break; } if (virBitmapOverlaps(def->resctrls[i]->vcpus, vcpus)) { @@ -19331,19 +19331,19 @@ virDomainCachetuneDefParse(virDomainDefPtr def, return -1; } - if (virDomainResctrlVcpuMatch(def, vcpus, &alloc) < 0) + if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0) return -1; - if (!alloc) { - alloc = virResctrlAllocNew(); - if (!alloc) - return -1; - } else { + if (resctrl) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Identical vcpus in cachetunes found")); return -1; } + alloc = virResctrlAllocNew(); + if (!alloc) + return -1; + for (i = 0; i < n; i++) { if (virDomainCachetuneDefParseCache(ctxt, nodes[i], alloc) < 0) return -1; @@ -19519,7 +19519,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, ssize_t i = 0; int n; int ret = -1; - bool new_alloc = false; ctxt->node = node; @@ -19535,14 +19534,18 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, return -1; } - if (virDomainResctrlVcpuMatch(def, vcpus, &alloc) < 0) + if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0) return -1; - if (!alloc) { + if (resctrl && resctrl->alloc) { + alloc = virObjectRef(resctrl->alloc); + } else { alloc = virResctrlAllocNew(); - if (!alloc) - return -1; - new_alloc = true; + if (resctrl) { + alloc = virResctrlAllocNew(); + if (!alloc) + return -1; + } } for (i = 0; i < n; i++) { @@ -19557,7 +19560,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, * If this is a new allocation, format ID and append to resctrl, otherwise * just update the existing alloc information, which is done in above * virDomainMemorytuneDefParseMemory */ - if (new_alloc) { + if (!resctrl) { resctrl = virDomainResctrlNew(node, alloc, vcpus, flags); if (!resctrl) return -1; -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list