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