Serial Terminal (VM/Qemu)

Ramalama

Well-Known Member
Dec 26, 2020
851
197
53
35
Hi everybody.

Does anyone has maybe some fixes Tipps for the Serial Terminal for VM's (Qemu), like Ubuntu/Debian etc?

Because:
-> Serial Terminal on LXC Containers is pretty perfect, you can resize windows etc, everything is perfect...
-> Serial Terminal on VM's is horrible, you can resize either but most of the times something start to glitch... If you don't resize and stay with the default (small) Windows, its works well for a quite time, but at some point it fucks up too and you have to restart the console xD

It starts to nerv me, basically it never gotten better since PVE6 (i dont know PVE5 and before xD).
It nerved already since forever on Opnsense/PFsense VM's, but now i have a situation where i need to work over the Serial Terminal with an Ubuntu 24.04 VM.

Maybe someone knows some tunings etc...
Cheers :)
 
I configured it via ‘/etc/default/grub’

Code:
GRUB_CMDLINE_LINUX_DEFAULT="quiet console=ttyS0,115200"

It's not particularly pretty. It works better if you log in to the Proxmox VE host with root and open the console of the VM from there.
Code:
qm terminal <vmid>
 
  • Like
Reactions: BobhWasatch
Because:
-> Serial Terminal on LXC Containers is pretty perfect, you can resize windows etc, everything is perfect...
-> Serial Terminal on VM's is horrible, you can resize either but most of the times something start to glitch... If you don't resize and stay with the default (small) Windows, its works well for a quite time, but at some point it fucks up too and you have to restart the console xD
Serial terminal on containers is really just the LXC console. There is no emulation of RS-232, it acts more like a network connection. It can support lots of features that a real serial terminal can't.

Serial terminal on a VM is using a virtual RS-232 port. It has all of the limitations of a real serial port. As far as the VM is concerned it is a real serial port.

There is no out-of-band signaling, which means no environment variable passthrough and no terminal size change signal. It is the functional equivalent of connecting a vintage VT-100 which has a fixed number of rows and columns.

Terminal commands like "change color" and "move cursor" are handled by in-band "escape codes". The "glitching" is almost always caused by the user having written something to the screen that the terminal emulator interprets as a command. Something like "cat binary-file" will do it. The "reset" command can help get out of this.


It starts to nerv me, basically it never gotten better since PVE6 (i dont know PVE5 and before xD).
It isn't a PVE problem it is a limitation of serial terminals as I described above. There are some environment variables you can set:

Code:
export LINES=xx            # set number of lines
export COLUMNS=yy        # set number of columns
export TERM=xterm-256    # set terminal emulator type

There is no easy way to dynamically adjust window size. Somebody recently posted a login script snippet here that attempts to do that by employing some escape code tricks to measure the size after every command. Apparently it works but slows things down a lot. Don't have a reference, you'll have to search for it.

The limitation of this approach is that it won't work if you are in a full-screen application like nano and resize the window.
 
  • Like
Reactions: Ramalama and fireon
Serial terminal on containers is really just the LXC console. There is no emulation of RS-232, it acts more like a network connection. It can support lots of features that a real serial terminal can't.

Serial terminal on a VM is using a virtual RS-232 port. It has all of the limitations of a real serial port. As far as the VM is concerned it is a real serial port.

There is no out-of-band signaling, which means no environment variable passthrough and no terminal size change signal. It is the functional equivalent of connecting a vintage VT-100 which has a fixed number of rows and columns.

Terminal commands like "change color" and "move cursor" are handled by in-band "escape codes". The "glitching" is almost always caused by the user having written something to the screen that the terminal emulator interprets as a command. Something like "cat binary-file" will do it. The "reset" command can help get out of this.



It isn't a PVE problem it is a limitation of serial terminals as I described above. There are some environment variables you can set:

Code:
export LINES=xx            # set number of lines
export COLUMNS=yy        # set number of columns
export TERM=xterm-256    # set terminal emulator type

There is no easy way to dynamically adjust window size. Somebody recently posted a login script snippet here that attempts to do that by employing some escape code tricks to measure the size after every command. Apparently it works but slows things down a lot. Don't have a reference, you'll have to search for it.

The limitation of this approach is that it won't work if you are in a full-screen application like nano and resize the window.
Couldn't you use a real serial terminal emulator (like for AS400 etc.) for something similar? It's been a long time, but I just remembered that...
 
Serial terminal on containers is really just the LXC console. There is no emulation of RS-232, it acts more like a network connection. It can support lots of features that a real serial terminal can't.

Serial terminal on a VM is using a virtual RS-232 port. It has all of the limitations of a real serial port. As far as the VM is concerned it is a real serial port.

There is no out-of-band signaling, which means no environment variable passthrough and no terminal size change signal. It is the functional equivalent of connecting a vintage VT-100 which has a fixed number of rows and columns.

Terminal commands like "change color" and "move cursor" are handled by in-band "escape codes". The "glitching" is almost always caused by the user having written something to the screen that the terminal emulator interprets as a command. Something like "cat binary-file" will do it. The "reset" command can help get out of this.



It isn't a PVE problem it is a limitation of serial terminals as I described above. There are some environment variables you can set:

Code:
export LINES=xx            # set number of lines
export COLUMNS=yy        # set number of columns
export TERM=xterm-256    # set terminal emulator type

There is no easy way to dynamically adjust window size. Somebody recently posted a login script snippet here that attempts to do that by employing some escape code tricks to measure the size after every command. Apparently it works but slows things down a lot. Don't have a reference, you'll have to search for it.

The limitation of this approach is that it won't work if you are in a full-screen application like nano and resize the window.
Thanks for the explanation.
Yeah i do serial connections with switches and i have sometimes the same issues there xD

I just hoped that anyone knows maybe something like another emular type that we can set on the vm, to improve things a little. Something in this direction at least.
But i didn't knew about the "reset" command! Thats very helpfull already!! Thanks!
 
What I remembered... a few things can be set up for the xterm.js:

Screenshot_20240904_091651.png
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!