Message ID | 20190203205606.7709-1-johannes@sipsolutions.net |
---|---|
State | Changes Requested |
Headers | show |
Series | tests: hwsim: start telnet server inside VMs | expand |
On Sun, 2019-02-03 at 21:56 +0100, Johannes Berg wrote: > From: Johannes Berg <johannes.berg@intel.com> > > If telnetd is installed, start it 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 ports 4000 > (and higher for parallel-vm) for this. Please drop this for now. It was very useful and helped me debug a bunch of test setup issues yesterday, but having it by default is annoying because then you can't run two manual "vm-run.sh" scripts in parallel without specifying --num, which doesn't make sense... so I guess this should be opt-in by passing --telnet or something. johannes
On Mon, Feb 04, 2019 at 01:28:02PM +0100, Johannes Berg wrote: > On Sun, 2019-02-03 at 21:56 +0100, Johannes Berg wrote: > > If telnetd is installed, start it 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 ports 4000 > > (and higher for parallel-vm) for this. > > Please drop this for now. It was very useful and helped me debug a bunch > of test setup issues yesterday, but having it by default is annoying > because then you can't run two manual "vm-run.sh" scripts in parallel > without specifying --num, which doesn't make sense... so I guess this > should be opt-in by passing --telnet or something. In addition, it produced this on Ubuntu 16.04: qemu-system-x86_64: -nic: invalid option We also have the comment out bash call in the end of inside.sh. I've used that whenever wanting to do something at the end of a test case. I guess telnetd would be nice for allowing access at any point in time, so it might make sense to enable it with a vm-run.sh option.
On Tue, 2019-02-05 at 12:51 +0200, Jouni Malinen wrote: > > In addition, it produced this on Ubuntu 16.04: > qemu-system-x86_64: -nic: invalid option Oh. I guess that can be fixed by not using the combined -nic option, I'll have to look up how but shouldn't be hard. The more annoying part is that it won't start up if it can't listen on the socket. > We also have the comment out bash call in the end of inside.sh. I've > used that whenever wanting to do something at the end of a test case. I > guess telnetd would be nice for allowing access at any point in time, so > it might make sense to enable it with a vm-run.sh option. Yes. I actually removed this call ;-) In this case, I was debugging the 'sed' patch and trying to figure out why no tests were starting though. So I guess a parallel-vm.py option too. johannes
diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh index ac01d411c3b2..3130557dfcfd 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 @@ -29,6 +33,7 @@ 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 @@ -96,8 +101,25 @@ 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 + +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 +) & + # 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..34d8d5505085 100755 --- a/tests/hwsim/vm/parallel-vm.py +++ b/tests/hwsim/vm/parallel-vm.py @@ -433,7 +433,7 @@ def main(): logger.info("Starting virtual machine {}/{}".format(i + 1, num_servers)) cmd = [os.path.join(scriptsdir, 'vm-run.sh'), '--delay', str(i), '--timestamp', str(timestamp), - '--ext', 'srv.%d' % (i + 1), + '--num', '%d' % (i + 1), '-i'] + codecov_args + extra_args vm[i] = {} vm[i]['first_run_done'] = False diff --git a/tests/hwsim/vm/vm-run.sh b/tests/hwsim/vm/vm-run.sh index 67168da9b08c..40d6bfb76db8 100755 --- a/tests/hwsim/vm/vm-run.sh +++ b/tests/hwsim/vm/vm-run.sh @@ -32,6 +32,9 @@ KVMOUT=ttyS1 # number of channels each hwsim device supports CHANNELS=1 +# telnet (for debug) base port +BASEPORT=4000 + test -f vm-config && . vm-config test -f ~/.wpas-vm-config && . ~/.wpas-vm-config @@ -53,14 +56,16 @@ CODECOV=no TIMEWARP=0 DELAY=0 CODECOV_DIR= +PORT=$BASEPORT while [ "$1" != "" ]; do case $1 in --timestamp ) shift TIMESTAMP=$1 shift ;; - --ext ) shift - DATE=$TIMESTAMP.$1 + --num ) shift + DATE=$TIMESTAMP.srv.$1 + PORT=$(( $BASEPORT + $1 - 1 )) shift ;; --codecov ) shift @@ -134,6 +139,7 @@ $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 \ + -nic user,ipv6=off,model=virtio-net-pci,restrict=on,net=172.16.0.0/24,hostfwd=tcp:127.0.0.1:$PORT-:23 \ -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" | \ sed -u '1,/running inside a VM/d'