From patchwork Thu Aug 27 22:16:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 32340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 22794B7B97 for ; Fri, 28 Aug 2009 12:16:40 +1000 (EST) Received: from localhost ([127.0.0.1]:56169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mgr13-0002Iy-8s for incoming@patchwork.ozlabs.org; Thu, 27 Aug 2009 22:16:37 -0400 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 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7S2G23f031096; Thu, 27 Aug 2009 22:16:02 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7S2G1ho010865; Thu, 27 Aug 2009 22:16:02 -0400 From: Glauber Costa To: qemu-devel@nongnu.org Date: Thu, 27 Aug 2009 18:16:01 -0400 Message-Id: <1251411361-579-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH] use host_tid for qemu system too X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);