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>
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;
}
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)
if (cpu->kvm->single_step)
kvm_cpu__enable_singlestep(cpu);
- for (;;) {
+ while (cpu->is_running) {
if (cpu->paused) {
kvm__notify_paused();
cpu->paused = 0;
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;
}