Commit ea15cec7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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