From d975eb8b04087f8606d881d527d02e75f97c6243 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Mon, 26 Apr 2021 12:07:15 +0200 Subject: v7a: run: make the SSH forwarding port multiprocess-compatible When multiple ./configs/platform-v7a/run scripts are run at the same time, the first qemu process will open port 4445, and following runs will fail. To prevent that, first look at the environment variable QEMU_SSH_PORT to determine the port to be used (so that users can set this in their shell to keep the port constant), or fall back to a port between 1025 and 65025 based on the shell's PID, which should have a good chance of choosing an unused, but stable port. Also print the port forwarding before starting qemu, so we don't have to bother about grepping the process list. Signed-off-by: Roland Hieber Link: https://lore.pengutronix.de/20210426100714.10944-1-rhi@pengutronix.de Signed-off-by: Robert Schwebel --- configs/platform-v7a/run | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'configs') diff --git a/configs/platform-v7a/run b/configs/platform-v7a/run index ed8ab1b..8af190f 100755 --- a/configs/platform-v7a/run +++ b/configs/platform-v7a/run @@ -39,7 +39,7 @@ fi # the port to which an sshd would connect (in the emulated sysem) SSH_INTERNAL_PORT=22 # the port which QEMU opens at the host side to give access to the ${SSH_INTERNAL_PORT} -SSH_EXTERNAL_PORT=4445 +SSH_EXTERNAL_PORT=${QEMU_SSH_PORT:-${PPID%64000+1025}} # check if vde is available for networking if [ -z "${VDE_SOCKET}" ]; then @@ -59,6 +59,7 @@ fi # fall back to user network if necessary if [ -z "${QEMU_NET}" ]; then QEMU_NET=(-netdev user,id=net1,hostfwd=tcp:127.0.0.1:${SSH_EXTERNAL_PORT}-:${SSH_INTERNAL_PORT} ) + echo "Forwarding SSH port 127.0.0.1:${SSH_EXTERNAL_PORT} -> qemu:${SSH_INTERNAL_PORT}" fi BASE_CMDLINE="console=ttyAMA0,115200 loglevel=5 systemd.log_level=warning systemd.show_status=auto" -- cgit v1.2.3