A.3. Capturing Trace Data on a Constant Basis Using the Systemtap Flight Recorder
You can capture QEMU trace data all the time using a systemtap initscript provided in the qemu-kvm package. This package uses SystemTap's flight recorder mode to trace all running guest virtual machines and to save the results to a fixed-size buffer on the host. Old trace entries are overwritten by new entries when the buffer is filled.
Procedure A.1. Configuring and running systemtap
Install the package
Install the systemtap-initscript package by running the following command:#
yum install systemtap-initscript
Copy the configuration file
Copy the systemtap scripts and the configuration files to the systemtap directory by running the following commands:#
cp /usr/share/qemu-kvm/systemtap/script.d/qemu_kvm.stp /etc/systemtap/script.d/
#cp /usr/share/qemu-kvm/systemtap/conf.d/qemu_kvm.conf /etc/systemtap/conf.d/
The set of trace events to enable is given in qemu_kvm.stp. This SystemTap script can be customized to add or remove trace events provided in/usr/share/systemtap/tapset/qemu-kvm-simpletrace.stp
.SystemTap customizations can be made toqemu_kvm.conf
to control the flight recorder buffer size and whether to store traces in memory only or in the disk as well.Start the service
Start the systemtap service by running the following command:#
systemctl start systemtap qemu_kvm
Make systemtap enabled to run at boot time
Enable the systemtap service to run at boot time by running the following command:#
systemctl enable systemtap qemu_kvm
Confirmation the service is running
Confirm that the service is working by running the following command:#
systemctl status systemtap qemu_kvm
qemu_kvm is running...
Procedure A.2. Inspecting the trace buffer
Create a trace buffer dump file
Create a trace buffer dump file called trace.log and place it in the tmp directory by running the following command:#
staprun -A qemu_kvm >/tmp/trace.log
You can change the file name and location to something else.Start the service
As the previous step stops the service, start it again by running the following command:#
systemctl start systemtap qemu_kvm
Convert the trace contents into a readable format
To convert the trace file contents into a more readable format, enter the following command:#
/usr/share/qemu-kvm/simpletrace.py --no-header /usr/share/qemu-kvm/trace-events /tmp/trace.log
Note
The following notes and limitations should be noted:
- The systemtap service is disabled by default.
- There is a small performance penalty when this service is enabled, but it depends on which events are enabled in total.
- There is a README file located in
/usr/share/doc/qemu-kvm-*/README.systemtap
.