@@ -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);
@@ -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");
}
}
@@ -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 */
@@ -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);
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(-)