diff mbox

[02/20] qemu-kvm: Enable CONFIG_IOTHREAD

Message ID d44fb7fae4bc246820e0fa8166ae747bd5b30dbb.1306498737.git.jan.kiszka@siemens.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka May 27, 2011, 12:19 p.m. UTC
So far, qemu-kvm's build was incompatible with --enable-io-thread. But
to consolidate both iothread versions, we need to start enabling
upstream code under this config option.

This patch force-enables CONFIG_IOTHREAD but still picks the !IOTHREAD
variant of those functions that are used by the qemu-kvm code paths.
This temporary hack breaks TCG until we can safely enable all upstream
iothread functions.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch_init.c |    3 ++-
 configure   |    1 +
 cpus.c      |   37 +++++++++++++++++++++++--------------
 vl.c        |    5 ++++-
 4 files changed, 30 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/arch_init.c b/arch_init.c
index 484b39d..ac67c3d 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -711,7 +711,8 @@  int audio_available(void)
 
 int tcg_available(void)
 {
-    return 1;
+    /* temporarily broken */
+    return 0;
 }
 
 int kvm_available(void)
diff --git a/configure b/configure
index b3a8c68..4c738b1 100755
--- a/configure
+++ b/configure
@@ -1866,6 +1866,7 @@  EOF
   kvm_cflags="$kvm_cflags -idirafter $source_path/compat"
   if compile_prog "$kvm_cflags" "" ; then
     kvm=yes
+    io_thread=yes
     cat > $TMPC <<EOF
 #include <linux/kvm_para.h>
 int main(void) { return 0; }
diff --git a/cpus.c b/cpus.c
index d209535..48bac70 100644
--- a/cpus.c
+++ b/cpus.c
@@ -529,7 +529,7 @@  static void qemu_tcg_init_cpu_signals(void)
 }
 #endif /* _WIN32 */
 
-#ifndef CONFIG_IOTHREAD
+/*#ifndef CONFIG_IOTHREAD*/
 int qemu_init_main_loop(void)
 {
     int ret;
@@ -567,6 +567,7 @@  void qemu_init_vcpu(void *_env)
         qemu_tcg_init_cpu_signals();
     }
 }
+#ifndef CONFIG_IOTHREAD
 
 int qemu_cpu_is_self(void *env)
 {
@@ -578,6 +579,7 @@  void run_on_cpu(CPUState *env, void (*func)(void *data), void *data)
     func(data);
 }
 
+#endif /* !IOTHREAD */
 void resume_all_vcpus(void)
 {
 }
@@ -589,8 +591,8 @@  void pause_all_vcpus(void)
 void qemu_cpu_kick(void *env)
 {
 }
+#ifndef CONFIG_IOTHREAD
 
-#ifdef UNUSED_IMPL
 void qemu_cpu_kick_self(void)
 {
 #ifndef _WIN32
@@ -601,8 +603,8 @@  void qemu_cpu_kick_self(void)
     abort();
 #endif
 }
-#endif
 
+#endif /* !IOTHREAD */
 void qemu_notify_event(void)
 {
     CPUState *env = cpu_single_env;
@@ -616,12 +618,12 @@  void qemu_notify_event(void)
     }
     exit_request = 1;
 }
+#ifndef CONFIG_IOTHREAD
 
-#if defined(OBSOLETE_KVM_IMPL) || !defined(CONFIG_KVM)
 void qemu_mutex_lock_iothread(void) {}
 void qemu_mutex_unlock_iothread(void) {}
-#endif
 
+#endif /* !IOTHREAD */
 void cpu_stop_current(void)
 {
 }
@@ -630,25 +632,31 @@  void vm_stop(int reason)
 {
     do_vm_stop(reason);
 }
+#ifndef CONFIG_IOTHREAD
 
 #else /* CONFIG_IOTHREAD */
 
 QemuMutex qemu_global_mutex;
+#ifdef UNUSED_IOTHREAD_IMPL
 static QemuMutex qemu_fair_mutex;
 
 static QemuThread io_thread;
 
 static QemuThread *tcg_cpu_thread;
 static QemuCond *tcg_halt_cond;
+#endif
 
 static int qemu_system_ready;
 /* cpu creation */
+#ifdef UNUSED_IOTHREAD_IMPL
 static QemuCond qemu_cpu_cond;
 /* system init */
 static QemuCond qemu_system_cond;
 static QemuCond qemu_pause_cond;
+#endif
 static QemuCond qemu_work_cond;
 
+#ifdef UNUSED_IOTHREAD_IMPL
 int qemu_init_main_loop(void)
 {
     int ret;
@@ -684,6 +692,7 @@  void qemu_main_loop_start(void)
     qemu_system_ready = 1;
     qemu_cond_broadcast(&qemu_system_cond);
 }
+#endif /* UNUSED_IOTHREAD_IMPL */
 
 void run_on_cpu(CPUState *env, void (*func)(void *data), void *data)
 {
@@ -714,6 +723,7 @@  void run_on_cpu(CPUState *env, void (*func)(void *data), void *data)
     }
 }
 
+#ifdef UNUSED_IOTHREAD_IMPL
 static void flush_queued_work(CPUState *env)
 {
     struct qemu_work_item *wi;
@@ -849,8 +859,8 @@  static void *qemu_tcg_cpu_thread_fn(void *arg)
 
     return NULL;
 }
+#endif /* UNUSED_IOTHREAD_IMPL */
 
-#endif
 static void qemu_cpu_kick_thread(CPUState *env)
 {
 #ifndef _WIN32
@@ -869,8 +879,8 @@  static void qemu_cpu_kick_thread(CPUState *env)
     }
 #endif
 }
-#ifdef CONFIG_IOTHREAD
 
+#ifdef UNUSED_IOTHREAD_IMPL
 void qemu_cpu_kick(void *_env)
 {
     CPUState *env = _env;
@@ -881,8 +891,8 @@  void qemu_cpu_kick(void *_env)
         env->thread_kicked = true;
     }
 }
+#endif /* UNUSED_IOTHREAD_IMPL */
 
-#endif
 void qemu_cpu_kick_self(void)
 {
 #ifndef _WIN32
@@ -896,7 +906,6 @@  void qemu_cpu_kick_self(void)
     abort();
 #endif
 }
-#ifdef CONFIG_IOTHREAD
 
 int qemu_cpu_is_self(void *_env)
 {
@@ -905,6 +914,7 @@  int qemu_cpu_is_self(void *_env)
     return qemu_thread_is_self(env->thread);
 }
 
+#ifdef UNUSED_IOTHREAD_IMPL
 void qemu_mutex_lock_iothread(void)
 {
     if (kvm_enabled()) {
@@ -1043,6 +1053,7 @@  void vm_stop(int reason)
     }
     do_vm_stop(reason);
 }
+#endif /* UNUSED_IOTHREAD_IMPL */
 
 #endif
 
@@ -1195,11 +1206,9 @@  pthread_mutex_t qemu_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t qemu_vcpu_cond = PTHREAD_COND_INITIALIZER;
 pthread_cond_t qemu_system_cond = PTHREAD_COND_INITIALIZER;
 pthread_cond_t qemu_pause_cond = PTHREAD_COND_INITIALIZER;
-pthread_cond_t qemu_work_cond = PTHREAD_COND_INITIALIZER;
+pthread_cond_t qemu_kvm_work_cond = PTHREAD_COND_INITIALIZER;
 __thread CPUState *current_env;
 
-static int qemu_system_ready;
-
 static CPUState *kvm_debug_cpu_requested;
 
 unsigned long kvm_get_thread_id(void)
@@ -1241,7 +1250,7 @@  void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
 
     pthread_kill(env->thread->thread, SIG_IPI);
     while (!wi.done) {
-        kvm_cond_wait(&qemu_work_cond);
+        kvm_cond_wait(&qemu_kvm_work_cond);
     }
 }
 
@@ -1289,7 +1298,7 @@  static void flush_queued_work(CPUState *env)
         wi->done = true;
     }
     env->kvm_cpu_state.queued_work_last = NULL;
-    pthread_cond_broadcast(&qemu_work_cond);
+    pthread_cond_broadcast(&qemu_kvm_work_cond);
 }
 
 static void kvm_main_loop_wait(CPUState *env, int timeout)
diff --git a/vl.c b/vl.c
index 73e147f..2587aae 100644
--- a/vl.c
+++ b/vl.c
@@ -1910,7 +1910,8 @@  static int debugcon_parse(const char *devname)
 
 static int tcg_init(void)
 {
-    return 0;
+    fprintf(stderr, "Emulation temporarily broken\n");
+    return -1;
 }
 
 static struct {
@@ -2699,6 +2700,8 @@  int main(int argc, char **argv, char **envp)
                 }
                 break;
 	    case QEMU_OPTION_no_kvm:
+                fprintf(stderr, "Emulation temporarily broken\n");
+                exit(1);
                 olist = qemu_find_opts("machine");
                 qemu_opts_reset(olist);
                 qemu_opts_parse(olist, "accel=tcg", 0);