[tip:tools/kvm] kvm tools: Make keyboard termination go through regular termination path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  ae622771002683a9caad0253e2f87001135c0123
Gitweb:     http://git.kernel.org/tip/ae622771002683a9caad0253e2f87001135c0123
Author:     Sasha Levin <levinsasha928@xxxxxxxxx>
AuthorDate: Thu, 11 Aug 2011 15:43:54 +0300
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Thu, 11 Aug 2011 17:01:15 +0300

kvm tools: Make keyboard termination go through regular termination path

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@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-run.c |    9 +++++----
 tools/kvm/kvm-cpu.c     |    8 ++++++--
 tools/kvm/term.c        |    6 +-----
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 1ab7122..4c0bb82 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -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;
 	}
diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
index 2f5d23c..fc0d6d4 100644
--- a/tools/kvm/kvm-cpu.c
+++ b/tools/kvm/kvm-cpu.c
@@ -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;
diff --git a/tools/kvm/term.c b/tools/kvm/term.c
index 2a3e1f0..fa4382d 100644
--- a/tools/kvm/term.c
+++ b/tools/kvm/term.c
@@ -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;
 	}
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux