Commit ea15cec7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 848b5f51
#!/bin/sh -e
# qemu-runlinux <kernel> <program> ...
# qemu-runlinux [options] <kernel> <program> ...
# run kernel in QEMU with root fs taken from host
#
# Useful to test/debug just compiled kernel via running programs
......@@ -7,7 +7,6 @@
# pid=1: we are running inside booted kernel as init.
# mount /sys /proc etc and tail to the program.
qshutdown() {
echo 1 >/proc/sys/kernel/sysrq
echo o >/proc/sysrq-trigger # shutdown
......@@ -58,12 +57,33 @@ if [ $$ == 1 ]; then
qdie "unreachable"
fi
# ----------------------------------------
die() {
echo "$*" 1>&2
exit 1
}
nographic=y
while test $# != 0
do
case "$1" in
-g)
nographic=;;
*)
break;;
esac
shift
done
kernel=$1
arch=`uname -m`
test -z "$kernel" && kernel=arch/$arch/boot/bzImage
test -n "$kernel" || die "kernel not specified"
shift
prog="$@"
test -n "$prog" || die "program not specified"
dir=`pwd`
......@@ -85,9 +105,10 @@ dir=`pwd`
# References
# http://unix.stackexchange.com/questions/90423/can-virtfs-9p-be-used-as-root-file-system
# http://stackoverflow.com/questions/11408041/kernel-debugging-with-gdb-and-qemu
arch=`uname -m`
qemu-system-$arch \
-enable-kvm \
-nographic \
${nographic:+-nographic} \
\
-m 512M `# default 128M is too limiting` \
\
......@@ -96,7 +117,7 @@ qemu-system-$arch \
\
-kernel $kernel \
-append "ro rootfstype=9p rootflags=trans=virtio \
console=ttyS0 init="$(realpath $0)" \
${nographic:+console=ttyS0} init="$(realpath $0)" \
CWD="$dir" HOME="$HOME" LANG="$LANG" TERM="$TERM" PATH="$PATH" \
-- $prog \
"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment