From 5ec00aab69673833ed82d33b132e1e54d5401249 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 22 Sep 2010 11:52:52 -0400 Subject: Add KVM helper scripts. Useful for pushing and pull files, as well as launching kernels. --- kvm-pull-traces.sh | 25 +++++++++++++++++++++++++ kvm-push-liblitmus.sh | 25 +++++++++++++++++++++++++ kvm-run-kernel.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ sample-config/litmus-kvm | 16 ++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100755 kvm-pull-traces.sh create mode 100755 kvm-push-liblitmus.sh create mode 100755 kvm-run-kernel.sh create mode 100644 sample-config/litmus-kvm 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 @@ +#!/bin/bash +# +# Simple script to download files from a KVM image to the local system. +# Originally written by Andrea Bastoni. +# Config file support added by Bjoern Brandenburg. + +SSH_PORT=2222 # default +SSH_USER=root # what to log in as +SSH_HOST=localhost # where is the forwarded port? +DATA_DIR="~/liblitmus2010/" # where are the traces in the image? +FILE_GLOB="test*.bin" # which files to copy +DOWNLOADS=. # where to copy the files + +# include config file +[ -f ~/.litmus_kvm ] && source ~/.litmus_kvm + +#SRC="${SSH_USER}@${SSH_HOST}:${DATA_DIR}${FILE_GLOB}" +#echo scp -P $SSH_PORT ${SRC} ${DOWNLOADS} +#scp -P $SSH_PORT ${SRC} ${DOWNLOADS} + + +CMD="ssh -l ${SSH_USER} -p ${SSH_PORT}" +SRC="${SSH_HOST}:${DATA_DIR}${FILE_GLOB}" +echo rsync -ah -z --progress -e "$CMD" ${SRC} ${DOWNLOADS} +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 @@ +#!/bin/bash + +# +# Simple script to push a compiled version of liblitmus2010 to a KVM instance. +# Originally written by Andrea Bastoni. +# Config file support added by Bjoern Brandenburg. + +SSH_PORT=2222 # default +SSH_USER=root # what to log in as +SSH_HOST=localhost # where is the forwarded port? +HOST_LIBLITMUS_DIR="~/liblitmus2010" # where is the compilation unit +KVM_WORKSPACE="~/" # where to copy the files + +# include config file +[ -f ~/.litmus_kvm ] && source ~/.litmus_kvm + +#SRC="${SSH_USER}@${SSH_HOST}:${DATA_DIR}${FILE_GLOB}" +#echo scp -P $SSH_PORT ${SRC} ${DOWNLOADS} +#scp -P $SSH_PORT ${SRC} ${DOWNLOADS} + + +CMD="ssh -l ${SSH_USER} -p ${SSH_PORT}" +TARGET="${SSH_HOST}:${KVM_WORKSPACE}" +echo rsync -ah -z --progress -e "$CMD" ${HOST_LIBLITMUS_DIR} ${TARGET} +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 @@ +#!/bin/bash +# Launch a kernel with GDB support. +# Originally written by Andrea Bastoni. +# Config file support and option parsing added by Bjoern Brandenburg. + +function info() { + echo "(ii) $*" +} + +while true +do + case $1 in + --gdb) + shift + WANT_GDB=1 + ;; + *) # unknown argument + break + ;; + esac +done + +if [ $# -lt 2 ]; then + echo "Usage: run_kvm [--gdb] [other kernel parameters]" + exit 1 +fi + +SSH_PORT=2222 # default +GDB_PORT=6666 # override in config file +KVM_IMAGE=~/kvm_debian_images/debian_amd64_lib.qcow2 + +# include config file +[ -f ~/.litmus_kvm ] && source ~/.litmus_kvm + +info "Simulating $2 CPUs." +info "Running on top of image ${KVM_IMAGE}." +info "Launching kernel $1." +info "Redirecting SSH to port ${SSH_PORT}." + +if [ ! -z "$WANT_GDB" ] +then + info "Opening remote GDB port ${GDB_PORT}." + GDB_OPT="-gdb tcp::${GDB_PORT} -S" +else + GDB_OPT= +fi + +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 @@ +# Simple Litmus KVM tools config file. +# Copy this to ~/.litmus_kvm + +# how to connect to the VM +SSH_PORT=1234 # CHANGE THIS +GDB_PORT=4321 # CHANGE THIS +SSH_HOST=localhost + +# for pull +DATA_DIR="~/liblitmus2010/traces/" +FILE_GLOB="*" +DOWNLOADS=~/downloads + +# for push +HOST_LIBLITMUS_DIR=~/dev/liblitmus2010 +KVM_WORKSPACE="~/" -- cgit v1.2.2