[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 09/17] accel: Move KVM accel registration to kvm-
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH v3 09/17] accel: Move KVM accel registration to kvm-all.c |
Date: |
Fri, 26 Sep 2014 17:45:24 -0300 |
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 <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
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)
{
}
--
1.9.3
- [Qemu-devel] [PATCH v3 00/17] QOMify accelerator code, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 01/17] vl.c: Small coding style fix, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 02/17] accel: Move accel code to accel.c, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 03/17] accel: Create AccelType typedef, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 04/17] accel: Simplify configure_accelerator() using AccelType *acc variable, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 05/17] accel: Move accel name lookup to separate function, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 06/17] accel: Use QOM classes for accel types, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 07/17] accel: Make AccelClass.available() optional, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 08/17] accel: Report unknown accelerator as "not found" instead of "does not exist", Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 09/17] accel: Move KVM accel registration to kvm-all.c,
Eduardo Habkost <=
- [Qemu-devel] [PATCH v3 10/17] accel: Move Xen registration code to xen-common.c, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 11/17] accel: Move qtest accel registration to qtest.c, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 12/17] accel: Remove tcg_available() function, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 13/17] accel: Move accel init/allowed code to separate function, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 14/17] accel: Rename 'init' method to 'init_machine', Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 15/17] accel: Pass MachineState object to accel init functions, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 16/17] accel: Create accel object when initializing machine, Eduardo Habkost, 2014/09/26
- [Qemu-devel] [PATCH v3 17/17] kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct, Eduardo Habkost, 2014/09/26
- Re: [Qemu-devel] [PATCH v3 00/17] QOMify accelerator code, Paolo Bonzini, 2014/09/29