From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH 3/11] QEMU/KVM: Proper vm_stop on debug events Date: Tue, 27 May 2008 00:09:48 +0200 Message-ID: <483B352C.5010102@web.de> References: <4839B14A.3010406@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Hollis Blanchard , Jerone Young , Joerg Roedel To: kvm-devel Return-path: Received: from fmmailgate02.web.de ([217.72.192.227]:33556 "EHLO fmmailgate02.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755236AbYEZWJu (ORCPT ); Mon, 26 May 2008 18:09:50 -0400 In-Reply-To: <4839B14A.3010406@web.de> Sender: kvm-owner@vger.kernel.org List-ID: [ Changes to last revision: Reordered kvm_debug_stop_requested and vm_stop to avoid race. ] 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 --- qemu/qemu-kvm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) Index: b/qemu/qemu-kvm.c =================================================================== --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -58,6 +58,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); @@ -517,6 +519,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(); @@ -529,7 +535,8 @@ static int kvm_debug(void *opaque, int v { CPUState *env = cpu_single_env; - env->exception_index = EXCP_DEBUG; + kvm_debug_stop_requested = 1; + vcpu_info[vcpu].stopped = 1; return 1; }