Skip to content

Instantly share code, notes, and snippets.

@Jimmy-Xu
Forked from nlm/connect-qemu-serial.sh
Created April 5, 2017 08:22
Show Gist options
  • Save Jimmy-Xu/cccc7770907bba5097830b4bb75f4dd3 to your computer and use it in GitHub Desktop.
Save Jimmy-Xu/cccc7770907bba5097830b4bb75f4dd3 to your computer and use it in GitHub Desktop.
Connect to QEMU unix socket serial port
#!/bin/sh
SOCKDIR="/var/lib/qemu/sockets"
HOSTNAME="$1"
if [ -z "$HOSTNAME" ]
then
echo "usage: $0 HOSTNAME" >&2
exit 1
fi
SOCKET="${SOCKDIR}/serial.${HOSTNAME}.socket"
if [ ! -e "${SOCKET}" ]
then
echo "error: socket ${SOCKET} does not exist" >&2
exit 1
fi
echo "Starting Console... (ctrl+q to quit)"
exec socat stdin,raw,echo=0,escape=0x11 "unix-connect:${SOCKET}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment