Newer userspace may run on an older kernel. Therefore we need a way to check the capabilities of the kernel so that we can downgrade userspace dynamically if necessary
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]> --- qemu/qemu-kvm.c | 19 +++++++++++++++++++ user/kvmctl.c | 14 ++++++++++++++ user/kvmctl.h | 5 +++++ 3 files changed, 38 insertions(+), 0 deletions(-) diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c index 59e79bf..6096f21 100644 --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -697,6 +697,25 @@ int kvm_qemu_init() int kvm_qemu_create_context(void) { int i; + uint64_t ext; + + if (kvm_check_extension(kvm_context, &ext) < 0) { + kvm_qemu_destroy(); + return -1; + } + + if (!(ext & KVM_EXTENSION_LAPIC) && kvm_apic_level) { + /* + * Opps... the kernel doesnt support apic-emulation even though + * the user wants it. We must turn this off and warn the user + */ + kvm_apic_level = 0; + + /* FIXME: We should log this officially */ + printf("WARNING: older kernel does not support apic " \ + "emulation. Falling back to userspace emulation. Upgrade " \ + "your kernel/modules\n"); + } if (kvm_create(kvm_context, phys_ram_size, kvm_apic_level, (void**)&phys_ram_base) < 0) { diff --git a/user/kvmctl.c b/user/kvmctl.c index ea86426..fcabc1a 100644 --- a/user/kvmctl.c +++ b/user/kvmctl.c @@ -889,3 +889,17 @@ int kvm_set_signal_mask(kvm_context_t kvm, int vcpu, const sigset_t *sigset) free(sigmask); return r; } + +int kvm_check_extension(kvm_context_t kvm, uint64_t *ext) +{ + *ext = 0; + + int r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_APIC_MSG); + if (r < 0) + return r; + + if (r) + *ext |= KVM_EXTENSION_LAPIC; + + return 0; +} diff --git a/user/kvmctl.h b/user/kvmctl.h index 07cbc08..5371d71 100644 --- a/user/kvmctl.h +++ b/user/kvmctl.h @@ -384,4 +384,9 @@ int kvm_dirty_pages_log_enable_all(kvm_context_t kvm); */ int kvm_dirty_pages_log_reset(kvm_context_t kvm); +#define KVM_EXTENSION_LAPIC (1<<0) + +int kvm_check_extension(kvm_context_t kvm, uint64_t *ext); + + #endif ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel