Patchwork [41/41] cpus: create qemu_in_vcpu_thread()

login
register
mail settings
Submitter Juan Quintela
Date Oct. 2, 2012, 11:33 a.m.
Message ID <1349177616-5341-42-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/188477/
State New
Headers show

Comments

Juan Quintela - Oct. 2, 2012, 11:33 a.m.
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 <quintela@redhat.com>
---
 cpus.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Patch

diff --git a/cpus.c b/cpus.c
index 4b726ef..76c4255 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_in_vcpu_thread(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_in_vcpu_thread()) {
         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_in_vcpu_thread()) {
         qemu_system_vmstop_request(state);
         /*
          * FIXME: should not return to device code in case