From: Marcelo Tosatti <[email protected]>

Use upstream hooks around select() to lock/unlock global mutex.

Signed-off-by: Marcelo Tosatti <[email protected]>

diff --git a/qemu-kvm.h b/qemu-kvm.h
index ec35f29..6a9be12 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -1117,13 +1117,13 @@ static inline void kvm_load_tsc(CPUState *env) {}
 void kvm_mutex_unlock(void);
 void kvm_mutex_lock(void);
 
-static inline void kvm_sleep_begin(void)
+static inline void qemu_mutex_unlock_iothread(void)
 {
     if (kvm_enabled())
        kvm_mutex_unlock();
 }
 
-static inline void kvm_sleep_end(void)
+static inline void qemu_mutex_lock_iothread(void)
 {
     if (kvm_enabled())
        kvm_mutex_lock();
diff --git a/vl.c b/vl.c
index 6ef7690..0ee2908 100644
--- a/vl.c
+++ b/vl.c
@@ -289,24 +289,6 @@ static QEMUTimer *nographic_timer;
 
 uint8_t qemu_uuid[16];
 
-static int qemu_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *xfds,
-                      struct timeval *tv)
-{
-    int ret;
-
-    /* KVM holds a mutex while QEMU code is running, we need hooks to
-       release the mutex whenever QEMU code sleeps. */
-
-    kvm_sleep_begin();
-
-    ret = select(max_fd, rfds, wfds, xfds, tv);
-
-    kvm_sleep_end();
-
-    return ret;
-}
-
-
 /***********************************************************/
 /* x86 ISA bus support */
 
@@ -3714,8 +3696,10 @@ void qemu_notify_event(void)
      }
 }
 
+#ifdef KVM_UPSTREAM
 #define qemu_mutex_lock_iothread() do { } while (0)
 #define qemu_mutex_unlock_iothread() do { } while (0)
+#endif
 
 void vm_stop(int reason)
 {
@@ -4126,7 +4110,9 @@ void main_loop_wait(int timeout)
 
     slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
 
-    ret = qemu_select(nfds + 1, &rfds, &wfds, &xfds, &tv);
+    qemu_mutex_unlock_iothread();
+    ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
+    qemu_mutex_lock_iothread();
     if (ret > 0) {
         IOHandlerRecord **pioh;
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to