958e1b
From a8ebb2f69df031099116afebca2fb2a2cb3ec678 Mon Sep 17 00:00:00 2001
958e1b
From: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
Date: Tue, 7 Oct 2014 14:06:58 +0200
958e1b
Subject: [PATCH 40/43] trace: add SystemTap init scripts for simpletrace
958e1b
 bridge
958e1b
958e1b
Message-id: <1412690820-31016-10-git-send-email-stefanha@redhat.com>
958e1b
Patchwork-id: 61614
958e1b
O-Subject: [RHEL7.1 qemu-kvm PATCH 09/11] trace: add SystemTap init scripts for simpletrace bridge
958e1b
Bugzilla: 1088112
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
958e1b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
958e1b
Add example files for use with the systemtap-initscript package.  These
958e1b
example files set up the SystemTap flight recorder with our simpletrace
958e1b
bridge script.  In other words, they set up always-on simpletrace.
958e1b
958e1b
The example file enables a small subset of trace events across all
958e1b
qemu-kvm processes with 4MB per CPU trace buffers.  This example
958e1b
configuration may be useful to customers who wish to run with always-on
958e1b
tracing.
958e1b
958e1b
To enable it:
958e1b
958e1b
  # yum install systemtap-initscript
958e1b
  # cp /usr/share/qemu-kvm/systemtap/conf.d/qemu_kvm.conf /etc/systemtap/conf.d/
958e1b
  # cp /usr/share/qemu-kvm/systemtap/script.d/qemu_kvm.stp /etc/systemtap/script.d/
958e1b
  # service systemtap start qemu_kvm
958e1b
958e1b
Note that due to systemtap-initscript naming restrictions the scripts
958e1b
are called "qemu_kvm" instead of "qemu-kvm".
958e1b
958e1b
Once installed the script will be activated on boot.
958e1b
958e1b
Note that since gitignore(1) hides *.d we explicitly unhide
958e1b
scripts/systemtap/{conf.d,script.d} in this patch.
958e1b
958e1b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
(cherry picked from commit 3a83a60ee0fd25580499695e4781fc473de147c5)
958e1b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
958e1b
Conflicts:
958e1b
	Makefile
958e1b
	redhat/qemu-kvm.spec.template
958e1b
958e1b
This downstream commit from RHEL 6.6 was forwarded-ported to RHEL 7.1
958e1b
where the Makefile and qemu-kvm.spec.template are organized differently.
958e1b
---
958e1b
 .gitignore                              | 2 ++
958e1b
 Makefile                                | 4 ++++
958e1b
 redhat/qemu-kvm.spec.template           | 4 +++-
958e1b
 scripts/systemtap/conf.d/qemu_kvm.conf  | 4 ++++
958e1b
 scripts/systemtap/script.d/qemu_kvm.stp | 1 +
958e1b
 5 files changed, 14 insertions(+), 1 deletion(-)
958e1b
 create mode 100644 scripts/systemtap/conf.d/qemu_kvm.conf
958e1b
 create mode 100644 scripts/systemtap/script.d/qemu_kvm.stp
958e1b
958e1b
diff --git a/.gitignore b/.gitignore
958e1b
index 4f2345c..454561e 100644
958e1b
--- a/.gitignore
958e1b
+++ b/.gitignore
958e1b
@@ -74,6 +74,8 @@ fsdev/virtfs-proxy-helper.pod
958e1b
 *.vr
958e1b
 *.d
958e1b
 !scripts/qemu-guest-agent/fsfreeze-hook.d
958e1b
+!scripts/systemtap/script.d
958e1b
+!scripts/systemtap/conf.d
958e1b
 *.o
958e1b
 *.lo
958e1b
 *.la
958e1b
diff --git a/Makefile b/Makefile
958e1b
index 1b0b4f7..8407945 100644
958e1b
--- a/Makefile
958e1b
+++ b/Makefile
958e1b
@@ -407,6 +407,10 @@ endif
958e1b
 		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
958e1b
 	done
958e1b
 	$(INSTALL_DATA) $(SRC_PATH)/trace-events "$(DESTDIR)$(qemu_datadir)/trace-events"
958e1b
+	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/systemtap/script.d"
958e1b
+	$(INSTALL_DATA) $(SRC_PATH)/scripts/systemtap/script.d/qemu_kvm.stp "$(DESTDIR)$(qemu_datadir)/systemtap/script.d/"
958e1b
+	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/systemtap/conf.d"
958e1b
+	$(INSTALL_DATA) $(SRC_PATH)/scripts/systemtap/conf.d/qemu_kvm.conf "$(DESTDIR)$(qemu_datadir)/systemtap/conf.d/"
958e1b
 	for d in $(TARGET_DIRS); do \
958e1b
 	$(MAKE) -C $$d $@ || exit 1 ; \
958e1b
         done
958e1b
diff --git a/scripts/systemtap/conf.d/qemu_kvm.conf b/scripts/systemtap/conf.d/qemu_kvm.conf
958e1b
new file mode 100644
958e1b
index 0000000..372d816
958e1b
--- /dev/null
958e1b
+++ b/scripts/systemtap/conf.d/qemu_kvm.conf
958e1b
@@ -0,0 +1,4 @@
958e1b
+# Force load uprobes (see BZ#1118352)
958e1b
+stap -e 'probe process("/usr/libexec/qemu-kvm").function("main") { printf("") }' -c true
958e1b
+
958e1b
+qemu_kvm_OPT="-s4" # per-CPU buffer size, in megabytes
958e1b
diff --git a/scripts/systemtap/script.d/qemu_kvm.stp b/scripts/systemtap/script.d/qemu_kvm.stp
958e1b
new file mode 100644
958e1b
index 0000000..c04abf9
958e1b
--- /dev/null
958e1b
+++ b/scripts/systemtap/script.d/qemu_kvm.stp
958e1b
@@ -0,0 +1 @@
958e1b
+probe qemu.kvm.simpletrace.handle_qmp_command,qemu.kvm.simpletrace.monitor_protocol_*,qemu.kvm.simpletrace.migrate_set_state {}
958e1b
-- 
958e1b
1.8.3.1
958e1b