PAPR requires that PowerPC,<name> shall not contain underscores, so skip
any underscores in the type name.

Reported-by: Prerna Saxena <pre...@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaer...@suse.de>
---
 hw/ppc/spapr.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0e9be32..137e060 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -264,7 +264,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     char qemu_hypertas_prop[] = "hcall-memop1";
     uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
     uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
-    int i, smt = kvmppc_smt_threads();
+    int i, j, smt = kvmppc_smt_threads();
     unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
 
     fdt = g_malloc0(FDT_MAX_SIZE);
@@ -350,6 +350,17 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
             }
             nodename = g_strndup(typename,
                                  strlen(typename) - strlen("-" 
TYPE_POWERPC_CPU));
+            for (i = j = 0; j < strlen(nodename); i++, j++) {
+                if (nodename[j] == '_') {
+                    j++;
+                }
+                if (j > i) {
+                    nodename[i] = nodename[j];
+                }
+            }
+            if (j > i) {
+                nodename[i] = '\0';
+            }
             dc->fw_name = g_strdup_printf("PowerPC,%s", nodename);
             g_free(nodename);
         }
-- 
1.8.1.4


Reply via email to