From: Johannes Berg <johannes.berg@xxxxxxxxx> If telnetd is installed and --telnet <port> is passed on the vm-run.sh command line, start a telnet server (directly connected to bash, no login) inside the VM(s) to be able to look into them when something is wrong. Use a user network in qemu with a single host forward from the specified port for this, listening only on 'localhost'. For parallel-vm.py, the --telnet argument specifies the base port and each VM index (0, 1, ...) is added to it. Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx> --- tests/hwsim/vm/inside.sh | 25 +++++++++++++++++++++++++ tests/hwsim/vm/parallel-vm.py | 4 ++++ tests/hwsim/vm/vm-run.sh | 10 +++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh index 6cb6f76f0d8e..22620c13328e 100755 --- a/tests/hwsim/vm/inside.sh +++ b/tests/hwsim/vm/inside.sh @@ -15,6 +15,10 @@ mount sysfs -t sysfs /sys # needed for tracing mount debugfs -t debugfs /sys/kernel/debug +# for inside telnet +mkdir /dev/pts +mount devpts -t devpts /dev/pts + export PATH=/usr/sbin:$PATH # reboot on any sort of crash @@ -25,10 +29,12 @@ sysctl kernel.panic=1 TESTDIR=$(sed 's/.*testdir=\([^ ]*\) .*/\1/' /proc/cmdline) TIMEWARP=$(sed 's/.*timewarp=\([^ ]*\) .*/\1/' /proc/cmdline) EPATH=$(sed 's/.*EPATH=\([^ ]*\) .*/\1/' /proc/cmdline) +TELNET=$(sed 's/.*TELNET=\([^ ]*\) .*/\1/' /proc/cmdline) ARGS=$(sed 's/.*ARGS=\([^ ]*\)\( \|$\).*/\1/' /proc/cmdline) # create /dev entries we need mknod -m 660 /dev/ttyS0 c 4 64 +mknod -m 666 /dev/ptmx c 5 2 mknod -m 660 /dev/random c 1 8 mknod -m 660 /dev/urandom c 1 9 mknod -m 666 /dev/null c 1 3 @@ -98,8 +104,27 @@ if [ "$TIMEWARP" = "1" ] ; then ) & fi +echo hwsimvm > /proc/sys/kernel/hostname echo 8 8 8 8 > /proc/sys/kernel/printk +cat > /tmp/bin/login <<EOF +#!/bin/sh + +export PS1='\h:\w\$ ' +exec bash +EOF +chmod +x /tmp/bin/login + +if [ "$TELNET" = "1" ] ; then + ip link set eth0 up + ip addr add 172.16.0.15/24 dev eth0 + which in.telnetd >/dev/null && ( + while true ; do + in.telnetd -debug 23 -L /tmp/bin/login + done + ) & +fi + # check if we're rebooting due to a kernel panic ... if grep -q 'Kernel panic' /tmp/logs/console ; then echo "KERNEL CRASHED!" >/dev/ttyS0 diff --git a/tests/hwsim/vm/parallel-vm.py b/tests/hwsim/vm/parallel-vm.py index c9baf5a6c2e1..cf7f8df65802 100755 --- a/tests/hwsim/vm/parallel-vm.py +++ b/tests/hwsim/vm/parallel-vm.py @@ -356,6 +356,8 @@ def main(): p.add_argument('--valgrind', dest='valgrind', action='store_const', const=True, default=False, help="run tests under valgrind") + p.add_argument('--telnet', dest='telnet', metavar='<baseport>', type=int, + help="enable telnet server inside VMs, specify the base port here") p.add_argument('params', nargs='*') args = p.parse_args() @@ -435,6 +437,8 @@ def main(): '--timestamp', str(timestamp), '--ext', 'srv.%d' % (i + 1), '-i'] + codecov_args + extra_args + if args.telnet: + cmd += [ '--telnet', str(args.telnet + i) ] vm[i] = {} vm[i]['first_run_done'] = False vm[i]['proc'] = subprocess.Popen(cmd, diff --git a/tests/hwsim/vm/vm-run.sh b/tests/hwsim/vm/vm-run.sh index 2972fb1b0786..0f393e4e1288 100755 --- a/tests/hwsim/vm/vm-run.sh +++ b/tests/hwsim/vm/vm-run.sh @@ -51,6 +51,8 @@ TIMESTAMP=$(date +%s) DATE=$TIMESTAMP CODECOV=no TIMEWARP=0 +TELNET_QEMU= +TELNET_ARG=0 DELAY=0 CODECOV_DIR= while [ "$1" != "" ]; do @@ -73,6 +75,11 @@ while [ "$1" != "" ]; do --timewrap ) shift TIMEWARP=1 ;; + --telnet ) shift + TELNET_ARG=1 + TELNET_QEMU="-net nic,model=virtio -net user,id=telnet,ipv6=off,restrict=on,net=172.16.0.0/24,hostfwd=tcp:127.0.0.1:$1-:23" + shift + ;; --delay ) shift DELAY=$1 shift @@ -134,7 +141,8 @@ $KVM \ -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \ -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \ -monitor null -serial stdio -serial file:$LOGDIR/console \ - -append "mac80211_hwsim.support_p2p_device=0 mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=7 cfg80211.dyndbg=+p mac80211.dyndbg=+p mac80211_hwsim.dyndbg=+p init=$CMD testdir=$TESTDIR timewarp=$TIMEWARP console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$argsfile" | \ + $TELNET_QEMU \ + -append "mac80211_hwsim.support_p2p_device=0 mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=7 cfg80211.dyndbg=+p mac80211.dyndbg=+p mac80211_hwsim.dyndbg=+p init=$CMD testdir=$TESTDIR timewarp=$TIMEWARP TELNET=$TELNET_ARG console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$argsfile" | \ sed -u '0,/VM has started up/d' if [ $CODECOV = "yes" ]; then -- 2.17.2 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap