use host_tid for qemu system too
PATCH 1/1 use host_tid for qemu system too
kvm can have multiple threads, each representing one vcpu. Hijack the host_tid field to represent that.
Signed-off-by Glauber Costa <[email protected]>
--- exec.c | 1 + monitor.c | 1 + osdep.c | 14 ++++++++++++++ osdep.h | 2 ++ 4 files changed, 18 insertions(+), 0 deletions(-)
exec.c +1 -0
@@ -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);
monitor.c +1 -0
@@ -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" ); } }
osdep.c +14 -0
@@ -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 */
osdep.h +2 -0
@@ -78,6 +78,8 @@ void qemu_vfree(void *ptr);int qemu_create_pidfile (const char *filename); +int qemu_get_thread_id (void ); +#ifdef _WIN32int ffs (int i);
Signature · 1 line
1.6.2.2