[SOLVED] how can i add a serial port config to a vm via conf file

immo

Renowned Member
Nov 20, 2014
92
0
71
is there a waz to permanently connect a serial port to a vm?

If possible can I create also some provide a telnet or ssh access to this serial line ?
As result we like to have a telnet to see the linux vm upcoming on the serial interface via telnet from a different host.
 
so serial is working with qm terminal
but how to use args to modify the chardev part proxmox creates
-chardev 'socket,id=serial0,path=/var/run/qemu-server/384.serial0,server,nowait'

do I have to configure the whole serial part as args lines ?
 
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.