Blame SOURCES/0017-Add-support-for-simpletrace.patch

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