Patchwork use host_tid for qemu system too

login
register
mail settings
Submitter Glauber Costa
Date Aug. 27, 2009, 10:16 p.m.
Message ID <1251411361-579-1-git-send-email-glommer@redhat.com>
Download mbox | patch
Permalink /patch/32340/
State Superseded
Headers show

Comments

Glauber Costa - Aug. 27, 2009, 10:16 p.m.
kvm can have multiple threads, each representing one vcpu. Hijack
the host_tid field to represent that.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 exec.c    |    1 +
 monitor.c |    1 +
 osdep.c   |   14 ++++++++++++++
 osdep.h   |    2 ++
 4 files changed, 18 insertions(+), 0 deletions(-)

Patch

diff --git a/exec.c b/exec.c
index 131e2af..4461651 100644
--- a/exec.c
+++ b/exec.c
@@ -573,6 +573,7 @@  void cpu_exec_init(CPUState *env)
         cpu_index++;
     }
     env->cpu_index = cpu_index;
+    env->host_tid = qemu_get_thread_id();
     env->numa_node = 0;
     TAILQ_INIT(&env->breakpoints);
     TAILQ_INIT(&env->watchpoints);
diff --git a/monitor.c b/monitor.c
index 967171b..c0afefb 100644
--- a/monitor.c
+++ b/monitor.c
@@ -375,6 +375,7 @@  static void do_info_cpus(Monitor *mon)
 #endif
         if (env->halted)
             monitor_printf(mon, " (halted)");
+        monitor_printf(mon," thread_id=%d", env->host_tid);
         monitor_printf(mon, "\n");
     }
 }
diff --git a/osdep.c b/osdep.c
index 90cc95f..ad90834 100644
--- a/osdep.c
+++ b/osdep.c
@@ -44,6 +44,8 @@ 
 #include <malloc.h>
 #endif
 
+#include <sys/syscall.h>
+
 #include "qemu-common.h"
 #include "sysemu.h"
 #include "qemu_socket.h"
@@ -161,6 +163,18 @@  int qemu_create_pidfile(const char *filename)
     return 0;
 }
 
+int qemu_get_thread_id(void)
+{
+#ifdef __WIN32
+    return GetCurrentProcessId();
+#elif defined(__linux__) 
+    return syscall(SYS_gettid);
+#else
+    return getpid();
+#endif
+
+}
+
 #ifdef _WIN32
 
 /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
diff --git a/osdep.h b/osdep.h
index 2517b1a..85a499b 100644
--- a/osdep.h
+++ b/osdep.h
@@ -78,6 +78,8 @@  void qemu_vfree(void *ptr);
 
 int qemu_create_pidfile(const char *filename);
 
+int qemu_get_thread_id(void);
+
 #ifdef _WIN32
 int ffs(int i);