From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 2/3] qemu-kvm: Introduce single vcpu pause/resume Date: Fri, 23 May 2008 17:49:59 +0200 Message-ID: <4836E7A7.7070804@web.de> References: <483622F6.8020805@web.de> <483624E8.8040601@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 fmmailgate01.web.de ([217.72.192.221]:43625 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756736AbYEWPvt (ORCPT ); Fri, 23 May 2008 11:51:49 -0400 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate01.web.de (Postfix) with ESMTP id 1F562E07DCED for ; Fri, 23 May 2008 17:50:00 +0200 (CEST) Received: from [88.64.30.47] (helo=[192.168.1.198]) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1JzZWp-0001uZ-00 for kvm@vger.kernel.org; Fri, 23 May 2008 17:50:00 +0200 In-Reply-To: <483624E8.8040601@web.de> Sender: kvm-owner@vger.kernel.org List-ID: Jan Kiszka wrote: > Small helpers that allow to pause and resume only a single vcpu thread. Updated version with corrected assertions: ------------ Small helpers that allow to pause and resume only a single vcpu thread. Signed-off-by: Jan Kiszka --- qemu/qemu-kvm.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) Index: b/qemu/qemu-kvm.c =================================================================== --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -207,6 +207,17 @@ static int all_threads_paused(void) return 1; } +static void pause_vcpu_thread(int index) +{ + assert(!cpu_single_env || cpu_single_env->cpu_index != index); + + vcpu_info[index].stop = 1; + pthread_kill(vcpu_info[index].thread, SIG_IPI); + + while (!vcpu_info[index].stopped) + qemu_cond_wait(&qemu_pause_cond); +} + static void pause_all_threads(void) { int i; @@ -221,17 +232,21 @@ static void pause_all_threads(void) qemu_cond_wait(&qemu_pause_cond); } +static void resume_vcpu_thread(int index) +{ + assert(!cpu_single_env || cpu_single_env->cpu_index != index); + + vcpu_info[index].stop = 0; + vcpu_info[index].stopped = 0; + pthread_kill(vcpu_info[index].thread, SIG_IPI); +} + static void resume_all_threads(void) { int i; - assert(!cpu_single_env); - - for (i = 0; i < smp_cpus; ++i) { - vcpu_info[i].stop = 0; - vcpu_info[i].stopped = 0; - pthread_kill(vcpu_info[i].thread, SIG_IPI); - } + for (i = 0; i < smp_cpus; ++i) + resume_vcpu_thread(i); } static void kvm_vm_state_change_handler(void *context, int running)