Received: from eggs.gnu.org ([208.118.235.92]:45158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEyua-0008Gx-BR for qemu-devel@nongnu.org; Fri, 21 Sep 2012 04:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEyuW-0004wc-8k for qemu-devel@nongnu.org; Fri, 21 Sep 2012 04:48:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEyuW-0004wQ-0P for qemu-devel@nongnu.org; Fri, 21 Sep 2012 04:48:32 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8L8mVR5009349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Sep 2012 04:48:31 -0400 From: Juan Quintela Date: Fri, 21 Sep 2012 10:47:35 +0200 Message-Id: <1348217255-22441-42-git-send-email-quintela@redhat.com> In-Reply-To: <1348217255-22441-1-git-send-email-quintela@redhat.com> References: <1348217255-22441-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 41/41] cpus: create qemu_cpu_is_vcpu() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Old code used !io_thread to know if a thread was an vcpu or not. That fails when we introduce the iothread. Signed-off-by: Juan Quintela --- cpus.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index e476a3c..1b7061a 100644 --- a/cpus.c +++ b/cpus.c @@ -902,6 +902,11 @@ int qemu_cpu_is_self(void *_env) return qemu_thread_is_self(cpu->thread); } +static bool qemu_cpu_is_vcpu(void) +{ + return cpu_single_env && qemu_cpu_is_self(&cpu_single_env); +} + void qemu_mutex_lock_iothread(void) { if (!tcg_enabled()) { @@ -947,7 +952,7 @@ void pause_all_vcpus(void) penv = penv->next_cpu; } - if (!qemu_thread_is_self(&io_thread)) { + if (qemu_cpu_is_vcpu()) { cpu_stop_current(); if (!kvm_enabled()) { while (penv) { @@ -1064,7 +1069,7 @@ void cpu_stop_current(void) void vm_stop(RunState state) { - if (!qemu_thread_is_self(&io_thread)) { + if (qemu_cpu_is_vcpu()) { qemu_system_vmstop_request(state); /* * FIXME: should not return to device code in case -- 1.7.11.4