diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-09-22 11:52:52 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-09-22 11:52:52 -0400 |
commit | 5ec00aab69673833ed82d33b132e1e54d5401249 (patch) | |
tree | 0b203f4ce1408d221df85880ce2a3f8b8b08eb66 | |
parent | f03d628e1e8bcdbf36aa28e23ca5266e7bafef12 (diff) |
Add KVM helper scripts.
Useful for pushing and pull files, as well as launching kernels.
-rwxr-xr-x | kvm-pull-traces.sh | 25 | ||||
-rwxr-xr-x | kvm-push-liblitmus.sh | 25 | ||||
-rwxr-xr-x | kvm-run-kernel.sh | 48 | ||||
-rw-r--r-- | sample-config/litmus-kvm | 16 |
4 files changed, 114 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..5470ba5 --- /dev/null +++ b/kvm-run-kernel.sh | |||
@@ -0,0 +1,48 @@ | |||
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 | 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/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="~/" | ||