diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-10-21 07:02:43 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-10-21 07:02:43 -0400 |
| commit | c660d82a9ffab4752687b5f17ceba1b108ed8002 (patch) | |
| tree | 457a0a2ba4b67c8c1792a48daf1f9b4abe022a4d | |
| parent | 2425e327182e56648b19c12a7ae3515367bbffc4 (diff) | |
| parent | 5a2381ded7672b5d3799ce7e591788953fa622ce (diff) | |
Merge branch 'master' of ssh://cvs/~/litmus/tools
| -rwxr-xr-x | kvm-pull-traces.sh | 25 | ||||
| -rwxr-xr-x | kvm-push-liblitmus.sh | 25 | ||||
| -rwxr-xr-x | kvm-run-kernel.sh | 50 | ||||
| -rwxr-xr-x | resolve-symlink.py | 21 | ||||
| -rw-r--r-- | sample-config/litmus-kvm | 16 | ||||
| -rwxr-xr-x | tex-un-include | 51 |
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 | |||
| 7 | SSH_PORT=2222 # default | ||
| 8 | SSH_USER=root # what to log in as | ||
| 9 | SSH_HOST=localhost # where is the forwarded port? | ||
| 10 | DATA_DIR="~/liblitmus2010/" # where are the traces in the image? | ||
| 11 | FILE_GLOB="test*.bin" # which files to copy | ||
| 12 | DOWNLOADS=. # 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 | |||
| 22 | CMD="ssh -l ${SSH_USER} -p ${SSH_PORT}" | ||
| 23 | SRC="${SSH_HOST}:${DATA_DIR}${FILE_GLOB}" | ||
| 24 | echo rsync -ah -z --progress -e "$CMD" ${SRC} ${DOWNLOADS} | ||
| 25 | rsync -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 | |||
| 8 | SSH_PORT=2222 # default | ||
| 9 | SSH_USER=root # what to log in as | ||
| 10 | SSH_HOST=localhost # where is the forwarded port? | ||
| 11 | HOST_LIBLITMUS_DIR="~/liblitmus2010" # where is the compilation unit | ||
| 12 | KVM_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 | |||
| 22 | CMD="ssh -l ${SSH_USER} -p ${SSH_PORT}" | ||
| 23 | TARGET="${SSH_HOST}:${KVM_WORKSPACE}" | ||
| 24 | echo rsync -ah -z --progress -e "$CMD" ${HOST_LIBLITMUS_DIR} ${TARGET} | ||
| 25 | rsync -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 | |||
| 6 | function info() { | ||
| 7 | echo "(ii) $*" | ||
| 8 | } | ||
| 9 | |||
| 10 | while true | ||
| 11 | do | ||
| 12 | case $1 in | ||
| 13 | --gdb) | ||
| 14 | shift | ||
| 15 | WANT_GDB=1 | ||
| 16 | ;; | ||
| 17 | *) # unknown argument | ||
| 18 | break | ||
| 19 | ;; | ||
| 20 | esac | ||
| 21 | done | ||
| 22 | |||
| 23 | if [ $# -lt 2 ]; then | ||
| 24 | echo "Usage: run_kvm [--gdb] <vmlinuz> <nr cpu> [other kernel parameters]" | ||
| 25 | exit 1 | ||
| 26 | fi | ||
| 27 | |||
| 28 | SSH_PORT=2222 # default | ||
| 29 | GDB_PORT=6666 # override in config file | ||
| 30 | KVM_IMAGE=~/kvm_debian_images/debian_amd64_lib.qcow2 | ||
| 31 | |||
| 32 | # include config file | ||
| 33 | [ -f ~/.litmus_kvm ] && source ~/.litmus_kvm | ||
| 34 | |||
| 35 | info "Simulating $2 CPUs." | ||
| 36 | info "Running on top of image ${KVM_IMAGE}." | ||
| 37 | info "Launching kernel $1." | ||
| 38 | info "Redirecting SSH to port ${SSH_PORT}." | ||
| 39 | |||
| 40 | if [ ! -z "$WANT_GDB" ] | ||
| 41 | then | ||
| 42 | info "Opening remote GDB port ${GDB_PORT}." | ||
| 43 | GDB_OPT="-gdb tcp::${GDB_PORT} -S" | ||
| 44 | else | ||
| 45 | GDB_OPT= | ||
| 46 | fi | ||
| 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" | ||
| 50 | qemu-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 | |||
| 3 | import os | ||
| 4 | import sys | ||
| 5 | import shutil | ||
| 6 | |||
| 7 | def 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 | |||
| 20 | if __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 | ||
| 5 | SSH_PORT=1234 # CHANGE THIS | ||
| 6 | GDB_PORT=4321 # CHANGE THIS | ||
| 7 | SSH_HOST=localhost | ||
| 8 | |||
| 9 | # for pull | ||
| 10 | DATA_DIR="~/liblitmus2010/traces/" | ||
| 11 | FILE_GLOB="*" | ||
| 12 | DOWNLOADS=~/downloads | ||
| 13 | |||
| 14 | # for push | ||
| 15 | HOST_LIBLITMUS_DIR=~/dev/liblitmus2010 | ||
| 16 | KVM_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 | |||
| 3 | import sys | ||
| 4 | import re | ||
| 5 | |||
| 6 | comment_re = re.compile(r'([^\\]|^)%') | ||
| 7 | input_re = re.compile(r'\\input\{([^}]*)\}') | ||
| 8 | |||
| 9 | def 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 | |||
| 17 | def chomp(line): | ||
| 18 | if line and line[-1] == '\n': | ||
| 19 | return line[:-1] | ||
| 20 | else: | ||
| 21 | return line | ||
| 22 | |||
| 23 | def 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 | |||
| 31 | def 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 | |||
| 46 | def main(args=sys.argv[1:]): | ||
| 47 | for fname in args: | ||
| 48 | process_file(fname) | ||
| 49 | |||
| 50 | if __name__ == '__main__': | ||
| 51 | main() | ||
