diff mbox series

[v25,07/16] trace-cmd: Add host / guest role in timestamp synchronization context

Message ID 20201029111816.247241-8-tz.stoyanov@gmail.com (mailing list archive)
State Superseded
Headers show
Series Timestamp synchronization of host - guest tracing session | expand

Commit Message

Tzvetomir Stoyanov (VMware) Oct. 29, 2020, 11:18 a.m. UTC
Added new parameter in timestamp synchronization context, holding the
current role in the timestamp synchronization process - host or guest.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/include/trace-tsync-local.h | 1 +
 lib/trace-cmd/trace-timesync.c            | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Steven Rostedt Dec. 2, 2020, 11:07 p.m. UTC | #1
On Thu, 29 Oct 2020 13:18:07 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> @@ -298,8 +298,11 @@ static int clock_context_init(struct tracecmd_time_sync *tsync, bool server)
>  	clock = calloc(1, sizeof(struct clock_sync_context));
>  	if (!clock)
>  		return -1;
> -
> -	clock->is_server = server;
> +	clock->is_guest = guest;
> +	if (clock->is_guest)
> +		clock->is_server = true;
> +	else
> +		clock->is_server = false;

Wait? You want them to equal?

Then you should have:

	clock->is_server = guest;

If you want them opposite:

	clock->is_server = !guest;

-- Steve

>  	if (get_vsocket_params(tsync->msg_handle->fd, &clock->local_cid,
>  			       &clock->local_port, &clock->remote_cid,
>  			       &clock->remote_port))
diff mbox series

Patch

diff --git a/lib/trace-cmd/include/trace-tsync-local.h b/lib/trace-cmd/include/trace-tsync-local.h
index 33add609..793737e8 100644
--- a/lib/trace-cmd/include/trace-tsync-local.h
+++ b/lib/trace-cmd/include/trace-tsync-local.h
@@ -11,6 +11,7 @@ 
 struct clock_sync_context {
 	void				*proto_data;	/* time sync protocol specific data */
 	bool				is_server;	/* server side time sync role */
+	bool				is_guest;	/* guest or host time sync role */
 	struct tracefs_instance		*instance;	/* ftrace buffer, used for time sync events */
 
 	/* Arrays with calculated time offsets at given time */
diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c
index d461392b..12e00686 100644
--- a/lib/trace-cmd/trace-timesync.c
+++ b/lib/trace-cmd/trace-timesync.c
@@ -283,7 +283,7 @@  clock_synch_delete_instance(struct tracefs_instance *inst)
 	tracefs_instance_free(inst);
 }
 
-static int clock_context_init(struct tracecmd_time_sync *tsync, bool server)
+static int clock_context_init(struct tracecmd_time_sync *tsync, bool guest)
 {
 	struct clock_sync_context *clock = NULL;
 	struct tsync_proto *protocol;
@@ -298,8 +298,11 @@  static int clock_context_init(struct tracecmd_time_sync *tsync, bool server)
 	clock = calloc(1, sizeof(struct clock_sync_context));
 	if (!clock)
 		return -1;
-
-	clock->is_server = server;
+	clock->is_guest = guest;
+	if (clock->is_guest)
+		clock->is_server = true;
+	else
+		clock->is_server = false;
 	if (get_vsocket_params(tsync->msg_handle->fd, &clock->local_cid,
 			       &clock->local_port, &clock->remote_cid,
 			       &clock->remote_port))