Telnet ports for the VMs are now randomized
This commit is contained in:
parent
0cd7bc791e
commit
54f3a2eb0a
17
autobuild
17
autobuild
|
@ -209,22 +209,27 @@ function start_build_vm() {
|
|||
## IE, if we want to build using the VM stored in ./build-farm/debian-stable-arm64
|
||||
## Then we would set ARCHDIR="debian-stable-arm64"
|
||||
local ARCHDIR=""
|
||||
|
||||
SSHPORT=$(get_random_free_port)
|
||||
TELNETPORT=$(get_random_free_port) # FIXME: Tiny possibility of the two calls generating the same port number
|
||||
|
||||
if [[ "$ARCH" == "i386" ]]; then
|
||||
ARCHDIR="debian-stable-i386"
|
||||
|
||||
SSHPORT=$(get_random_free_port)
|
||||
|
||||
boot_vm_nodisplay "$ARCH" "$buildfarmdir/$ARCHDIR/image.qcow" "$SSHPORT" &
|
||||
boot_vm_nodisplay "$ARCH" "$buildfarmdir/$ARCHDIR/image.qcow" "$SSHPORT" "$TELNETPORT" &
|
||||
|
||||
elif [[ "$ARCH" == "arm64" ]]; then
|
||||
ARCHDIR="debian-stable-arm64"
|
||||
|
||||
SSHPORT=$(get_random_free_port)
|
||||
|
||||
boot_vm_nodisplay "aarch64" "$buildfarmdir/$ARCHDIR/image.qcow" "$SSHPORT" &
|
||||
boot_vm_nodisplay "aarch64" "$buildfarmdir/$ARCHDIR/image.qcow" "$SSHPORT" "$TELNETPORT" &
|
||||
# Perhaps we should rename 'arm64' to 'aarch64' within Autobuild for consistency with the way Debian names things?
|
||||
fi
|
||||
|
||||
echo "---"
|
||||
echo "$ARCH VM started. You can connect to it (if you want) as follows:"
|
||||
echo " SSH Port: $SSHPORT"
|
||||
echo " TELNET Port: $TELNETPORT"
|
||||
echo "---"
|
||||
|
||||
sshpass -p $SSHPASSWORD ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -tt -p $SSHPORT $SSHUSER@127.0.0.1 >/dev/null 2>&1 << EOF
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ boot-install: image.qcow
|
|||
@echo "It may take a few minutes for the installer to get to that point.\n"
|
||||
@echo "Alternatively connect to the serial console:\n"
|
||||
@echo " telnet localhost 33333\n"
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh &
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh 33333 &
|
||||
${QEMU} -m 2048 \
|
||||
-machine virt \
|
||||
-cpu cortex-a53 \
|
||||
|
@ -113,7 +113,7 @@ boot-install: image.qcow
|
|||
-serial telnet:localhost:33333,server,nowait
|
||||
|
||||
boot-run:
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh &
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh 33333 &
|
||||
${QEMU} -m 2048 \
|
||||
-machine virt \
|
||||
-cpu cortex-a53 \
|
||||
|
|
|
@ -92,7 +92,7 @@ boot-install: image.qcow
|
|||
@echo "It may take a few minutes for the installer to get to that point.\n"
|
||||
@echo "Alternatively connect to the serial console:\n"
|
||||
@echo " telnet localhost 33333\n"
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh &
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh 33333 &
|
||||
${QEMU} -m 2048 \
|
||||
-accel kvm \
|
||||
-net user,hostfwd=tcp::22222-:22 \
|
||||
|
@ -102,7 +102,7 @@ boot-install: image.qcow
|
|||
-cdrom ${TARGET}
|
||||
|
||||
boot-run:
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh &
|
||||
@x-terminal-emulator -e /usr/share/autobuild/build-farm/view-progress.sh 33333 &
|
||||
${QEMU} -m 2048 \
|
||||
-accel kvm \
|
||||
-net user,hostfwd=tcp::22222-:22 \
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
|
||||
function boot_vm() {
|
||||
|
||||
if [[ $# != 5 ]]; then
|
||||
if [[ $# != 6 ]]; then
|
||||
echo "bad args to boot_vm"
|
||||
exit
|
||||
fi
|
||||
|
||||
local QEMU="$1" IMAGE="$2" MEMORY="$3" ACCEL="$4" SSHPORT="$5"
|
||||
local QEMU="$1" IMAGE="$2" MEMORY="$3" ACCEL="$4" SSHPORT="$5" TELNET_PORT="$6"
|
||||
|
||||
IMAGE_DIRECTORY=$(dirname "$IMAGE")
|
||||
|
||||
QEMU_COMMAND=""
|
||||
|
||||
# I hate this. So much.
|
||||
# TODO: Either git rid of the telnet deal (without screwing up the user's terminal window), or randomize the telnet port like we do with the SSH port.
|
||||
if [[ "$QEMU" == "qemu-system-aarch64" ]]; then
|
||||
|
||||
QEMU_COMMAND="$QEMU -m $MEMORY \
|
||||
|
@ -29,7 +28,7 @@ function boot_vm() {
|
|||
-net user,hostfwd=tcp::$SSHPORT-:22 \
|
||||
-net nic \
|
||||
-drive if=virtio,file=$IMAGE_DIRECTORY/image.qcow,format=qcow2,id=hd \
|
||||
-serial telnet:localhost:33333,server,nowait \
|
||||
-serial telnet:localhost:$TELNET_PORT,server,nowait \
|
||||
-nographic"
|
||||
else
|
||||
QEMU_COMMAND="$QEMU -m $MEMORY \
|
||||
|
@ -37,7 +36,7 @@ function boot_vm() {
|
|||
-net user,hostfwd=tcp::$SSHPORT-:22 \
|
||||
-net nic \
|
||||
-hda $IMAGE \
|
||||
-serial telnet:localhost:33333,server,nowait \
|
||||
-serial telnet:localhost:$TELNET_PORT,server,nowait \
|
||||
-nographic"
|
||||
fi
|
||||
|
||||
|
@ -48,12 +47,12 @@ function boot_vm() {
|
|||
|
||||
function boot_vm_nodisplay() {
|
||||
|
||||
if [[ $# != 3 ]]; then
|
||||
if [[ $# != 4 ]]; then
|
||||
echo "bad args to boot_vm_nodisplay"
|
||||
exit
|
||||
fi
|
||||
|
||||
local ARCH="$1" IMAGE="$2" SSH_PORT="$3"
|
||||
local ARCH="$1" IMAGE="$2" SSH_PORT="$3" TELNET_PORT="$4"
|
||||
|
||||
BOOT_SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||
|
||||
|
@ -65,7 +64,7 @@ function boot_vm_nodisplay() {
|
|||
MEMORY_TO_USE=$(get_vm_memory)
|
||||
|
||||
# Try with KVM acceleration
|
||||
boot_vm "$QEMU" "$IMAGE" "$MEMORY_TO_USE" "$ACCEL_OPTION" "$SSH_PORT" &
|
||||
boot_vm "$QEMU" "$IMAGE" "$MEMORY_TO_USE" "$ACCEL_OPTION" "$SSH_PORT" "$TELNET_PORT" &
|
||||
|
||||
qemu_pid=$!
|
||||
|
||||
|
@ -75,6 +74,6 @@ function boot_vm_nodisplay() {
|
|||
# Try without KVM acceleration
|
||||
echo "Booting VM with KVM acceleration failed. Trying without KVM..."
|
||||
ACCEL_OPTION="-accel tcg"
|
||||
boot_vm "$QEMU" "$IMAGE" "$MEMORY_TO_USE" "$ACCEL_OPTION" "$SSH_PORT" &
|
||||
boot_vm "$QEMU" "$IMAGE" "$MEMORY_TO_USE" "$ACCEL_OPTION" "$SSH_PORT" "$TELNET_PORT" &
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/bin/sh
|
||||
sleep 5; telnet localhost 33333
|
||||
port=$1
|
||||
until (telnet localhost "$port"); do sleep 5; done
|
||||
exec "exit"
|
||||
|
|
Loading…
Reference in New Issue