From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH 6/11] QEMU/KVM: Introduce single vcpu pause/resume Date: Tue, 27 May 2008 00:10:12 +0200 Message-ID: <483B3544.1010802@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]:33699 "EHLO fmmailgate02.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755248AbYEZWKO (ORCPT ); Mon, 26 May 2008 18:10:14 -0400 In-Reply-To: <4839B14A.3010406@web.de> Sender: kvm-owner@vger.kernel.org List-ID: 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)