summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2010-10-21 07:02:43 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-10-21 07:02:43 -0400
commitc660d82a9ffab4752687b5f17ceba1b108ed8002 (patch)
tree457a0a2ba4b67c8c1792a48daf1f9b4abe022a4d
parent2425e327182e56648b19c12a7ae3515367bbffc4 (diff)
parent5a2381ded7672b5d3799ce7e591788953fa622ce (diff)
Merge branch 'master' of ssh://cvs/~/litmus/tools
-rwxr-xr-xkvm-pull-traces.sh25
-rwxr-xr-xkvm-push-liblitmus.sh25
-rwxr-xr-xkvm-run-kernel.sh50
-rwxr-xr-xresolve-symlink.py21
-rw-r--r--sample-config/litmus-kvm16
-rwxr-xr-xtex-un-include51
6 files changed, 188 insertions, 0 deletions
diff --git a/kvm-pull-traces.sh b/kvm-pull-traces.sh
new file mode 100755
index 0000000..f823360
--- /dev/null
+++ b/kvm-pull-traces.sh
@@ -0,0 +1,25 @@
1#!/bin/bash
2#
3# Simple script to download files from a KVM image to the local system.
4# Originally written by Andrea Bastoni.
5# Config file support added by Bjoern Brandenburg.
6
7SSH_PORT=2222 # default
8SSH_USER=root # what to log in as
9SSH_HOST=localhost # where is the forwarded port?
10DATA_DIR="~/liblitmus2010/" # where are the traces in the image?
11FILE_GLOB="test*.bin" # which files to copy
12DOWNLOADS=. # where to copy the files
13
14# include config file
15[ -f ~/.litmus_kvm ] && source ~/.litmus_kvm
16
17#SRC="${SSH_USER}@${SSH_HOST}:${DATA_DIR}${FILE_GLOB}"
18#echo scp -P $SSH_PORT ${SRC} ${DOWNLOADS}
19#scp -P $SSH_PORT ${SRC} ${DOWNLOADS}
20
21
22CMD="ssh -l ${SSH_USER} -p ${SSH_PORT}"
23SRC="${SSH_HOST}:${DATA_DIR}${FILE_GLOB}"
24echo rsync -ah -z --progress -e "$CMD" ${SRC} ${DOWNLOADS}
25rsync -ah -z --progress -e "$CMD" ${SRC} ${DOWNLOADS}
diff --git a/kvm-push-liblitmus.sh b/kvm-push-liblitmus.sh
new file mode 100755
index 0000000..0073efd
--- /dev/null
+++ b/kvm-push-liblitmus.sh
@@ -0,0 +1,25 @@
1#!/bin/bash
2
3#
4# Simple script to push a compiled version of liblitmus2010 to a KVM instance.
5# Originally written by Andrea Bastoni.
6# Config file support added by Bjoern Brandenburg.
7
8SSH_PORT=2222 # default
9SSH_USER=root # what to log in as
10SSH_HOST=localhost # where is the forwarded port?
11HOST_LIBLITMUS_DIR="~/liblitmus2010" # where is the compilation unit
12KVM_WORKSPACE="~/" # where to copy the files
13
14# include config file
15[ -f ~/.litmus_kvm ] && source ~/.litmus_kvm
16
17#SRC="${SSH_USER}@${SSH_HOST}:${DATA_DIR}${FILE_GLOB}"
18#echo scp -P $SSH_PORT ${SRC} ${DOWNLOADS}
19#scp -P $SSH_PORT ${SRC} ${DOWNLOADS}
20
21
22CMD="ssh -l ${SSH_USER} -p ${SSH_PORT}"
23TARGET="${SSH_HOST}:${KVM_WORKSPACE}"
24echo rsync -ah -z --progress -e "$CMD" ${HOST_LIBLITMUS_DIR} ${TARGET}
25rsync -ah -z --progress -e "$CMD" ${HOST_LIBLITMUS_DIR} ${TARGET}
diff --git a/kvm-run-kernel.sh b/kvm-run-kernel.sh
new file mode 100755
index 0000000..5f75bcb
--- /dev/null
+++ b/kvm-run-kernel.sh
@@ -0,0 +1,50 @@
1#!/bin/bash
2# Launch a kernel with GDB support.
3# Originally written by Andrea Bastoni.
4# Config file support and option parsing added by Bjoern Brandenburg.
5
6function info() {
7 echo "(ii) $*"
8}
9
10while true
11do
12 case $1 in
13 --gdb)
14 shift
15 WANT_GDB=1
16 ;;
17 *) # unknown argument
18 break
19 ;;
20 esac
21done
22
23if [ $# -lt 2 ]; then
24 echo "Usage: run_kvm [--gdb] <vmlinuz> <nr cpu> [other kernel parameters]"
25 exit 1
26fi
27
28SSH_PORT=2222 # default
29GDB_PORT=6666 # override in config file
30KVM_IMAGE=~/kvm_debian_images/debian_amd64_lib.qcow2
31
32# include config file
33[ -f ~/.litmus_kvm ] && source ~/.litmus_kvm
34
35info "Simulating $2 CPUs."
36info "Running on top of image ${KVM_IMAGE}."
37info "Launching kernel $1."
38info "Redirecting SSH to port ${SSH_PORT}."
39
40if [ ! -z "$WANT_GDB" ]
41then
42 info "Opening remote GDB port ${GDB_PORT}."
43 GDB_OPT="-gdb tcp::${GDB_PORT} -S"
44else
45 GDB_OPT=
46fi
47
48# Newer versions of KVM may refuse to load a proper serial interface if both -nographic and -serial stdio are specified (koruna does this).
49# In such cases, remove "-serial stdio"
50qemu-system-x86_64 ${GDB_OPT} -smp $2 -cpu core2duo -hda ${KVM_IMAGE} -m 2000 -net nic,model=e1000 -net user -k en-us -kernel $1 -append "console=ttyS0 root=/dev/hda1 $3" ro -nographic -serial stdio -redir tcp:${SSH_PORT}::22
diff --git a/resolve-symlink.py b/resolve-symlink.py
new file mode 100755
index 0000000..a9107a9
--- /dev/null
+++ b/resolve-symlink.py
@@ -0,0 +1,21 @@
1#!/usr/bin/env python
2
3import os
4import sys
5import shutil
6
7def resolve_symlinks(links):
8 for f in links:
9 try:
10 target = os.readlink(f)
11 if target[0] != '/':
12 # make absolute
13 target = os.path.join(os.path.dirname(f), target)
14 os.unlink(f)
15 shutil.move(target, f)
16 except OSError, err:
17 print "Failed: %s (%s)" % (f, err)
18
19
20if __name__ == '__main__':
21 resolve_symlinks(sys.argv[1:])
diff --git a/sample-config/litmus-kvm b/sample-config/litmus-kvm
new file mode 100644
index 0000000..b724a85
--- /dev/null
+++ b/sample-config/litmus-kvm
@@ -0,0 +1,16 @@
1# Simple Litmus KVM tools config file.
2# Copy this to ~/.litmus_kvm
3
4# how to connect to the VM
5SSH_PORT=1234 # CHANGE THIS
6GDB_PORT=4321 # CHANGE THIS
7SSH_HOST=localhost
8
9# for pull
10DATA_DIR="~/liblitmus2010/traces/"
11FILE_GLOB="*"
12DOWNLOADS=~/downloads
13
14# for push
15HOST_LIBLITMUS_DIR=~/dev/liblitmus2010
16KVM_WORKSPACE="~/"
diff --git a/tex-un-include b/tex-un-include
new file mode 100755
index 0000000..72d7998
--- /dev/null
+++ b/tex-un-include
@@ -0,0 +1,51 @@
1#!/usr/bin/env python
2
3import sys
4import re
5
6comment_re = re.compile(r'([^\\]|^)%')
7input_re = re.compile(r'\\input\{([^}]*)\}')
8
9def strip_comment(line):
10 g = comment_re.search(line)
11 if g:
12 # we matched some non-\ character
13 return line[0:g.start() + 1]
14 else:
15 return line
16
17def chomp(line):
18 if line and line[-1] == '\n':
19 return line[:-1]
20 else:
21 return line
22
23def open_tex_file(fname, mode='r'):
24 try:
25 f = open(fname, mode)
26 except IOError:
27 # try again with .tex appended
28 f = open(fname + '.tex', mode)
29 return f
30
31def process_file(fname, out=sys.stdout):
32 for line in open_tex_file(fname):
33 line = chomp(strip_comment(line))
34 idx = 0
35 for g in input_re.finditer(line):
36 out.write(line[idx:g.start()])
37 fname = g.group(1)
38 # recurse into file
39 out.write("%%!!!!! processing %s !!!!!\n" % fname)
40 process_file(fname, out)
41 idx = g.end()
42 out.write(line[idx:])
43 out.write('\n')
44
45
46def main(args=sys.argv[1:]):
47 for fname in args:
48 process_file(fname)
49
50if __name__ == '__main__':
51 main()