From efb53d90dbca8a42e8679dd470120d454115bdeb Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Tue, 27 May 2008 00:09:48 +0200 Subject: [PATCH] Proper vm_stop on debug events When a vcpu exits after hitting a debug exception, we have to invoke vm_stop(EXCP_DEBUG). But this has to take place over the io-thread. This patch introduces kvm_debug_stop_requested to signal this event, and it takes care that the interrupted vcpu itself goes immediately into stop state. Signed-off-by: Jan Kiszka Signed-off-by: Avi Kivity --- qemu-kvm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index cac4d08175..a9f3e0ab08 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -71,6 +71,8 @@ pthread_t io_thread; static int io_thread_fd = -1; static int io_thread_sigfd = -1; +static int kvm_debug_stop_requested; + static inline unsigned long kvm_get_thread_id(void) { return syscall(SYS_gettid); @@ -581,6 +583,10 @@ int kvm_main_loop(void) qemu_system_powerdown(); else if (qemu_reset_requested()) qemu_kvm_system_reset(); + else if (kvm_debug_stop_requested) { + vm_stop(EXCP_DEBUG); + kvm_debug_stop_requested = 0; + } } pause_all_threads(); @@ -593,7 +599,8 @@ static int kvm_debug(void *opaque, int vcpu) { CPUState *env = cpu_single_env; - env->exception_index = EXCP_DEBUG; + kvm_debug_stop_requested = 1; + vcpu_info[vcpu].stopped = 1; return 1; } -- 2.11.4.GIT