* [PATCH] initscript: automatically detect uprobes dependency
@ 2014-09-09 15:23 Stefan Hajnoczi
2014-09-12 21:41 ` Jonathan Lebon
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2014-09-09 15:23 UTC (permalink / raw)
To: systemtap; +Cc: Jonathan Lebon, Josh Stone, Stefan Hajnoczi
systemtap-initscript scripts that rely on uprobes must be configured
with the --save-uprobes option. This option saves the generated
uprobes.ko module and loads it when running the script.
The uprobes dependency information is actually available at compile time
so we can autodetect as follows:
1. Check if uprobes.ko was generated during compile
2. When uprobes.ko was generated, touch <name>.uprobes in the cache
directory.
3. Add the staprun -u option if <name>.uprobes exists
It is no longer necessary to specify the --save-uprobes option in the
initscript configuration file, although doing so allowed.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
initscript/systemtap.in | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/initscript/systemtap.in b/initscript/systemtap.in
index 683734d..c8219cb 100755
--- a/initscript/systemtap.in
+++ b/initscript/systemtap.in
@@ -495,13 +495,16 @@ compile_script () { # script checkcache
return 1
fi
pushd "$tmpdir" &> /dev/null
- logex $STAP -m "$1" -p4 -r $KRELEASE $opts "$f"
+ logex $STAP -m "$1" -p4 -r $KRELEASE --save-uprobes $opts "$f"
ret=$?
if [ $ret -eq 0 ]; then
if [ -f "uprobes/uprobes.ko" ]; then
+ logex touch "$CACHE_PATH/$1.uprobes"
logex mkdir -p "$CACHE_PATH/uprobes"
logex mv "uprobes/uprobes.ko" "$CACHE_PATH/uprobes/"
ret=$?
+ elif [ -f "$CACHE_PATH/$1.uprobes" ]; then
+ rm "$CACHE_PATH/$1.uprobes"
fi
fi
if [ $ret -eq 0 ]; then
@@ -575,6 +578,10 @@ start_script () { # script
mode=$?
[ $mode -eq 0 ] && return 2
+ if [ -f "$CACHE_PATH/$s.uprobes" ]; then
+ opts="$opts -u$CACHE_PATH/uprobes/uprobes.ko"
+ fi
+
clog " Starting $1 ... " -n
tmpdir=`mktemp -d -p "$TEMP_PATH" cache.XXXXXXXX` # bz7097
if [ $? -ne 0 ]; then
@@ -767,7 +774,7 @@ compile () {
return 1
fi
for s in $SCRIPTS; do
- ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" 2> /dev/null`
+ ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" "$CACHE_PATH/$s.uprobes" 2> /dev/null`
done
ss=`echo -n $ss`
if [ "$ss" ]; then
@@ -960,7 +967,7 @@ cleanup () {
fi
for s in $SCRIPTS; do
- ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" 2> /dev/null`
+ ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" "$CACHE_PATH/$s.uprobes" 2> /dev/null`
done
ss=`echo -n $ss`
if [ "$ss" ]; then
@@ -968,7 +975,7 @@ cleanup () {
ask_yesno "Do you really want to remove above caches"
[ $? -eq 0 ] && return 0
for s in $SCRIPTS; do
- logex rm -f "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts"
+ logex rm -f "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" "$CACHE_PATH/$s.uprobes"
[ $? -ne 0 ] && might_fail $"failed to clean cache $s.ko"
done
might_success "done"
--
1.9.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-12 21:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09 15:23 [PATCH] initscript: automatically detect uprobes dependency Stefan Hajnoczi
2014-09-12 21:41 ` Jonathan Lebon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).