cpu: Fix loading PowerPC vendor from cpu_map.xml

When ppcVendorLoad fails to parse the vendor element for whatever
reason, it is supposed to ignore it and return 0 rather than -1. The
patch also removes PowerPC vendor string from the XML as it is not
actually used for anything.
This commit is contained in:
Jiri Denemark 2012-12-19 00:06:45 +01:00
parent 70349cb90d
commit ba8ba24711
2 changed files with 13 additions and 24 deletions

View File

@ -586,7 +586,8 @@
</arch> </arch>
<arch name='ppc64'> <arch name='ppc64'>
<!-- vendor definitions --> <!-- vendor definitions -->
<vendor name='IBM' string='PowerPC'/> <vendor name='IBM'/>
<!-- IBM-based CPU models --> <!-- IBM-based CPU models -->
<model name='POWER7'> <model name='POWER7'>
<vendor name='IBM'/> <vendor name='IBM'/>

View File

@ -203,11 +203,11 @@ ppcVendorLoad(xmlXPathContextPtr ctxt,
struct ppc_map *map) struct ppc_map *map)
{ {
struct ppc_vendor *vendor = NULL; struct ppc_vendor *vendor = NULL;
char *string = NULL;
int ret = -1;
if (VIR_ALLOC(vendor) < 0) if (VIR_ALLOC(vendor) < 0) {
goto no_memory; virReportOOMError();
return -1;
}
vendor->name = virXPathString("string(@name)", ctxt); vendor->name = virXPathString("string(@name)", ctxt);
if (!vendor->name) { if (!vendor->name) {
@ -222,31 +222,19 @@ ppcVendorLoad(xmlXPathContextPtr ctxt,
goto ignore; goto ignore;
} }
string = virXPathString("string(@string)", ctxt); if (!map->vendors) {
if (!string) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing vendor string for CPU vendor %s"), vendor->name);
goto ignore;
}
if (!map->vendors)
map->vendors = vendor; map->vendors = vendor;
else { } else {
vendor->next = map->vendors; vendor->next = map->vendors;
map->vendors = vendor; map->vendors = vendor;
} }
ret = 0; cleanup:
return 0;
out:
VIR_FREE(string);
return ret;
no_memory:
virReportOOMError();
ignore: ignore:
ppcVendorFree(vendor); ppcVendorFree(vendor);
goto out; goto cleanup;
} }
static int static int