trace-cmd listen: Update the V2 protocol to handle old and new
Change the protocol slightly where V1 will fail right away without creating
a blank trace.dat file by appending '-1' to the V2 name. The old trace-cmd
listen will see that as a negative CPU count and bail.
Also change the hand shake a bit such that if we go to a V3, a V2 server
could just let the newer trace-cmd client know what version it can support.
Here's the update:
<server> <client>
listen to socket fd
connect to socket fd
accept the client
send "tracecmd"
+------------> receive "tracecmd"
check "tracecmd"
* send "-1V2\0"
* try_again:
* receive "-1V2" <------------+
* check "-1V2"
* if (!"-1V2") {
* if (memcmp("-1V",3))
* error();
* send "V2\0"
* goto try_again;
* }
* send "V2"
* +---------------> receive "V2"
* check "V2"
* send "<MAGIC_NUMBER>\00" as the v2 protocol
read "<MAGIC_NUMBER>\00"
* send "OK"
* +---------------> receive "OK"
* check "OK"
send cpus,pagesize,option(MSG_TINIT)
receive MSG_TINIT <-------+
print "cpus=XXX"
print "pagesize=XXX"
understand option
send port_array
+--MSG_RINIT-> receive MSG_RINIT
understand port_array
send meta data(MSG_SENDMETA)
receive MSG_SENDMETA <----+
record meta data
(snip)
send a message to finish sending meta data
| (MSG_FINMETA)
receive MSG_FINMETA <-----+
read block
--- start sending trace data on child processes ---
--- When client finishes sending trace data ---
send MSG_CLOSE
receive MSG_CLOSE <-------+
close(socket fd) close(socket fd)
The '*' represents what was updated.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
3 files changed