]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tools/kvm: Exit gracefully upon KVM_EXIT_SHUTDOWN
authorPekka Enberg <penberg@kernel.org>
Tue, 22 Mar 2011 19:32:46 +0000 (21:32 +0200)
committerPekka Enberg <penberg@kernel.org>
Tue, 22 Mar 2011 19:32:46 +0000 (21:32 +0200)
This patch changes the userspace hypervisor to exit gracefully upon
KVM_EXIT_SHUTDOWN which is triggered when guest userspace is shut down.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/main.c

index cac8d307858dc2719a48a8a7036ea7ead94ccb2b..d70b4466bb6f1180d57e7ea6f223c31d0665624a 100644 (file)
@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
                                        kvm->kvm_run->io.count);
 
                        if (!ret)
-                               goto exit_kvm;
+                               goto panic_kvm;
                        break;
                }
                case KVM_EXIT_MMIO: {
@@ -203,30 +203,34 @@ int main(int argc, char *argv[])
                                        kvm->kvm_run->mmio.is_write);
 
                        if (!ret)
-                               goto exit_kvm;
+                               goto panic_kvm;
                        break;
                }
                case KVM_EXIT_INTR: {
                        serial8250__interrupt(kvm);
                        break;
                }
-               default:
+               case KVM_EXIT_SHUTDOWN:
                        goto exit_kvm;
+               default:
+                       goto panic_kvm;
                }
        }
-
 exit_kvm:
+       kvm__delete(kvm);
 
+       return 0;
+
+panic_kvm:
        fprintf(stderr, "KVM exit reason: %" PRIu32 " (\"%s\")\n",
                kvm->kvm_run->exit_reason, kvm_exit_reasons[kvm->kvm_run->exit_reason]);
        if (kvm->kvm_run->exit_reason == KVM_EXIT_UNKNOWN)
                fprintf(stderr, "KVM exit code: 0x%" PRIu64 "\n",
                        kvm->kvm_run->hw.hardware_exit_reason);
-
        kvm__show_registers(kvm);
        kvm__show_code(kvm);
        kvm__show_page_tables(kvm);
        kvm__delete(kvm);
 
-       return 0;
+       return 1;
 }