From patchwork Fri Sep 26 20:45:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 393969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B9A2C1401EB for ; Sat, 27 Sep 2014 06:51:42 +1000 (EST) Received: from localhost ([::1]:52394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXcUO-00087v-Ep for incoming@patchwork.ozlabs.org; Fri, 26 Sep 2014 16:51:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXcPi-0008Ra-28 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 16:46:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXcPb-0006BJ-Rp for qemu-devel@nongnu.org; Fri, 26 Sep 2014 16:46:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXcPb-0006AJ-CW for qemu-devel@nongnu.org; Fri, 26 Sep 2014 16:46:43 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8QKkWTS014316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Sep 2014 16:46:32 -0400 Received: from localhost (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8QKkV0A030785; Fri, 26 Sep 2014 16:46:32 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 26 Sep 2014 17:45:24 -0300 Message-Id: <1411764332-23265-10-git-send-email-ehabkost@redhat.com> In-Reply-To: <1411764332-23265-1-git-send-email-ehabkost@redhat.com> References: <1411764332-23265-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Michael Mueller , Marcel Apfelbaum , "Michael S. Tsirkin" , Alexander Graf , Christian Borntraeger , "Jason J. Herne" , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH v3 09/17] accel: Move KVM accel registration to kvm-all.c 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 Note that this has an user-visible side-effect: instead of reporting "KVM is not supported for this target", QEMU binaries not supporting KVM will report "kvm accelerator does not exist". As kvm_availble() always return 1 when CONFIG_KVM is enabled, we don't need to set AccelClass.available anymore. kvm_enabled() is not being completely removed yet only because qmp_query_kvm() still uses it. This also allows us to make kvm_init() static. Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost --- accel.c | 18 ------------------ include/sysemu/kvm.h | 2 -- kvm-all.c | 26 +++++++++++++++++++++++++- kvm-stub.c | 5 ----- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/accel.c b/accel.c index fce6eab..a20e427 100644 --- a/accel.c +++ b/accel.c @@ -149,23 +149,6 @@ static const TypeInfo xen_accel_type = { .class_init = xen_accel_class_init, }; -static void kvm_accel_class_init(ObjectClass *oc, void *data) -{ - AccelClass *ac = ACCEL_CLASS(oc); - ac->name = "KVM"; - ac->available = kvm_available; - ac->init = kvm_init; - ac->allowed = &kvm_allowed; -} - -#define TYPE_KVM_ACCEL ACCEL_CLASS_NAME("kvm") - -static const TypeInfo kvm_accel_type = { - .name = TYPE_KVM_ACCEL, - .parent = TYPE_ACCEL, - .class_init = kvm_accel_class_init, -}; - static void qtest_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac = ACCEL_CLASS(oc); @@ -188,7 +171,6 @@ static void register_accel_types(void) type_register_static(&accel_type); type_register_static(&tcg_accel_type); type_register_static(&xen_accel_type); - type_register_static(&kvm_accel_type); type_register_static(&qtest_accel_type); } diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index d2000af..7f34006 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -163,8 +163,6 @@ extern KVMState *kvm_state; /* external API */ -int kvm_init(MachineClass *mc); - int kvm_has_sync_mmu(void); int kvm_has_vcpu_events(void); int kvm_has_robust_singlestep(void); diff --git a/kvm-all.c b/kvm-all.c index 8b9e66d..009c0dc 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -25,6 +25,7 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "sysemu/sysemu.h" +#include "sysemu/accel.h" #include "hw/hw.h" #include "hw/pci/msi.h" #include "hw/s390x/adapter.h" @@ -110,6 +111,8 @@ struct KVMState #endif }; +#define TYPE_KVM_ACCEL ACCEL_CLASS_NAME("kvm") + KVMState *kvm_state; bool kvm_kernel_irqchip; bool kvm_async_interrupts_allowed; @@ -1381,7 +1384,7 @@ static int kvm_max_vcpus(KVMState *s) return (ret) ? ret : kvm_recommended_vcpus(s); } -int kvm_init(MachineClass *mc) +static int kvm_init(MachineClass *mc) { static const char upgrade_note[] = "Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n" @@ -2227,3 +2230,24 @@ int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target) } return r; } + +static void kvm_accel_class_init(ObjectClass *oc, void *data) +{ + AccelClass *ac = ACCEL_CLASS(oc); + ac->name = "KVM"; + ac->init = kvm_init; + ac->allowed = &kvm_allowed; +} + +static const TypeInfo kvm_accel_type = { + .name = TYPE_KVM_ACCEL, + .parent = TYPE_ACCEL, + .class_init = kvm_accel_class_init, +}; + +static void kvm_type_init(void) +{ + type_register_static(&kvm_accel_type); +} + +type_init(kvm_type_init); diff --git a/kvm-stub.c b/kvm-stub.c index 8e7737c..43fc0dd 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -35,11 +35,6 @@ int kvm_init_vcpu(CPUState *cpu) return -ENOSYS; } -int kvm_init(MachineClass *mc) -{ - return -ENOSYS; -} - void kvm_flush_coalesced_mmio_buffer(void) { }