From patchwork Tue Aug 9 16:59:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 9271933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 741B060839 for ; Tue, 9 Aug 2016 17:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 628D928375 for ; Tue, 9 Aug 2016 17:17:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 574FF28389; Tue, 9 Aug 2016 17:17:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D06E628375 for ; Tue, 9 Aug 2016 17:17:56 +0000 (UTC) Received: from localhost ([::1]:36861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXAf5-0007kz-Ub for patchwork-qemu-devel@patchwork.kernel.org; Tue, 09 Aug 2016 13:17:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXAO1-0006mg-At for qemu-devel@nongnu.org; Tue, 09 Aug 2016 13:00:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXANx-00032p-Jf for qemu-devel@nongnu.org; Tue, 09 Aug 2016 13:00:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXANx-00032R-Ap; Tue, 09 Aug 2016 13:00:13 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8D4F43A4E; Tue, 9 Aug 2016 17:00:12 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u79H01DS030452; Tue, 9 Aug 2016 13:00:10 -0400 From: Thomas Huth To: David Gibson , qemu-ppc@nongnu.org Date: Tue, 9 Aug 2016 18:59:59 +0200 Message-Id: <1470762001-414-4-git-send-email-thuth@redhat.com> In-Reply-To: <1470762001-414-1-git-send-email-thuth@redhat.com> References: <1470762001-414-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 09 Aug 2016 17:00:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/5] hw/ppc/spapr: Look up CPU alias names instead of hard-coding the aliases X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: clg@kaod.org, bharata@linux.vnet.ibm.com, Alexander Graf , abologna@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hard-coding the CPU alias names in the spapr_cores[] array has two big disadvantages: 1) We register a real type with the CPU alias name in spapr_cpu_core_register_types() - this prevents us from registering a CPU family name in kvm_ppc_register_host_cpu_type() with the same name (as we do it for the non-hotpluggable CPU types). 2) It's quite cumbersome to maintain the aliases here in sync with the ppc_cpu_aliases list from target-ppc/cpu-models.c. So let's simply add proper alias lookup to the spapr cpu core code, too (by checking whether the given model can be used directly, and if not by trying to look up the given model as an alias name instead). Signed-off-by: Thomas Huth --- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_cpu_core.c | 38 +++++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 399dcc0..0787c66 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1815,7 +1815,7 @@ static void ppc_spapr_init(MachineState *machine) if (mc->query_hotpluggable_cpus) { char *type = spapr_get_cpu_core_type(machine->cpu_model); - if (!object_class_by_name(type)) { + if (type == NULL) { error_report("Unable to find sPAPR CPU Core definition"); exit(1); } diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 716f7c4..bcb483d 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -93,6 +93,19 @@ char *spapr_get_cpu_core_type(const char *model) core_type = g_strdup_printf("%s-%s", model_pieces[0], TYPE_SPAPR_CPU_CORE); g_strfreev(model_pieces); + + /* Check whether it exists or whether we have to look up an alias name */ + if (!object_class_by_name(core_type)) { + const char *realmodel; + + g_free(core_type); + realmodel = ppc_cpu_lookup_alias(model); + if (realmodel) { + return spapr_get_cpu_core_type(realmodel); + } + return NULL; + } + return core_type; } @@ -354,41 +367,32 @@ typedef struct SPAPRCoreInfo { } SPAPRCoreInfo; static const SPAPRCoreInfo spapr_cores[] = { - /* 970 and aliaes */ + /* 970 */ { .name = "970_v2.2", .initfn = spapr_cpu_core_970_initfn }, - { .name = "970", .initfn = spapr_cpu_core_970_initfn }, - /* 970MP variants and aliases */ + /* 970MP variants */ { .name = "970MP_v1.0", .initfn = spapr_cpu_core_970MP_v10_initfn }, { .name = "970mp_v1.0", .initfn = spapr_cpu_core_970MP_v10_initfn }, { .name = "970MP_v1.1", .initfn = spapr_cpu_core_970MP_v11_initfn }, { .name = "970mp_v1.1", .initfn = spapr_cpu_core_970MP_v11_initfn }, - { .name = "970mp", .initfn = spapr_cpu_core_970MP_v11_initfn }, - /* POWER5 and aliases */ + /* POWER5+ */ { .name = "POWER5+_v2.1", .initfn = spapr_cpu_core_POWER5plus_initfn }, - { .name = "POWER5+", .initfn = spapr_cpu_core_POWER5plus_initfn }, - /* POWER7 and aliases */ + /* POWER7 */ { .name = "POWER7_v2.3", .initfn = spapr_cpu_core_POWER7_initfn }, - { .name = "POWER7", .initfn = spapr_cpu_core_POWER7_initfn }, - /* POWER7+ and aliases */ + /* POWER7+ */ { .name = "POWER7+_v2.1", .initfn = spapr_cpu_core_POWER7plus_initfn }, - { .name = "POWER7+", .initfn = spapr_cpu_core_POWER7plus_initfn }, - /* POWER8 and aliases */ + /* POWER8 */ { .name = "POWER8_v2.0", .initfn = spapr_cpu_core_POWER8_initfn }, - { .name = "POWER8", .initfn = spapr_cpu_core_POWER8_initfn }, - { .name = "power8", .initfn = spapr_cpu_core_POWER8_initfn }, - /* POWER8E and aliases */ + /* POWER8E */ { .name = "POWER8E_v2.1", .initfn = spapr_cpu_core_POWER8E_initfn }, - { .name = "POWER8E", .initfn = spapr_cpu_core_POWER8E_initfn }, - /* POWER8NVL and aliases */ + /* POWER8NVL */ { .name = "POWER8NVL_v1.0", .initfn = spapr_cpu_core_POWER8NVL_initfn }, - { .name = "POWER8NVL", .initfn = spapr_cpu_core_POWER8NVL_initfn }, { .name = NULL } };