Commit 208aca62 authored by Kirill Smelkov's avatar Kirill Smelkov

t/qemu-runlinux: Kernel verbosity control via -v

	0: ERROR+ on boot/run
	1: INFO+  on      run
	2: INFO+  on boot/run
	3: DEBUG+ on boot/run

It is convenient not to see large kernel boot log on every test run. "1"
(single -v) is also convenient: one can skip the boot log but still see
details of what is going on when test workload is run. -vv and -vvv are
there to see full picture.
parent a568d6d9
...@@ -32,7 +32,12 @@ ...@@ -32,7 +32,12 @@
# 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.
if [ $$ == 1 ]; then if [ $$ == 1 ]; then
echo "qinit ..." qinfo() {
test "$qrun_loglevel" -le 6 && return # <= KERN_INFO
echo "$*"
}
qinfo "qinit ..."
qshutdown() { qshutdown() {
echo 1 >/proc/sys/kernel/sysrq echo 1 >/proc/sys/kernel/sysrq
...@@ -47,11 +52,14 @@ if [ $$ == 1 ]; then ...@@ -47,11 +52,14 @@ if [ $$ == 1 ]; then
exit 1 # just in case exit 1 # just in case
} }
# mount proc early & set loglevel for run phase
mount -t proc none /proc
echo "$qrun_loglevel" >/proc/sys/kernel/printk
mount -t sysfs none /sys mount -t sysfs none /sys
mount -t debugfs none /sys/kernel/debug mount -t debugfs none /sys/kernel/debug
mount -t bpf none /sys/fs/bpf mount -t bpf none /sys/fs/bpf
mount -t fusectl none /sys/fs/fuse/connections mount -t fusectl none /sys/fs/fuse/connections
mount -t proc none /proc
mount -t devtmpfs none /dev mount -t devtmpfs none /dev
mkdir /dev/{pts,mqueue,hugepages,shm} mkdir /dev/{pts,mqueue,hugepages,shm}
...@@ -77,7 +85,7 @@ if [ $$ == 1 ]; then ...@@ -77,7 +85,7 @@ if [ $$ == 1 ]; then
#set -x #set -x
set +e set +e
setsid "$0" .qinit2 "$@" <>/dev/ttyS0 >&0 2>&1 # run qinit2 with argv[1:] passed to init setsid "$0" .qinit2 "$@" <>/dev/ttyS0 >&0 2>&1 # run qinit2 with argv[1:] passed to init
echo "exit code: $?" qinfo "exit code: $?"
qshutdown qshutdown
sleep 1d # give time to shutdown sleep 1d # give time to shutdown
...@@ -113,17 +121,32 @@ Run linux/program under QEMU with rootfs taken from host. ...@@ -113,17 +121,32 @@ Run linux/program under QEMU with rootfs taken from host.
Options: Options:
-v increase verbosity
0: ERROR+ on boot/run
1: INFO+ on run
2: INFO+ on boot/run
3: DEBUG+ on boot/run
-g run with graphics -g run with graphics
EOF EOF
} }
# by default output goes to stdout with both /dev/console and /dev/ttyS0 (where # by default output goes to stdout with both /dev/console and /dev/ttyS0 (where
# program is run) attached there. # program is run) attached there.
verbose=0
nographic=y nographic=y
while test $# != 0 while test $# != 0
do do
case "$1" in case "$1" in
-v)
verbose=$(($verbose + 1));;
-vv)
verbose=$(($verbose + 2));;
-vvv)
verbose=$(($verbose + 3));;
-g) # run with graphics UI, /dev/console goes to VGA; program to /dev/ttyS0 -g) # run with graphics UI, /dev/console goes to VGA; program to /dev/ttyS0
nographic=;; nographic=;;
-h) -h)
...@@ -145,6 +168,14 @@ test -n "$prog" || die "program not specified" ...@@ -145,6 +168,14 @@ test -n "$prog" || die "program not specified"
dir=`pwd` dir=`pwd`
# loglevel: default ERROR+ on boot/run
loglevel=4
qrun_loglevel=4
test $verbose -ge 1 && qrun_loglevel=7 # INFO+ on run
test $verbose -ge 2 && loglevel=7 # INFO+ on boot/run
test $verbose -ge 3 && loglevel=8 # DEBUG+ on boot/run
test $loglevel -gt 4 && qrun_loglevel=$loglevel
# may be also useful: # may be also useful:
# -serial stdio # -serial stdio
# -serial file:ttyS0 # -serial file:ttyS0
...@@ -175,7 +206,8 @@ qemu-system-$arch \ ...@@ -175,7 +206,8 @@ qemu-system-$arch \
\ \
-kernel $kernel \ -kernel $kernel \
-append "ro rootfstype=9p rootflags=trans=virtio \ -append "ro rootfstype=9p rootflags=trans=virtio \
${nographic:+console=ttyS0} init="$(realpath $0)" \ ${nographic:+console=ttyS0} loglevel=$loglevel qrun_loglevel=$qrun_loglevel \
init="$(realpath $0)" \
CWD="$dir" HOME="$HOME" LANG="$LANG" ${nographic:+TERM="$TERM"} PATH="$PATH" \ CWD="$dir" HOME="$HOME" LANG="$LANG" ${nographic:+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