提交 48e188d2 编写于 作者: W Wang Huaqiang 提交者: Michal Privoznik

conf: code cleanup for return error code directly

code cleanup for 'virDomainCachetuneDefParse' and
'virDomainMemorytuneDefParse'.
Signed-off-by: NWang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 53c87fb9
......@@ -19374,40 +19374,38 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
ctxt->node = node;
if (virDomainResctrlParseVcpus(def, node, &vcpus) < 0)
goto cleanup;
return -1;
if (virBitmapIsAllClear(vcpus)) {
ret = 0;
goto cleanup;
}
if (virBitmapIsAllClear(vcpus))
return 0;
if ((n = virXPathNodeSet("./cache", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot extract cache nodes under cachetune"));
goto cleanup;
return -1;
}
if (virDomainResctrlVcpuMatch(def, vcpus, &alloc) < 0)
goto cleanup;
return -1;
if (!alloc) {
alloc = virResctrlAllocNew();
if (!alloc)
goto cleanup;
return -1;
} else {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Identical vcpus in cachetunes found"));
goto cleanup;
return -1;
}
for (i = 0; i < n; i++) {
if (virDomainCachetuneDefParseCache(ctxt, nodes[i], alloc) < 0)
goto cleanup;
return -1;
}
resctrl = virDomainResctrlNew(node, alloc, vcpus, flags);
if (!resctrl)
goto cleanup;
return -1;
if (virDomainResctrlMonDefParse(def, ctxt, node,
VIR_RESCTRL_MONITOR_TYPE_CACHE,
......@@ -19580,37 +19578,35 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
ctxt->node = node;
if (virDomainResctrlParseVcpus(def, node, &vcpus) < 0)
goto cleanup;
return -1;
if (virBitmapIsAllClear(vcpus)) {
ret = 0;
goto cleanup;
}
if (virBitmapIsAllClear(vcpus))
return 0;
if ((n = virXPathNodeSet("./node", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot extract memory nodes under memorytune"));
goto cleanup;
return -1;
}
if (virDomainResctrlVcpuMatch(def, vcpus, &alloc) < 0)
goto cleanup;
return -1;
if (!alloc) {
alloc = virResctrlAllocNew();
if (!alloc)
goto cleanup;
return -1;
new_alloc = true;
}
for (i = 0; i < n; i++) {
if (virDomainMemorytuneDefParseMemory(ctxt, nodes[i], alloc) < 0)
goto cleanup;
}
if (virResctrlAllocIsEmpty(alloc)) {
ret = 0;
goto cleanup;
return -1;
}
if (virResctrlAllocIsEmpty(alloc))
return 0;
/*
* If this is a new allocation, format ID and append to resctrl, otherwise
* just update the existing alloc information, which is done in above
......@@ -19618,7 +19614,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
if (new_alloc) {
resctrl = virDomainResctrlNew(node, alloc, vcpus, flags);
if (!resctrl)
goto cleanup;
return -1;
if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册