summaryrefslogtreecommitdiffstats
path: root/kvm-run-kernel.sh
diff options
context:
space:
mode:
Diffstat (limited to 'kvm-run-kernel.sh')
-rwxr-xr-xkvm-run-kernel.sh48
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
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
48qemu-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