Re: [Qemu-devel] [PATCH qom-cpu 3/4] target-ppc: Slim conversion of model definitions to QOM subclasses

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

 



Am 18.12.2012 08:53, schrieb Andreas Färber:
> +static gint ppc_cpu_compare_class_name(gconstpointer a, gconstpointer b)
> +{
> +    ObjectClass *oc = (ObjectClass *)a;
> +    const char *name = b;
>  
> -    return NULL;
> +    if (strncasecmp(name, object_class_get_name(oc), strlen(name)) == 0 &&
> +        strcmp(object_class_get_name(oc) + strlen(name),
> +               "-" TYPE_POWERPC_CPU) == 0) {
> +        return 0;
> +    }
> +    return -1;
>  }
>  
>  #include <ctype.h>
>  
> -const ppc_def_t *cpu_ppc_find_by_name (const char *name)
> +static ObjectClass *ppc_cpu_class_by_name(const char *name)
[...]
> +    list = object_class_get_list(TYPE_POWERPC_CPU, false);
> +    item = g_slist_find_custom(list, name, ppc_cpu_compare_class_name);
> +    if (item != NULL) {
> +        ret = OBJECT_CLASS(item->data);
>      }
> +    g_slist_free(list);
>  
>      return ret;
>  }
[...]
> +static void ppc_cpu_register_model(const ppc_def_t *def)
> +{
> +    TypeInfo type_info = {
> +        .name = def->name,
> +        .parent = TYPE_POWERPC_CPU,
> +        .class_init = ppc_cpu_def_class_init,
> +        .class_data = (void *)def,
> +    };
> +
> +    type_register(&type_info);
>  }

Err, needs the following fix:

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 908a558..ad0763e 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -10446,13 +10446,14 @@ static void ppc_cpu_def_class_init(ObjectClass
*oc, void *data)
 static void ppc_cpu_register_model(const ppc_def_t *def)
 {
     TypeInfo type_info = {
-        .name = def->name,
         .parent = TYPE_POWERPC_CPU,
         .class_init = ppc_cpu_def_class_init,
         .class_data = (void *)def,
     };

+    type_info.name = g_strdup_printf("%s-" TYPE_POWERPC_CPU, def->name),
     type_register(&type_info);
+    g_free((gpointer)type_info.name);
 }

 /* CPUClass::reset() */

Not sure how I managed to screw this up so badly, seems I tested corner
cases and -cpu host too much...

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux