From patchwork Wed Dec 19 02:46:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 1894411 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A79E83FCD4 for ; Wed, 19 Dec 2012 02:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754517Ab2LSCqW (ORCPT ); Tue, 18 Dec 2012 21:46:22 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39613 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752924Ab2LSCqV (ORCPT ); Tue, 18 Dec 2012 21:46:21 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id F0F81A4E82; Wed, 19 Dec 2012 03:46:19 +0100 (CET) Message-ID: <50D12A72.6030801@suse.de> Date: Wed, 19 Dec 2012 03:46:10 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Organization: SUSE LINUX Products GmbH User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Alexander Graf Cc: qemu-devel@nongnu.org, kvm , Marcelo Tosatti , qemu-ppc , David Gibson Subject: Re: [Qemu-devel] [PATCH qom-cpu 3/4] target-ppc: Slim conversion of model definitions to QOM subclasses References: <1355817223-13076-1-git-send-email-afaerber@suse.de> <1355817223-13076-4-git-send-email-afaerber@suse.de> In-Reply-To: <1355817223-13076-4-git-send-email-afaerber@suse.de> X-Enigmail-Version: 1.4.6 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 > > -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: /* CPUClass::reset() */ Not sure how I managed to screw this up so badly, seems I tested corner cases and -cpu host too much... Andreas 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); }