Qemu trace usage
Qemu has its own Trace framework and supports multiple debug/trace backends including: nop, dtrace, ftrace, log, simple, ust, which can help us analyze problems in Qemu. For an introduction to these backend, you can see this link: http://repo.or.cz/w/qemu/stefanha.git/blob_plain/refs/heads/tracing:/docs/tracing.txt, if the existing trace point does not meet your needs, it also describes how to add a new trace point. This article focuses on the use of a backend:Simple trace embedded in Qemu, which can be used without installing any other software.
1) enable trace backend is required when compiling qemu
. / configure-- enable-trace-backends=simple
2) add the event of the trace you want
$cat / tmp/events
Virtio_blk_req_complete
Virtio_blk_handle_write
3) start the virtual machine
-trace events=/tmp/events,file=trace.bin
Among them, add "- trace events=/tmp/events,file=trace.bin" to the normally started qemu program, where / tmp/events is the event to be tracked, and trace.bin is the file generated by trace, which cannot be read directly, but through the tool.
4) get the trace result
Simpletrace.py trace-events trace.bin
5) some modules also implement their own pretty-print tools to make it easier to view the results. For example, if you trace the module of 9p, you can check it through the following tools.
Analyse-9p-simpletrace.py trace-events trace.bin