Improve kvm internal error reporting
cover Improve kvm internal error reporting
If a kvm internal error occurs, freeze the vm so we can inspect it. Also provide any extra data the kernel gives us.
Avi Kivity (4):
Move internal error handling into a function Freeze guest on internal error
Report extra data on internal errors
Import internal error data header updates from kvm.git
kvm/include/linux/kvm.h | 4 ++++ qemu-kvm.c | 30 ++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-)
PATCH 1/4 Move internal error handling into a function
Signed-off-by Avi Kivity <[email protected]>
--- qemu-kvm.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
qemu-kvm.c +13 -6
@@ -869,6 +869,18 @@ int kvm_is_ready_for_interrupt_injection(CPUState *env)return env->kvm_run->ready_for_interrupt_injection; } +static int kvm_handle_internal_error (kvm_context_t kvm, +CPUState *env, +struct kvm_run *run) +{ +fprintf (stderr,"KVM internal error. Suberror: %d\n" , + run->internal.suberror); +kvm_show_regs (env); +if (run->internal.suberror ==KVM_INTERNAL_ERROR_EMULATION ) +fprintf (stderr,"emulation failure, check dmesg for details\n" ); +abort (); +} +int kvm_run (CPUState *env) {int r;
@@ -967,12 +979,7 @@ int kvm_run(CPUState *env)break ;#endif case KVM_EXIT_INTERNAL_ERROR : -fprintf (stderr,"KVM internal error. Suberror: %d\n" , - run->internal.suberror); -kvm_show_regs (env); -if (run->internal.suberror ==KVM_INTERNAL_ERROR_EMULATION ) -fprintf (stderr,"emulation failure, check dmesg for details\n" ); -abort (); + r =kvm_handle_internal_error (kvm, env, run);break ;default :if (kvm_arch_run (env)) {
Signature · 1 line
1.6.5.2
PATCH 2/4 Freeze guest on internal error
In reply to Avi KivitySo we have a chance to debug it.
Signed-off-by Avi Kivity <[email protected]>
--- qemu-kvm.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
qemu-kvm.c +2 -1
@@ -878,7 +878,8 @@ static int kvm_handle_internal_error(kvm_context_t kvm,kvm_show_regs (env);if (run->internal.suberror ==KVM_INTERNAL_ERROR_EMULATION )fprintf (stderr,"emulation failure, check dmesg for details\n" ); -abort (); +vm_stop (0 ); +return 0 ; }int kvm_run (CPUState *env)
Signature · 1 line
1.6.5.2
PATCH 3/4 Report extra data on internal errors
In reply to Avi KivitySigned-off-by Avi Kivity <[email protected]>
--- qemu-kvm.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
qemu-kvm.c +10 -0
@@ -875,6 +875,16 @@ static int kvm_handle_internal_error(kvm_context_t kvm, {fprintf (stderr,"KVM internal error. Suberror: %d\n" , run->internal.suberror); +#ifdef KVM_CAP_INTERNAL_ERROR_DATA +if (kvm_check_extension (kvm_state,KVM_CAP_INTERNAL_ERROR_DATA )) { +int i; + +for (i =0 ; i < run->internal.ndata; ++i) { +fprintf (stderr,"extra data[%d]: %" PRIx64"\n" , + i, (uint64_t )run->internal.data[i]); + } + } +#endif kvm_show_regs (env);if (run->internal.suberror ==KVM_INTERNAL_ERROR_EMULATION )fprintf (stderr,"emulation failure, check dmesg for details\n" );
Signature · 1 line
1.6.5.2
PATCH 4/4 Import internal error data header updates from kvm.git
In reply to Avi KivitySigned-off-by Avi Kivity <[email protected]>
--- kvm/include/linux/kvm.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kvm/include/linux/kvm.h +4 -0
@@ -187,6 +187,9 @@ struct kvm_run { } dcr;struct {__u32 suberror; +/* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ +__u32 ndata; +__u64 data[16 ]; } internal;/* Fix the size of the union. */ char padding[256 ];
@@ -436,6 +439,7 @@ struct kvm_ioeventfd {#endif #define KVM_CAP_IOEVENTFD 36#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 +#define KVM_CAP_INTERNAL_ERROR_DATA 40#ifdef KVM_CAP_IRQ_ROUTING
Signature · 1 line
1.6.5.2