aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2022-05-19 20:43:28 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-05-21 20:04:14 -0400
commit76b55935e332eac61717b3061b68e31c07c0a0b3 (patch)
tree7ed3e8c16fde710e8ca2aab671c879f49c328bdd
parentc1af390c936a7e07e7fe3c622247df947d4d4efa (diff)
downloadtrace-cmd-76b55935e332eac61717b3061b68e31c07c0a0b3.tar.gz
trace-cmd time-sync: Pass role to tracecmd_tsync_get_proto()
If the agent is a proxy server (host), then it should not pick the kvm protocol if it can not find the kvm offset and multiplier. If it does, it will fail the sync on the agent side which locks up the recorder side which will still run. This also shows how fragile the tsync code is but that is another project to have fixed. Link: https://lore.kernel.org/linux-trace-devel/20220519204328.534a1f30@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--lib/trace-cmd/include/private/trace-cmd-private.h2
-rw-r--r--lib/trace-cmd/trace-timesync.c5
-rw-r--r--tracecmd/trace-agent.c6
3 files changed, 7 insertions, 6 deletions
diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index 5606e132..d73a5191 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -530,7 +530,7 @@ int tracecmd_tsync_get_offsets(struct tracecmd_time_sync *tsync, int cpu,
int *count, long long **ts,
long long **offsets, long long **scalings, long long **frac);
const char *tracecmd_tsync_get_proto(const struct tracecmd_tsync_protos *protos,
- const char *clock);
+ const char *clock, enum tracecmd_time_sync_role role);
void tracecmd_tsync_free(struct tracecmd_time_sync *tsync);
int tracecmd_write_guest_time_shift(struct tracecmd_output *handle,
struct tracecmd_time_sync *tsync);
diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c
index e192a74a..8d4e977f 100644
--- a/lib/trace-cmd/trace-timesync.c
+++ b/lib/trace-cmd/trace-timesync.c
@@ -250,10 +250,9 @@ tsync_proto_select(const struct tracecmd_tsync_protos *protos,
*/
__hidden const char *
tracecmd_tsync_get_proto(const struct tracecmd_tsync_protos *protos,
- const char *clock)
+ const char *clock, enum tracecmd_time_sync_role role)
{
- return tsync_proto_select(protos, clock,
- TRACECMD_TIME_SYNC_ROLE_GUEST);
+ return tsync_proto_select(protos, clock, role);
}
/**
diff --git a/tracecmd/trace-agent.c b/tracecmd/trace-agent.c
index ea41ad54..23483295 100644
--- a/tracecmd/trace-agent.c
+++ b/tracecmd/trace-agent.c
@@ -157,6 +157,7 @@ static void agent_handle(int sd, int nr_cpus, int page_size,
unsigned long long peer_trace_id;
unsigned long long trace_id;
unsigned long flags = rcid >= 0 ? TRACECMD_MSG_FL_PROXY : 0;
+ enum tracecmd_time_sync_role tsync_role = TRACECMD_TIME_SYNC_ROLE_GUEST;
unsigned int remote_id;
unsigned int local_id;
unsigned int tsync_port = 0;
@@ -180,6 +181,7 @@ static void agent_handle(int sd, int nr_cpus, int page_size,
die("Failed to allocate message handle");
if (rcid >= 0) {
+ tsync_role = TRACECMD_TIME_SYNC_ROLE_HOST;
ret = tracecmd_msg_recv_trace_proxy(msg_handle, &argc, &argv,
&use_fifos, &peer_trace_id,
&tsync_protos,
@@ -197,8 +199,8 @@ static void agent_handle(int sd, int nr_cpus, int page_size,
if (ret < 0)
die("Failed to receive trace request");
- tsync_proto = tracecmd_tsync_get_proto(tsync_protos,
- get_clock(argc, argv));
+ tsync_proto = tracecmd_tsync_get_proto(tsync_protos, get_clock(argc, argv),
+ tsync_role);
if (use_fifos && open_agent_fifos(nr_cpus, fds))
use_fifos = false;