tests: Optionally start telnet server inside VMs
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'. Please note that this provides unauthenticated access to the guest system from anything that can open a TCP connection on the host system. The guess system does have access to reading all files on the host that the user account running kvm has access to (and even write access if the default ROTAG ,readonly parameter is cleared). In other words, this option should not be used on any multiuser systems where kvm is run under user accounts that are not dedicated for testing purposes (i.e., do not have access to any files that should not be readable to everyone). This needs CONFIG_VIRTIO_NET=y in the guest kernel. 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@intel.com>
This commit is contained in:
parent
b0797ec955
commit
e339511007
3 changed files with 38 additions and 1 deletions
|
@ -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 <<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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue