902636
From 26128b3ede339e292a3c50a84e3248af46ecd0ec Mon Sep 17 00:00:00 2001
26ba25
From: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
Date: Thu, 8 Oct 2015 09:50:17 +0200
26ba25
Subject: Add support for simpletrace
26ba25
26ba25
As simpletrace is upstream, we just need to properly handle it during rpmbuild.
26ba25
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
902636
Rebase notes (3.1.0):
902636
- Fixed python 2 to python3 switch
902636
26ba25
Rebase notes (2.9.0):
26ba25
- Added group argument for tracetool.py (upstream)
26ba25
26ba25
Rebase notes (2.8.0):
26ba25
- Changed tracetool.py parameters
26ba25
26ba25
Merged patches (2.3.0):
26ba25
- db959d6 redhat/qemu-kvm.spec.template: Install qemu-kvm-simpletrace.stp
26ba25
- 5292fc3 trace: add SystemTap init scripts for simpletrace bridge
26ba25
- eda9e5e simpletrace: install simpletrace.py
26ba25
- 85c4c8f trace: add systemtap-initscript README file to RPM
26ba25
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 .gitignore                              |  2 ++
26ba25
 Makefile                                |  4 +++
902636
 README.systemtap                        | 43 +++++++++++++++++++++++++
902636
 redhat/qemu-kvm.spec.template           | 26 ++++++++++++++-
26ba25
 scripts/systemtap/conf.d/qemu_kvm.conf  |  4 +++
26ba25
 scripts/systemtap/script.d/qemu_kvm.stp |  1 +
902636
 6 files changed, 79 insertions(+), 1 deletion(-)
26ba25
 create mode 100644 README.systemtap
26ba25
 create mode 100644 scripts/systemtap/conf.d/qemu_kvm.conf
26ba25
 create mode 100644 scripts/systemtap/script.d/qemu_kvm.stp
26ba25
26ba25
diff --git a/Makefile b/Makefile
902636
index 086727dbb9..4254950f7f 100644
26ba25
--- a/Makefile
26ba25
+++ b/Makefile
902636
@@ -939,6 +939,10 @@ endif
26ba25
 		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
26ba25
 	done
26ba25
 	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
26ba25
+	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/systemtap/script.d"
26ba25
+	$(INSTALL_DATA) $(SRC_PATH)/scripts/systemtap/script.d/qemu_kvm.stp "$(DESTDIR)$(qemu_datadir)/systemtap/script.d/"
26ba25
+	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/systemtap/conf.d"
26ba25
+	$(INSTALL_DATA) $(SRC_PATH)/scripts/systemtap/conf.d/qemu_kvm.conf "$(DESTDIR)$(qemu_datadir)/systemtap/conf.d/"
902636
 
902636
 .PHONY: ctags
902636
 ctags:
26ba25
diff --git a/README.systemtap b/README.systemtap
26ba25
new file mode 100644
902636
index 0000000000..ad913fc990
26ba25
--- /dev/null
26ba25
+++ b/README.systemtap
26ba25
@@ -0,0 +1,43 @@
26ba25
+QEMU tracing using systemtap-initscript
26ba25
+---------------------------------------
26ba25
+
26ba25
+You can capture QEMU trace data all the time using systemtap-initscript.  This
26ba25
+uses SystemTap's flight recorder mode to trace all running guests to a
26ba25
+fixed-size buffer on the host.  Old trace entries are overwritten by new
26ba25
+entries when the buffer size wraps.
26ba25
+
26ba25
+1. Install the systemtap-initscript package:
26ba25
+  # yum install systemtap-initscript
26ba25
+
26ba25
+2. Install the systemtap scripts and the conf file:
26ba25
+  # cp /usr/share/qemu-kvm/systemtap/script.d/qemu_kvm.stp /etc/systemtap/script.d/
26ba25
+  # cp /usr/share/qemu-kvm/systemtap/conf.d/qemu_kvm.conf /etc/systemtap/conf.d/
26ba25
+
26ba25
+The set of trace events to enable is given in qemu_kvm.stp.  This SystemTap
26ba25
+script can be customized to add or remove trace events provided in
26ba25
+/usr/share/systemtap/tapset/qemu-kvm-simpletrace.stp.
26ba25
+
26ba25
+SystemTap customizations can be made to qemu_kvm.conf to control the flight
26ba25
+recorder buffer size and whether to store traces in memory only or disk too.
26ba25
+See stap(1) for option documentation.
26ba25
+
26ba25
+3. Start the systemtap service.
26ba25
+ # service systemtap start qemu_kvm
26ba25
+
26ba25
+4. Make the service start at boot time.
26ba25
+ # chkconfig systemtap on
26ba25
+
26ba25
+5. Confirm that the service works.
26ba25
+  # service systemtap status qemu_kvm
26ba25
+  qemu_kvm is running...
26ba25
+
26ba25
+When you want to inspect the trace buffer, perform the following steps:
26ba25
+
26ba25
+1. Dump the trace buffer.
26ba25
+  # staprun -A qemu_kvm >/tmp/trace.log
26ba25
+
26ba25
+2. Start the systemtap service because the preceding step stops the service.
26ba25
+  # service systemtap start qemu_kvm
26ba25
+
26ba25
+3. Translate the trace record to readable format.
26ba25
+  # /usr/share/qemu-kvm/simpletrace.py --no-header /usr/share/qemu-kvm/trace-events /tmp/trace.log
26ba25
diff --git a/scripts/systemtap/conf.d/qemu_kvm.conf b/scripts/systemtap/conf.d/qemu_kvm.conf
26ba25
new file mode 100644
902636
index 0000000000..372d8160a4
26ba25
--- /dev/null
26ba25
+++ b/scripts/systemtap/conf.d/qemu_kvm.conf
26ba25
@@ -0,0 +1,4 @@
26ba25
+# Force load uprobes (see BZ#1118352)
26ba25
+stap -e 'probe process("/usr/libexec/qemu-kvm").function("main") { printf("") }' -c true
26ba25
+
26ba25
+qemu_kvm_OPT="-s4" # per-CPU buffer size, in megabytes
26ba25
diff --git a/scripts/systemtap/script.d/qemu_kvm.stp b/scripts/systemtap/script.d/qemu_kvm.stp
26ba25
new file mode 100644
902636
index 0000000000..c04abf9449
26ba25
--- /dev/null
26ba25
+++ b/scripts/systemtap/script.d/qemu_kvm.stp
26ba25
@@ -0,0 +1 @@
26ba25
+probe qemu.kvm.simpletrace.handle_qmp_command,qemu.kvm.simpletrace.monitor_protocol_*,qemu.kvm.simpletrace.migrate_set_state {}
26ba25
-- 
902636
2.21.0
26ba25