to have a serial port as telnet if available use only
args: -chardev socket,id=serial0,port=[insert your tcp port in here],host=0.0.0.0,server,nowait,telnet -device isa-serial,chardev=serial0
i would like to have the tcp port number automatically created out of the vmid but it doesnt look like this is automatically possible
if your host is often migrated between different hosts or you dont know the host or you dont have direct access rights create a telnet proxy in the middle.
socat will do the job
pBase == 11
function tcpClient() {
re=0
while true
do
APINODE=$(getApiHostFunction)
node=$(curl --silent --insecure --cookie "$(<cookie)" --header "$(<csrftoken)" -X GET
https://$APINODE:8006/api2/json/cluster/resources?type=vm | jq --raw-output ".[] | .[] | select(.vmid==$vmid) | .node " )
if [ "$re" -eq 0 ]
then
echo "server connection start session for vm with id ${vmid} on $node (TCP:$node:${pBase}${vmid}) "
else
echo "server connection terminated restart session for vm with id ${vmid} on $node (TCP:$node:${pBase}${vmid})"
fi
re=1
socat -L /tmp/$vmid.lock.so TCP:$node:${pBase}${vmid} PIPE:/tmp/${vmid}in,ignoreeof\!\!PIPE:/tmp/${vmid}out,ignoreeof
done
}
tcpClient &
socat -t2 TCP-LISTEN:10${vmid},reuseaddr,fork PIPE:/tmp/${vmid}out,nonblock=1,ignoreeof\!\!PIPE:/tmp/${vmid}in,nonblock=1,ignoreeof
its just a stub of a longer script but mainly two socat connects to named pipes locally
and remote to the proxmox server where the vm $vmid is currently running
the telnet server is listen and waiting for telnet access to the vm console port.