From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mgr0a-0002Ig-Ua for qemu-devel@nongnu.org; Thu, 27 Aug 2009 22:16:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mgr0W-0002I9-Ds for qemu-devel@nongnu.org; Thu, 27 Aug 2009 22:16:08 -0400 Received: from [199.232.76.173] (port=34021 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mgr0W-0002I6-87 for qemu-devel@nongnu.org; Thu, 27 Aug 2009 22:16:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40267) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mgr0V-0004R5-S5 for qemu-devel@nongnu.org; Thu, 27 Aug 2009 22:16:04 -0400 From: Glauber Costa Date: Thu, 27 Aug 2009 18:16:01 -0400 Message-Id: <1251411361-579-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH] use host_tid for qemu system too List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com kvm can have multiple threads, each representing one vcpu. Hijack the host_tid field to represent that. Signed-off-by: Glauber Costa --- exec.c | 1 + monitor.c | 1 + osdep.c | 14 ++++++++++++++ osdep.h | 2 ++ 4 files changed, 18 insertions(+), 0 deletions(-) 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 #endif +#include + #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); -- 1.6.2.2