summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-02-26 18:38:39 +0000
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-03-07 15:34:17 +0000
commit0b5538c300a56c3cfb33022840fe0b4968147e7a (patch)
tree9b60b859d24881e2d032828c3788b2171f3ceaa6 /vl.c
parent07bf23a77131668ef8db37e08d508b117655ce86 (diff)
downloadqemu-0b5538c300a56c3cfb33022840fe0b4968147e7a.tar.gz
simpletrace: Thread-safe tracing
Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe. There is no check to prevent them being enabled so people sometimes learn this the hard way. This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers. A writeout thread empties the trace buffer when threshold fill levels are reached. Should the writeout thread be unable to keep up with trace generation, records will simply be dropped. Each time events are dropped a special record is written to the trace file indicating how many events were dropped. The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count). Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/vl.c b/vl.c
index b436952d6c..5e007a764c 100644
--- a/vl.c
+++ b/vl.c
@@ -47,9 +47,6 @@
#include <dirent.h>
#include <netdb.h>
#include <sys/select.h>
-#ifdef CONFIG_SIMPLE_TRACE
-#include "trace.h"
-#endif
#ifdef CONFIG_BSD
#include <sys/stat.h>
@@ -159,6 +156,7 @@ int main(int argc, char **argv)
#include "slirp/libslirp.h"
#include "trace.h"
+#include "simpletrace.h"
#include "qemu-queue.h"
#include "cpus.h"
#include "arch_init.h"
@@ -1941,10 +1939,8 @@ int main(int argc, char **argv, char **envp)
const char *incoming = NULL;
int show_vnc_port = 0;
int defconfig = 1;
-
-#ifdef CONFIG_SIMPLE_TRACE
const char *trace_file = NULL;
-#endif
+
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
@@ -2770,6 +2766,8 @@ int main(int argc, char **argv, char **envp)
}
loc_set_none();
+ st_init(trace_file);
+
/* If no data_dir is specified then try to find it relative to the
executable path. */
if (!data_dir) {
@@ -2780,12 +2778,6 @@ int main(int argc, char **argv, char **envp)
data_dir = CONFIG_QEMU_DATADIR;
}
-#ifdef CONFIG_SIMPLE_TRACE
- /*
- * Set the trace file name, if specified.
- */
- st_set_trace_file(trace_file);
-#endif
/*
* Default to max_cpus = smp_cpus, in case the user doesn't
* specify a max_cpus value.