trace-cmd attach: Add new command "attach"

Add a new trace-cmd command called "attach". This will attach a trace.dat
file created on a guest to a trace.dat file created on the host at the
same time. In some cases, trace-cmd agent isn't possible. This gives the
ability to do a trace on the guest with trace-cmd record, and on the host
as well, and then combine the two such that the guest events are
interleaved properly within the host events.

There's some requirements for the traces. The host side needs to enable
kvm_exit/entry events as well as to use the tsc2nsec clock. The guest
needs to use the x86-tsc clock.

As can be seen by the above requirements, this currently works only for
x86, but when other architectures have raw clocks that can do the same,
then they will be supported.

Link: https://lore.kernel.org/linux-trace-devel/20230606211658.580d3063@gandalf.local.home

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
7 files changed