diff mbox

[RESEND] Print a user-friendly message on failed vmentry

Message ID 1275334818-6064-1-git-send-email-m.gamal005@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mohammed Gamal May 31, 2010, 7:40 p.m. UTC
None
diff mbox

Patch

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 9534b31..b8a9278 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -106,6 +106,31 @@  static int handle_unhandled(uint64_t reason)
     return -EINVAL;
 }
 
+#define VMX_INVALID_GUEST_STATE 0x80000021
+
+static int handle_failed_vmentry(uint64_t reason)
+{
+    fprintf(stderr, "kvm: vm entry failed with error 0x%" PRIx64 "\n\n", reason);
+
+    /* Perhaps we will need to check if this machine is intel since exit reason 0x21 
+       has a different interpretation on SVM */
+    if (reason == VMX_INVALID_GUEST_STATE) {
+        fprintf(stderr, "If you're runnning a guest on an Intel machine without\n");
+        fprintf(stderr, "unrestricted mode support, the failure can be most likely\n");
+        fprintf(stderr, "due to the guest entering an invalid state for Intel VT.\n");
+        fprintf(stderr, "For example, the guest maybe running in big real mode\n");
+        fprintf(stderr, "which is not supported on less recent Intel processors.\n\n");
+        fprintf(stderr, "You may want to try enabling KVM real mode emulation. To\n");
+        fprintf(stderr, "enable it, you can run the following commands as root:\n");
+        fprintf(stderr, "# rmmod kvm_intel\n");
+        fprintf(stderr, "# rmmod kvm\n");
+        fprintf(stderr, "# modprobe kvm_intel emulate_invalid_guest_state=1\n\n");
+        fprintf(stderr, "WARNING: Real mode emulation is still work-in-progress\n");
+        fprintf(stderr, "and thus it is not always guaranteed to work.\n\n");
+    }
+
+    return -EINVAL;
+}
 
 static inline void set_gsi(kvm_context_t kvm, unsigned int gsi)
 {
@@ -586,7 +611,7 @@  int kvm_run(CPUState *env)
             r = handle_unhandled(run->hw.hardware_exit_reason);
             break;
         case KVM_EXIT_FAIL_ENTRY:
-            r = handle_unhandled(run->fail_entry.hardware_entry_failure_reason);
+            r = handle_failed_vmentry(run->fail_entry.hardware_entry_failure_reason);
             break;
         case KVM_EXIT_EXCEPTION:
             fprintf(stderr, "exception %d (%x)\n", run->ex.exception,