accel: Move KVM accel registration to kvm-all.c

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 <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Eduardo Habkost 2014-09-26 17:45:24 -03:00 committed by Paolo Bonzini
parent b31f9acaaa
commit 782c3f2939
4 changed files with 25 additions and 26 deletions

18
accel.c
View file

@ -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);
}

View file

@ -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);

View file

@ -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"
@ -106,6 +107,8 @@ struct KVMState
#endif
};
#define TYPE_KVM_ACCEL ACCEL_CLASS_NAME("kvm")
KVMState *kvm_state;
bool kvm_kernel_irqchip;
bool kvm_async_interrupts_allowed;
@ -1377,7 +1380,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"
@ -2225,3 +2228,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);

View file

@ -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)
{
}