diff options
author | Namhyung Kim <namhyung@gmail.com> | 2017-11-08 00:31:36 +0900 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-12-18 14:37:36 +0000 |
commit | c9add6219514b20223f024584f0464b8842b1ec0 (patch) | |
tree | 8a80fb8d377602e7180d4b732a5c7da06d9c8592 /trace | |
parent | babfff8e11589a2d1ab9ca777ebb16495f708616 (diff) | |
download | qemu-c9add6219514b20223f024584f0464b8842b1ec0.zip qemu-c9add6219514b20223f024584f0464b8842b1ec0.tar.gz qemu-c9add6219514b20223f024584f0464b8842b1ec0.tar.bz2 |
trace: Try using tracefs first
Recent Linux kernel provides separate tracefs which doesn't need to be
mounted on the debugfs. Although most systems mount it at the
traditional place on the debugfs, it'd be safer to check tracefs first.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'trace')
-rw-r--r-- | trace/ftrace.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/trace/ftrace.c b/trace/ftrace.c index 213cb22..61692a8 100644 --- a/trace/ftrace.c +++ b/trace/ftrace.c @@ -42,12 +42,18 @@ bool ftrace_init(void) { char mount_point[PATH_MAX]; char path[PATH_MAX]; - int debugfs_found; + int tracefs_found; int trace_fd = -1; + const char *subdir = ""; - debugfs_found = find_mount(mount_point, "debugfs"); - if (debugfs_found) { - snprintf(path, PATH_MAX, "%s/tracing/tracing_on", mount_point); + tracefs_found = find_mount(mount_point, "tracefs"); + if (!tracefs_found) { + tracefs_found = find_mount(mount_point, "debugfs"); + subdir = "/tracing"; + } + + if (tracefs_found) { + snprintf(path, PATH_MAX, "%s%s/tracing_on", mount_point, subdir); trace_fd = open(path, O_WRONLY); if (trace_fd < 0) { if (errno == EACCES) { @@ -66,14 +72,14 @@ bool ftrace_init(void) } close(trace_fd); } - snprintf(path, PATH_MAX, "%s/tracing/trace_marker", mount_point); + snprintf(path, PATH_MAX, "%s%s/trace_marker", mount_point, subdir); trace_marker_fd = open(path, O_WRONLY); if (trace_marker_fd < 0) { perror("Could not open ftrace 'trace_marker' file"); return false; } } else { - fprintf(stderr, "debugfs is not mounted\n"); + fprintf(stderr, "tracefs is not mounted\n"); return false; } |