提交 49da4cf1 编写于 作者: J Jiri Denemark

cpu_x86: Don't ignore parsing errors in x86FeatureLoad

CPU map XML is our internal data file, it makes no sense to tolerate any
errors in it.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 db8a1873
...@@ -710,27 +710,26 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, ...@@ -710,27 +710,26 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
xmlNodePtr ctxt_node = ctxt->node; xmlNodePtr ctxt_node = ctxt->node;
virCPUx86FeaturePtr feature; virCPUx86FeaturePtr feature;
virCPUx86CPUID cpuid; virCPUx86CPUID cpuid;
int ret = 0; int ret = -1;
size_t i; size_t i;
int n; int n;
char *str = NULL; char *str = NULL;
bool migratable = true; bool migratable = true;
virCPUx86FeaturePtr migrate_blocker = NULL;
if (!(feature = x86FeatureNew())) if (!(feature = x86FeatureNew()))
goto error; goto cleanup;
feature->name = virXPathString("string(@name)", ctxt); feature->name = virXPathString("string(@name)", ctxt);
if (!feature->name) { if (!feature->name) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU feature name")); "%s", _("Missing CPU feature name"));
goto ignore; goto cleanup;
} }
if (x86FeatureFind(map, feature->name)) { if (x86FeatureFind(map, feature->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU feature %s already defined"), feature->name); _("CPU feature %s already defined"), feature->name);
goto ignore; goto cleanup;
} }
str = virXPathString("string(@migratable)", ctxt); str = virXPathString("string(@migratable)", ctxt);
...@@ -739,7 +738,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, ...@@ -739,7 +738,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
n = virXPathNodeSet("./cpuid", ctxt, &nodes); n = virXPathNodeSet("./cpuid", ctxt, &nodes);
if (n < 0) if (n < 0)
goto ignore; goto cleanup;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
ctxt->node = nodes[i]; ctxt->node = nodes[i];
...@@ -747,37 +746,35 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, ...@@ -747,37 +746,35 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid cpuid[%zu] in %s feature"), _("Invalid cpuid[%zu] in %s feature"),
i, feature->name); i, feature->name);
goto ignore; goto cleanup;
} }
if (virCPUx86DataAddCPUID(feature->data, &cpuid)) if (virCPUx86DataAddCPUID(feature->data, &cpuid))
goto error; goto cleanup;
} }
if (!migratable) { if (!migratable) {
if (!(migrate_blocker = x86FeatureCopy(feature))) virCPUx86FeaturePtr blocker;
goto error;
migrate_blocker->next = map->migrate_blockers; if (!(blocker = x86FeatureCopy(feature)))
map->migrate_blockers = migrate_blocker; goto cleanup;
blocker->next = map->migrate_blockers;
map->migrate_blockers = blocker;
} }
feature->next = map->features; feature->next = map->features;
map->features = feature; map->features = feature;
feature = NULL;
ret = 0;
cleanup: cleanup:
x86FeatureFree(feature);
ctxt->node = ctxt_node; ctxt->node = ctxt_node;
VIR_FREE(nodes); VIR_FREE(nodes);
VIR_FREE(str); VIR_FREE(str);
return ret; return ret;
error:
ret = -1;
ignore:
x86FeatureFree(feature);
x86FeatureFree(migrate_blocker);
goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册