Skip to content

Commit

Permalink
riscv64: Improve command forwarding
Browse files Browse the repository at this point in the history
Previous implementation uses `netcat` to test existence of
pre-configured target port, but that port is occupied in advance of
`sshd` inside VM is ready.

Replace `netcat` with `ssh` with `ConnectTimeout` set to directly verify
the connectivity of `sshd`.

Signed-off-by: Ruoqing He <[email protected]>
  • Loading branch information
TimePrinciple authored and roypat committed Sep 30, 2024
1 parent 3518bf4 commit 5ad7c27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion riscv64/build_finalize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apt-get update

DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
openssh-client libslirp-dev libfdt-dev libglib2.0-dev libssl-dev \
libpixman-1-dev netcat
libpixman-1-dev

# Modify fstab to mount `tmpfs` during boot
# See: https://wiki.qemu.org/Documentation/9p_root_fs#Let's_start_the_Installation
Expand Down
7 changes: 4 additions & 3 deletions riscv64/start_in_qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ cp -a $WORKDIR $ROOTFS_DIR/root

HOST=riscv-qemu

while ! nc -z localhost 2222; do
echo "Dialing qemu-system-riscv64..."
sleep 1
echo "Testing SSH connectivity to $HOST..."
while ! ssh -o ConnectTimeout=3 $HOST exit; do
echo "$HOST is not ready..."
done

# Issue command
COMMAND=$@
echo "$HOST is ready, forwarding command: $COMMAND"
ssh $HOST "export PATH=\"\$PATH:/root/.cargo/bin\" && cd workdir && $COMMAND"

0 comments on commit 5ad7c27

Please sign in to comment.