From: Avi Kivity <[email protected]> This allows the user to examine the VM and inspect state and guest code.
Signed-off-by: Avi Kivity <[email protected]> diff --git a/libkvm-all.c b/libkvm-all.c index c45b058..dd56498 100644 --- a/libkvm-all.c +++ b/libkvm-all.c @@ -981,16 +981,12 @@ again: if (1) { switch (run->exit_reason) { case KVM_EXIT_UNKNOWN: - fprintf(stderr, "unhandled vm exit: 0x%x vcpu_id %d\n", - (unsigned)run->hw.hardware_exit_reason,vcpu->id); - kvm_show_regs(vcpu); - abort(); + r = kvm->callbacks->unhandled(kvm, vcpu, + run->hw.hardware_exit_reason); break; case KVM_EXIT_FAIL_ENTRY: - fprintf(stderr, "kvm_run: failed entry, reason %u\n", - (unsigned)run->fail_entry.hardware_entry_failure_reason & 0xffff); - kvm_show_regs(vcpu); - return -ENOEXEC; + r = kvm->callbacks->unhandled(kvm, vcpu, + run->fail_entry.hardware_entry_failure_reason); break; case KVM_EXIT_EXCEPTION: fprintf(stderr, "exception %d (%x)\n", diff --git a/libkvm-all.h b/libkvm-all.h index ac80b92..2b18c00 100644 --- a/libkvm-all.h +++ b/libkvm-all.h @@ -87,6 +87,8 @@ struct kvm_callbacks { int (*s390_handle_reset)(kvm_context_t context, kvm_vcpu_context_t vcpu, struct kvm_run *run); #endif + int (*unhandled)(kvm_context_t context, kvm_vcpu_context_t vcpu, + uint64_t hw_reason); }; /*! diff --git a/qemu-kvm.c b/qemu-kvm.c index 1d9d584..7acc0ef 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -207,7 +207,7 @@ int kvm_cpu_exec(CPUState *env) r = kvm_run(env->kvm_cpu_state.vcpu_ctx, env); if (r < 0) { printf("kvm_run returned %d\n", r); - exit(1); + vm_stop(0); } return 0; @@ -738,7 +738,14 @@ static int kvm_shutdown(void *opaque, void *data) qemu_system_reset_request(); return 1; } - + +static int handle_unhandled(kvm_context_t kvm, kvm_vcpu_context_t vcpu, + uint64_t reason) +{ + fprintf(stderr, "kvm: unhandled exit %"PRIx64"\n", reason); + return -EINVAL; +} + static struct kvm_callbacks qemu_kvm_ops = { #ifdef KVM_CAP_SET_GUEST_DEBUG .debug = kvm_debug, @@ -767,6 +774,7 @@ static struct kvm_callbacks qemu_kvm_ops = { .powerpc_dcr_read = handle_powerpc_dcr_read, .powerpc_dcr_write = handle_powerpc_dcr_write, #endif + .unhandled = handle_unhandled, }; int kvm_qemu_init() -- To unsubscribe from this list: send the line "unsubscribe kvm-commits" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
