cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
From e10de328869f0b7b990b74863111c172fb45d7a4 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
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
26ba25
(cherry picked from commit bfc1d7f3628f2ffbabbae71d57a506cea6663ddf)
26ba25
---
26ba25
 .gitignore                              |  2 ++
26ba25
 Makefile                                |  4 +++
26ba25
 README.systemtap                        | 43 +++++++++++++++++++++++++++++++++
26ba25
 redhat/qemu-kvm.spec.template           | 27 +++++++++++++++++++--
26ba25
 scripts/systemtap/conf.d/qemu_kvm.conf  |  4 +++
26ba25
 scripts/systemtap/script.d/qemu_kvm.stp |  1 +
26ba25
 6 files changed, 79 insertions(+), 2 deletions(-)
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
26ba25
index 89ba4c5..d0a848e 100644
26ba25
--- a/Makefile
26ba25
+++ b/Makefile
26ba25
@@ -864,6 +864,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/"
26ba25
 	for d in $(TARGET_DIRS); do \
26ba25
 	$(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
26ba25
         done
26ba25
diff --git a/README.systemtap b/README.systemtap
26ba25
new file mode 100644
26ba25
index 0000000..ad913fc
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
26ba25
index 0000000..372d816
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
26ba25
index 0000000..c04abf9
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
-- 
26ba25
1.8.3.1
26ba25