}
break;
case 'T':
- if (!trace_init_backends(optarg)) {
+ if (!trace_init_backends()) {
exit(1); /* error message will have been printed */
}
break;
loc_pop(&loc);
}
-bool trace_init_backends(const char *file)
+void trace_init_file(const char *file)
{
#ifdef CONFIG_TRACE_SIMPLE
- if (!st_init(file)) {
- fprintf(stderr, "failed to initialize simple tracing backend.\n");
- return false;
- }
+ st_set_trace_file(file);
#else
if (file) {
fprintf(stderr, "error: -trace file=...: "
"option not supported by the selected tracing backends\n");
+ exit(1);
+ }
+#endif
+}
+
+bool trace_init_backends(void)
+{
+#ifdef CONFIG_TRACE_SIMPLE
+ if (!st_init()) {
+ fprintf(stderr, "failed to initialize simple tracing backend.\n");
return false;
}
#endif
*
* Returns: Whether the backends could be successfully initialized.
*/
-bool trace_init_backends(const char *file);
+bool trace_init_backends(void);
/**
* trace_init_events:
*/
void trace_init_events(const char *file);
+/**
+ * trace_init_file:
+ * @file: Name of trace output file; may be NULL.
+ * Corresponds to commandline option "-trace file=...".
+ *
+ * Record the name of the output file for the tracing backend.
+ * Exits if no selected backend does not support specifying the
+ * output file, and a non-NULL file was passed.
+ */
+void trace_init_file(const char *file);
+
#include "trace/control-internal.h"
* @file The trace file name or NULL for the default name-<pid> set at
* config time
*/
-bool st_set_trace_file(const char *file)
+void st_set_trace_file(const char *file)
{
st_set_trace_file_enabled(false);
}
st_set_trace_file_enabled(true);
- return true;
}
void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
return thread;
}
-bool st_init(const char *file)
+bool st_init(void)
{
GThread *thread;
}
atexit(st_flush_trace_buffer);
- st_set_trace_file(file);
return true;
}
void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf);
void st_set_trace_file_enabled(bool enable);
-bool st_set_trace_file(const char *file);
-bool st_init(const char *file);
+void st_set_trace_file(const char *file);
+bool st_init(void);
void st_flush_trace_buffer(void);
typedef struct {
bool userconfig = true;
const char *log_mask = NULL;
const char *log_file = NULL;
- const char *trace_file = NULL;
+ char *trace_file = NULL;
ram_addr_t maxram_size;
uint64_t ram_slots = 0;
FILE *vmstate_dump_file = NULL;
exit(1);
}
trace_init_events(qemu_opt_get(opts, "events"));
- trace_file = qemu_opt_get(opts, "file");
+ if (trace_file) {
+ g_free(trace_file);
+ }
+ trace_file = g_strdup(qemu_opt_get(opts, "file"));
qemu_opts_del(opts);
break;
}
exit(0);
}
+ trace_init_file(trace_file);
+
/* Open the logfile at this point and set the log mask if necessary.
*/
if (log_file) {
}
if (!is_daemonized()) {
- if (!trace_init_backends(trace_file)) {
+ if (!trace_init_backends()) {
exit(1);
}
}
os_setup_post();
if (is_daemonized()) {
- if (!trace_init_backends(trace_file)) {
+ if (!trace_init_backends()) {
exit(1);
}
}