]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Make keyboard termination go through regular termination path
authorSasha Levin <levinsasha928@gmail.com>
Thu, 11 Aug 2011 12:43:54 +0000 (15:43 +0300)
committerPekka Enberg <penberg@kernel.org>
Thu, 11 Aug 2011 14:01:15 +0000 (17:01 +0300)
Instead of exiting directly when a user enters 'ctrl x + a', go through
the regular termination path by stopping all VCPUs and letting the
main thread handle it.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-run.c
tools/kvm/kvm-cpu.c
tools/kvm/term.c

index 1ab7122c067537182a5a28282477e6ce6632d4f0..4c0bb82246bad259365dc1d46a807e4c9e230b0f 100644 (file)
@@ -722,10 +722,11 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
                exit_code = 1;
 
        for (i = 1; i < nrcpus; i++) {
-               pthread_kill(kvm_cpus[i]->thread, SIGKVMEXIT);
-               if (pthread_join(kvm_cpus[i]->thread, &ret) != 0)
-                       die("pthread_join");
-
+               if (kvm_cpus[i]->is_running) {
+                       pthread_kill(kvm_cpus[i]->thread, SIGKVMEXIT);
+                       if (pthread_join(kvm_cpus[i]->thread, &ret) != 0)
+                               die("pthread_join");
+               }
                if (ret != NULL)
                        exit_code = 1;
        }
index 2f5d23c70ab6cdd4e70ea1cf3345d2c209c35be4..fc0d6d44d9af84a620b91de0729bf9bd81ba96f0 100644 (file)
@@ -421,7 +421,11 @@ static void kvm_cpu__handle_coalesced_mmio(struct kvm_cpu *cpu)
 
 void kvm_cpu__reboot(void)
 {
-       pthread_kill(kvm_cpus[0]->thread, SIGKVMEXIT);
+       int i;
+
+       for (i = 0; i < KVM_NR_CPUS; i++)
+               if (kvm_cpus[i])
+                       pthread_kill(kvm_cpus[i]->thread, SIGKVMEXIT);
 }
 
 int kvm_cpu__start(struct kvm_cpu *cpu)
@@ -442,7 +446,7 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
        if (cpu->kvm->single_step)
                kvm_cpu__enable_singlestep(cpu);
 
-       for (;;) {
+       while (cpu->is_running) {
                if (cpu->paused) {
                        kvm__notify_paused();
                        cpu->paused = 0;
index 2a3e1f0b12574d1f4a52b05f8c6f91dc59fdd332..fa4382dde7642b9f14213555b5d37a5cccb8d92c 100644 (file)
@@ -34,12 +34,8 @@ int term_getc(int who)
 
        if (term_got_escape) {
                term_got_escape = false;
-               if (c == 'x') {
+               if (c == 'x')
                        kvm_cpu__reboot();
-                       kvm__delete(kvm);
-                       printf("\n  # KVM session terminated.\n");
-                       exit(1);
-               }
                if (c == term_escape_char)
                        return c;
        }