From patchwork Fri Feb 4 15:47:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [18/23] Introduce VCPU self-signaling service From: Marcelo Tosatti X-Patchwork-Id: 81899 Message-Id: <47ec6d678b1a5da61f3413896808b5228edd1bc5.1296834446.git.mtosatti@redhat.com> To: Anthony Liguori Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Fri, 4 Feb 2011 13:47:21 -0200 From: Jan Kiszka Introduce qemu_cpu_kick_self to send SIG_IPI to the calling VCPU context. First user will be kvm. Signed-off-by: Jan Kiszka Signed-off-by: Marcelo Tosatti --- cpus.c | 21 +++++++++++++++++++++ qemu-common.h | 1 + 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/cpus.c b/cpus.c index c4c5914..9c50a34 100644 --- a/cpus.c +++ b/cpus.c @@ -537,6 +537,17 @@ void qemu_cpu_kick(void *env) return; } +void qemu_cpu_kick_self(void) +{ +#ifndef _WIN32 + assert(cpu_single_env); + + raise(SIG_IPI); +#else + abort(); +#endif +} + void qemu_notify_event(void) { CPUState *env = cpu_single_env; @@ -835,6 +846,16 @@ void qemu_cpu_kick(void *_env) } } +void qemu_cpu_kick_self(void) +{ + assert(cpu_single_env); + + if (!cpu_single_env->thread_kicked) { + qemu_thread_signal(cpu_single_env->thread, SIG_IPI); + cpu_single_env->thread_kicked = true; + } +} + int qemu_cpu_self(void *_env) { CPUState *env = _env; diff --git a/qemu-common.h b/qemu-common.h index c7ff280..a4d9c21 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -288,6 +288,7 @@ void qemu_notify_event(void); /* Unblock cpu */ void qemu_cpu_kick(void *env); +void qemu_cpu_kick_self(void); int qemu_cpu_self(void *env); /* work queue */