diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh index accc0ddec..c22289cc3 100755 --- a/tests/hwsim/vm/inside.sh +++ b/tests/hwsim/vm/inside.sh @@ -12,6 +12,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 @@ -22,10 +26,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 @@ -92,8 +98,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 </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 c9baf5a6c..cf7f8df65 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='', 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 2972fb1b0..c68e5568d 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,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