ppc: make cpu_model translation to type consistent
PPC handles -cpu FOO rather incosistently, i.e. it does case-insensitive matching of FOO to a CPU type (see: ppc_cpu_compare_class_name) but handles alias names as case-sensitive, as result: # qemu-system-ppc64 -M mac99 -cpu g3 qemu-system-ppc64: unable to find CPU model ' kN�U' # qemu-system-ppc64 -cpu 970MP_V1.1 qemu-system-ppc64: Unable to find sPAPR CPU Core definition while # qemu-system-ppc64 -M mac99 -cpu G3 # qemu-system-ppc64 -cpu 970MP_v1.1 start up just fine. Considering we can't take case-insensitive matching away, make it case-insensitive for all alias/type/core_type lookups. As side effect it allows to remove duplicate core types which are the same except of using different cased letters in name. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
		
							parent
							
								
									c913706581
								
							
						
					
					
						commit
						c5354f54aa
					
				| 
						 | 
					@ -130,8 +130,10 @@ char *spapr_get_cpu_core_type(const char *model)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    char *core_type;
 | 
					    char *core_type;
 | 
				
			||||||
    gchar **model_pieces = g_strsplit(model, ",", 2);
 | 
					    gchar **model_pieces = g_strsplit(model, ",", 2);
 | 
				
			||||||
 | 
					    gchar *cpu_model = g_ascii_strdown(model_pieces[0], -1);
 | 
				
			||||||
 | 
					    g_strfreev(model_pieces);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    core_type = g_strdup_printf("%s-%s", model_pieces[0], TYPE_SPAPR_CPU_CORE);
 | 
					    core_type = g_strdup_printf("%s-" TYPE_SPAPR_CPU_CORE, cpu_model);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Check whether it exists or whether we have to look up an alias name */
 | 
					    /* Check whether it exists or whether we have to look up an alias name */
 | 
				
			||||||
    if (!object_class_by_name(core_type)) {
 | 
					    if (!object_class_by_name(core_type)) {
 | 
				
			||||||
| 
						 | 
					@ -139,13 +141,13 @@ char *spapr_get_cpu_core_type(const char *model)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        g_free(core_type);
 | 
					        g_free(core_type);
 | 
				
			||||||
        core_type = NULL;
 | 
					        core_type = NULL;
 | 
				
			||||||
        realmodel = ppc_cpu_lookup_alias(model_pieces[0]);
 | 
					        realmodel = ppc_cpu_lookup_alias(cpu_model);
 | 
				
			||||||
        if (realmodel) {
 | 
					        if (realmodel) {
 | 
				
			||||||
            core_type = spapr_get_cpu_core_type(realmodel);
 | 
					            core_type = spapr_get_cpu_core_type(realmodel);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    g_free(cpu_model);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_strfreev(model_pieces);
 | 
					 | 
				
			||||||
    return core_type;
 | 
					    return core_type;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -273,31 +275,29 @@ static const char *spapr_core_models[] = {
 | 
				
			||||||
    "970_v2.2",
 | 
					    "970_v2.2",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* 970MP variants */
 | 
					    /* 970MP variants */
 | 
				
			||||||
    "970MP_v1.0",
 | 
					 | 
				
			||||||
    "970mp_v1.0",
 | 
					    "970mp_v1.0",
 | 
				
			||||||
    "970MP_v1.1",
 | 
					 | 
				
			||||||
    "970mp_v1.1",
 | 
					    "970mp_v1.1",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* POWER5+ */
 | 
					    /* POWER5+ */
 | 
				
			||||||
    "POWER5+_v2.1",
 | 
					    "power5+_v2.1",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* POWER7 */
 | 
					    /* POWER7 */
 | 
				
			||||||
    "POWER7_v2.3",
 | 
					    "power7_v2.3",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* POWER7+ */
 | 
					    /* POWER7+ */
 | 
				
			||||||
    "POWER7+_v2.1",
 | 
					    "power7+_v2.1",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* POWER8 */
 | 
					    /* POWER8 */
 | 
				
			||||||
    "POWER8_v2.0",
 | 
					    "power8_v2.0",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* POWER8E */
 | 
					    /* POWER8E */
 | 
				
			||||||
    "POWER8E_v2.1",
 | 
					    "power8e_v2.1",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* POWER8NVL */
 | 
					    /* POWER8NVL */
 | 
				
			||||||
    "POWER8NVL_v1.0",
 | 
					    "power8nvl_v1.0",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* POWER9 */
 | 
					    /* POWER9 */
 | 
				
			||||||
    "POWER9_v1.0",
 | 
					    "power9_v1.0",
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static Property spapr_cpu_core_properties[] = {
 | 
					static Property spapr_cpu_core_properties[] = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -2525,7 +2525,7 @@ static int kvm_ppc_register_host_cpu_type(void)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    dc = DEVICE_CLASS(ppc_cpu_get_family_class(pvr_pcc));
 | 
					    dc = DEVICE_CLASS(ppc_cpu_get_family_class(pvr_pcc));
 | 
				
			||||||
    for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
 | 
					    for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
 | 
				
			||||||
        if (strcmp(ppc_cpu_aliases[i].alias, dc->desc) == 0) {
 | 
					        if (strcasecmp(ppc_cpu_aliases[i].alias, dc->desc) == 0) {
 | 
				
			||||||
            char *suffix;
 | 
					            char *suffix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ppc_cpu_aliases[i].model = g_strdup(object_class_get_name(oc));
 | 
					            ppc_cpu_aliases[i].model = g_strdup(object_class_get_name(oc));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10326,7 +10326,7 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
 | 
					    for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
 | 
				
			||||||
        if (strcmp(ppc_cpu_aliases[i].alias, name) == 0) {
 | 
					        if (strcasecmp(ppc_cpu_aliases[i].alias, name) == 0) {
 | 
				
			||||||
            return ppc_cpu_class_by_alias(&ppc_cpu_aliases[i]);
 | 
					            return ppc_cpu_class_by_alias(&ppc_cpu_aliases[i]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue