[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/8] 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.
---
 src/cpu/cpu_map.xml   |  7 ++++---
 src/cpu/cpu_powerpc.c | 30 +++++++++---------------------
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index eb69a34..ba8c17d 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -585,9 +585,10 @@
     </model>
   </arch>
   <arch name='ppc64'>
-   <!-- vendor definitions -->
-    <vendor name='IBM' string='PowerPC'/>
-   <!-- IBM-based CPU models -->
+    <!-- vendor definitions -->
+    <vendor name='IBM'/>
+
+    <!-- IBM-based CPU models -->
     <model name='POWER7'>
       <vendor name='IBM'/>
     </model>
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index d5e9dd4..3fa98bd 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -203,11 +203,11 @@ ppcVendorLoad(xmlXPathContextPtr ctxt,
               struct ppc_map *map)
 {
     struct ppc_vendor *vendor = NULL;
-    char *string = NULL;
-    int ret = -1;
 
-    if (VIR_ALLOC(vendor) < 0)
-        goto no_memory;
+    if (VIR_ALLOC(vendor) < 0) {
+        virReportOOMError();
+        return -1;
+    }
 
     vendor->name = virXPathString("string(@name)", ctxt);
     if (!vendor->name) {
@@ -222,31 +222,19 @@ ppcVendorLoad(xmlXPathContextPtr ctxt,
         goto ignore;
     }
 
-    string = virXPathString("string(@string)", ctxt);
-    if (!string) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Missing vendor string for CPU vendor %s"), vendor->name);
-        goto ignore;
-    }
-    if (!map->vendors)
+    if (!map->vendors) {
         map->vendors = vendor;
-    else {
+    } else {
         vendor->next = map->vendors;
         map->vendors = vendor;
     }
 
-    ret = 0;
-
-out:
-    VIR_FREE(string);
-    return ret;
-
-no_memory:
-    virReportOOMError();
+cleanup:
+    return 0;
 
 ignore:
     ppcVendorFree(vendor);
-    goto out;
+    goto cleanup;
 }
 
 static int
-- 
1.8.0.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]