diff mbox

[QEMU-KVM,1/4] Move internal error handling into a function

Message ID 1257331796-29722-2-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity Nov. 4, 2009, 10:49 a.m. UTC
None
diff mbox

Patch

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 809fd65..4b22537 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -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)) {