diff options
Diffstat (limited to 'kvm-run-kernel.sh')
| -rwxr-xr-x | kvm-run-kernel.sh | 48 |
1 files changed, 48 insertions, 0 deletions
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 | ||
