From patchwork Mon Jun 6 15:16:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 9158649 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 8FA8060572 for ; Mon, 6 Jun 2016 15:50:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81137282EE for ; Mon, 6 Jun 2016 15:50:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75DA72833A; Mon, 6 Jun 2016 15:50:47 +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 21671282EE for ; Mon, 6 Jun 2016 15:50:47 +0000 (UTC) Received: from localhost ([::1]:43285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9wne-0004vx-63 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 11:50:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9wHB-0000Vx-Sc for qemu-devel@nongnu.org; Mon, 06 Jun 2016 11:17:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9wH9-0006yl-RK for qemu-devel@nongnu.org; Mon, 06 Jun 2016 11:17:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9wH3-0006xE-7K; Mon, 06 Jun 2016 11:17:05 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 CE05419CBEF; Mon, 6 Jun 2016 15:17:03 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u56FGtmw013155; Mon, 6 Jun 2016 11:17:02 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 17:16:45 +0200 Message-Id: <1465226212-254093-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1465226212-254093-1-git-send-email-imammedo@redhat.com> References: <1465226212-254093-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Jun 2016 15:17:03 +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 03/10] target-i386: cpu: move xcc->kvm_required check to realize time 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: peter.maydell@linaro.org, ehabkost@redhat.com, mark.cave-ayland@ilande.co.uk, blauwirbel@gmail.com, qemu-arm@nongnu.org, pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP it will allow to drop custom cpu_x86_init() and use cpu_generic_init() insteadi, reducing cpu_x86_create() to a simple 3-liner. Signed-off-by: Igor Mammedov Eduardo Habkost --- v1: - use x86_cpu_class_get_model_name() for getting cpu model name --- target-i386/cpu.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 79a9b61..ae67a15 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -677,6 +677,14 @@ static ObjectClass *x86_cpu_class_by_name(const char *cpu_model) return oc; } +static char *x86_cpu_class_get_model_name(X86CPUClass *cc) +{ + const char *class_name = object_class_get_name(OBJECT_CLASS(cc)); + assert(g_str_has_suffix(class_name, X86_CPU_TYPE_SUFFIX)); + return g_strndup(class_name, + strlen(class_name) - strlen(X86_CPU_TYPE_SUFFIX)); +} + struct X86CPUDefinition { const char *name; uint32_t level; @@ -2169,7 +2177,6 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp) X86CPU *cpu_x86_create(const char *cpu_model, Error **errp) { X86CPU *cpu = NULL; - X86CPUClass *xcc; ObjectClass *oc; gchar **model_pieces; char *name, *features; @@ -2188,12 +2195,6 @@ X86CPU *cpu_x86_create(const char *cpu_model, Error **errp) error_setg(&error, "Unable to find CPU definition: %s", name); goto out; } - xcc = X86_CPU_CLASS(oc); - - if (xcc->kvm_required && !kvm_enabled()) { - error_setg(&error, "CPU model '%s' requires KVM", name); - goto out; - } cpu = X86_CPU(object_new(object_class_get_name(oc))); @@ -2870,6 +2871,13 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) static bool ht_warned; FeatureWord w; + if (xcc->kvm_required && !kvm_enabled()) { + char *name = x86_cpu_class_get_model_name(xcc); + error_setg(&local_err, "CPU model '%s' requires KVM", name); + g_free(name); + goto out; + } + if (cpu->apic_id < 0) { error_setg(errp, "apic-id property was not initialized properly"); return;