TRACE-CMD-ATTACH(1) libtracefs Manual TRACE-CMD-ATTACH(1) (NAME) trace-cmd-attach - trace.dat trace.dat (SYNOPSIS) trace-cmd attach [OPTIONS] host-trace-file guest-trace-file guest-pid [guest-pid ...] (DESCRIPTION) trace-cmd attach(1) trace.dat trace.dat . trace-cmd-agent(1) (agent) trace-cmd trace-cmd-record(1) . trace-cmd attach(1) trace-cmd agent . host-trace-file trace.dat . kvm_exit kvm_entry "tsc2nsec" . guest-trace-file trace.dat . "x86-tsc" . x86 . guest-pid (PID) . vCPU . vCPU host-trace-file kvm_exit kvm_entry PID vCPU . (OPTIONS) -c cpus CPU . -s timeshift offset,scale,frac,timestamp /sys/kernel/kvm//vcpu/* . *offset*: "tsc-offset" . () . *scale*: "tsc-scaling-ratio" *frac*: "tsc-scaling-ratio-frac-bits" *timestamp*: . . . . CPU timeshift . CPU *-s* . CPU CPU . CPU . (EXAMPLES) : $ # find the process for a given guest $ ps aux |grep qemu libvirt+ 63170 5.6 1.6 13994848 4257540 ? Sl May02 2884:49 /usr/bin/qemu-system-x86_64... $ # Use 63170 to find all the PIDs for the give guest $ ls /proc/63170/task 1541591 63170 63198 63209 63211 63213 63214 63215 63216 63217 63218 63219 63234 $ # Find the tsc offset $ su # cat /sys/kernel/debug/kvm/63170-15/vcpu0/tsc-offset -27950965013436847 # trace-cmd record -C tsc2nsec -e kvm -e sched -e irq -e timer # on guest: # trace-cmd record -C x86-tsc -e sched -e irq -e timer sleep 10 # back on host, hit Ctrl^C to stop tracing after the guest is done # # Make the trace.dat user owned by your user account. # chown user.user trace.dat # exit $ scp root@guest:trace.dat trace-guest.dat $ # now attach the two files (guest has 8 CPUs) $ trace-cmd attach -c 8 -s 27950965013436847 trace.dat trace-guest.dat 1541591 63170 63198 63209 63211 63213 63214 63215 63216 63217 63218 63219 63234 $ trace-cmd report -i trace.dat -i trace-guest.dat $ # now you should see the guest trace interleaved within the host trace. (SEE ALSO) trace-cmd(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), trace-cmd-list(1), trace-cmd-listen(1), trace-cmd-profile(1) (AUTHORS) Steven Rostedt (Google) (RESOURCES) https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git (COPYRIGHT) ) Red Hat, Inc. (GPL) . (NOTES) 1. rostedt@goodmis.org mailto:rostedt@goodmis.org libtracefs 03/09/2026 TRACE-CMD-ATTACH(1)