From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] kvm-qemu: Proper vm_stop on debug events Date: Thu, 22 May 2008 19:35:32 -0500 Message-ID: <48361154.4080805@codemonkey.ws> References: <48360B4B.10105@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm-devel To: Jan Kiszka Return-path: Received: from yw-out-2324.google.com ([74.125.46.31]:48820 "EHLO yw-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758090AbYEWAfp (ORCPT ); Thu, 22 May 2008 20:35:45 -0400 Received: by yw-out-2324.google.com with SMTP id 9so229161ywe.1 for ; Thu, 22 May 2008 17:35:40 -0700 (PDT) In-Reply-To: <48360B4B.10105@web.de> Sender: kvm-owner@vger.kernel.org List-ID: Jan Kiszka wrote: > 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; > + > Why use this instead of just keying off of exception_index == EXCP_DEBUG? > 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; > This isn't quite right. In the very least, you need to set stopping = 0 and signal on the qemu_pause_cond. Thinking it through more though, a breakpoint should stop all VCPUs, right? vm_stop(EXCP_DEBUG) will actually do this. It invokes the vm_state_notify callbacks and the io-thread registers one. I think you should probably just issue vm_stop(EXCP_DEBUG) from kvm_debug. Regards, Anthony Liguori > return 1; > } > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >