From patchwork Thu Aug 16 16:59:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 178068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A58542C0093 for ; Fri, 17 Aug 2012 04:26:35 +1000 (EST) Received: from localhost ([::1]:40415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T24jO-00020C-68 for incoming@patchwork.ozlabs.org; Thu, 16 Aug 2012 14:23:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T24jC-0001pX-Ft for qemu-devel@nongnu.org; Thu, 16 Aug 2012 14:23:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T24jB-00065b-Dv for qemu-devel@nongnu.org; Thu, 16 Aug 2012 14:23:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T24jB-00065U-5D for qemu-devel@nongnu.org; Thu, 16 Aug 2012 14:23:29 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7GILSn5022946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 16 Aug 2012 14:23:04 -0400 Received: from blackpad.lan.raisama.net (vpn1-6-48.gru2.redhat.com [10.97.6.48]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7GGw9D6032635; Thu, 16 Aug 2012 12:58:10 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 1007C2011A4; Thu, 16 Aug 2012 13:59:14 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2012 13:59:09 -0300 Message-Id: <1345136352-10756-11-git-send-email-ehabkost@redhat.com> In-Reply-To: <1345136352-10756-1-git-send-email-ehabkost@redhat.com> References: <1345136352-10756-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, gleb@redhat.com, vijaymohan.pandarathil@hp.com, jan.kiszka@siemens.com, mtosatti@redhat.com, mdroth@linux.vnet.ibm.com, blauwirbel@gmail.com, avi@redhat.com, pbonzini@redhat.com, akong@redhat.com, lersek@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [RFC 10/13] cpu_x86_create: reorder parsing of CPU model string and creation of CPU object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A step towards making the creation of CPU objects use the CPU model name as class name. Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e7f32fc..2e24e00 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1508,18 +1508,19 @@ X86CPU *cpu_x86_create(const char *cpu_model) QDict *features = NULL; char *name = NULL; - cpu = X86_CPU(object_new(TYPE_X86_CPU)); - env = &cpu->env; - env->cpu_model_str = cpu_model; - /* for CPU subclasses should go into cpu_x86_init() before object_new() */ compat_normalize_cpu_model(cpu_model, &name, &features, &error); if (error_is_set(&error)) { - goto error; + goto error_normalize; } /* this block should be replaced by CPU subclasses */ memset(def, 0, sizeof(*def)); + + cpu = X86_CPU(object_new(TYPE_X86_CPU)); + env = &cpu->env; + env->cpu_model_str = cpu_model; + if (cpu_x86_find_by_name(cpu, def, name, &error) < 0) { goto error; } @@ -1538,13 +1539,14 @@ X86CPU *cpu_x86_create(const char *cpu_model) x86_cpu_realize(OBJECT(cpu), NULL); return cpu; error: + object_delete(OBJECT(cpu)); +error_normalize: QDECREF(features); g_free(name); if (error_is_set(&error)) { fprintf(stderr, "%s\n", error_get_pretty(error)); error_free(error); } - object_delete(OBJECT(cpu)); return NULL; }