From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH] kvm-qemu: Proper vm_stop on debug events Date: Fri, 23 May 2008 02:09:47 +0200 Message-ID: <48360B4B.10105@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit To: kvm-devel Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:60139 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754429AbYEWAJt (ORCPT ); Thu, 22 May 2008 20:09:49 -0400 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate03.web.de (Postfix) with ESMTP id 3BFBFDC18D44 for ; Fri, 23 May 2008 02:09:48 +0200 (CEST) Received: from [88.64.5.207] (helo=[192.168.1.198]) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1JzKqy-0003GK-00 for kvm@vger.kernel.org; Fri, 23 May 2008 02:09:48 +0200 Sender: kvm-owner@vger.kernel.org List-ID: 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) { + kvm_debug_stop_requested = 0; + vm_stop(EXCP_DEBUG); + } } 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; }