summaryrefslogtreecommitdiff
path: root/stp
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-09-14 01:37:28 +0300
committerAlon Levy <alevy@redhat.com>2012-09-14 01:37:28 +0300
commitb1209ad9adc7d407a4f9d6b08c0f6e8e2fb52bab (patch)
treed07f3ce15858ac03c3c405fc4e68d789c821d98e /stp
parentff7d86319d92e823dc6085605d9e67f9b899c699 (diff)
stp: add spice_generic stp generatorHEADmaster
Diffstat (limited to 'stp')
-rwxr-xr-xstp/spice_generic.py41
-rw-r--r--stp/spice_generic.stp.template9
2 files changed, 50 insertions, 0 deletions
diff --git a/stp/spice_generic.py b/stp/spice_generic.py
new file mode 100755
index 0000000..d42015e
--- /dev/null
+++ b/stp/spice_generic.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+import sys
+from argparse import ArgumentParser
+from glob import glob
+import os
+
+def get_library_path():
+ # TODO: /etc/ld.so.conf
+ return os.environ['LD_LIBRARY_PATH'].split(':') + ["/usr/lib64"]
+
+def find_spice_library(args):
+ paths = get_library_path()
+ candidates = sum([glob(os.path.join(p, 'libspice-server.so*'))
+ for p in paths], [])
+ if len(candidates) == 0:
+ print "no libspice-server.so* in %s" % repr(paths)
+ raise SystemExit
+ library = candidates[args.lib_num or 0]
+ if len(candidates) > 1 and not args.lib_num:
+ print "warning: guessing library as %s\noptions: %s" % (
+ library, repr(candidates))
+ return library
+
+def main():
+ parser = ArgumentParser()
+ parser.add_argument('--lib-num', help='index of library in candidates')
+ parser.add_argument('--template', default='spice_generic.stp.template')
+ parser.add_argument('--target', default='spice_generic.stp')
+ args = parser.parse_args(sys.argv[1:])
+ library = find_spice_library(args)
+ with open(args.template, 'r') as fd:
+ base_template = fd.read()
+ with open(args.target, 'w+') as fd:
+ fd.write("//Automatically Generated File, do not edit\n")
+ fd.write("//=========================================\n\n")
+ template = base_template.replace('%', '%%').replace('<>', '%')
+ fd.write(template % dict(library=library))
+ os.system('sudo stap -v %s' % args.target)
+
+if __name__ == '__main__':
+ main()
diff --git a/stp/spice_generic.stp.template b/stp/spice_generic.stp.template
new file mode 100644
index 0000000..859e42b
--- /dev/null
+++ b/stp/spice_generic.stp.template
@@ -0,0 +1,9 @@
+// Template is filled with the correct spice server library by searching
+// LD_LIBRARY_PATH, /usr/lib64, /lib64
+probe process("<>(library)s").function("red_channel_client_create")
+{
+ printf("[%d] new channel %d:%d; caps %d; common %d\n",
+ pid(), @cast($channel, "RedChannel")->type,
+ @cast($channel, "RedChannel")->id,
+ user_long($caps), user_long($common_caps));
+}