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