Summary of The Series --------------------- This series adds terminal size support to the virtio-console device. The goal is to make it possible to get a resizable terminal into a guest without using e.g. ssh.
Support for detecting terminal size is added to stdio and vc backends, but not pty and serial, because for the later it's unfortunately impossible to get resize notifications. A QMP command is added for notifying QEMU about the terminal size of any chardev. This can be used by clients to support resizing for devices where QEMU is not able to detect the size by itself (e.g. virsh console). There is a bug in Linux versions prior to 6.15 which causes the dimensions to be interpreted incorrectly by the guest. If the guest kernel is not up to date, the wrong dimensions can make the terminal hard to use. The fix will be backported to stable kernels soon, and the problem can be worked around by disabling the feature using the console-size property, restoring the previous behavior. Notes for This Version ---------------------- The issue with swapped rows/cols has now been resolved - the virtio spec will remain unchanged, and the kernel fix is being backported. The console-size property is not documented, even though it can be useful for working aroung a guest kernel bug. The 'vc' chardev size support is still incomplete - size support has been added only to the generic and gtk/vte implementations. Size support for the spice implementation is still missing, and the generic implementation is mostly untested. The previous version had a bug that it didn't resend the size after a guest reset. While fixing this, I ended up rewriting a significant part of the virtio changes. I also removed the logic that tries to avoid sending VIRTIO_CONSOLE_RESIZE messages before a VIRTIO_CONSOLE_CONSOLE_PORT message. I don't think this should cause any problems, but if it does, the logic could be reintroduced. Because one of the patches ended up being significantly different from Szymon Lukasz's original version, I decided to change patch author and instead add a note about the original version to the commit message. Let me know if you would like this to be handled differently. I have also found an initial size bug in the Linux kernel implementation, although it only affects non-multiport devices. I posted a fix for the Linux bug to Linux maining lists [1]. [1]: https://lore.kernel.org/virtualization/[email protected]/ Full Changelog -------------- v6: - Rebased (renaming CharBackend -> CharFrontend) - Virtio resize message code rewritten to fix corner cases - Updated version numbers ('Since: 11.0', hw_compat_10_2) - Added note to CHR_EVENT_RESIZE definition comment, explaining that only the focused frontend gets the event - Fixed checkpatch warning (line length) - Link to v5: https://lore.kernel.org/qemu-devel/[email protected] v5: - Rename chardev-resize -> chardev-window-size-changed - Improve chardev-window-size-changed documentation - Add partial implementation for 'vc' chardev - Config space now returns port 0 size if multiport - Console-size property completely disables size support - Fix misnamed variables in char-win-stdio - Link to v4: https://lore.kernel.org/qemu-devel/[email protected] v4: - Changed order of rows and cols fields - Added support for terminal size on Windows - Trace event is also emitted for legacy (non-multiport) drivers - Minor fixes required because of changes in QEMU (DECLARE_INSTANCE_CHECKER, qmp-example) - Updated version numbers ('Since: 10.2', hw_compat_10_1) - Link to v3: https://lore.kernel.org/qemu-devel/[email protected] v3: - Add resize messages over QMP, as suggested by Daniel v2: - Fix adding a new virtio feature bit to the virtio console device --- Filip Hejsek (4): virtio-serial-bus: add terminal resize messages char-win-stdio: add support for terminal size ui/console-vc: forward text console size to vc chardev ui/gtk: forward gtk console size to vc chardev Szymon Lukasz (8): chardev: add cols, rows fields chardev: add CHR_EVENT_RESIZE chardev: add qemu_chr_resize() char-mux: add support for the terminal size main-loop: change the handling of SIGWINCH char-stdio: add support for the terminal size qmp: add chardev-window-size-changed command virtio-console: notify the guest about terminal resizes backends/cryptodev-vhost-user.c | 1 + chardev/char-fe.c | 13 +++++++ chardev/char-mux.c | 18 +++++++++- chardev/char-stdio.c | 30 ++++++++++++++++ chardev/char-win-stdio.c | 19 ++++++++++ chardev/char.c | 26 ++++++++++++++ hw/block/vhost-user-blk.c | 1 + hw/char/terminal3270.c | 1 + hw/char/trace-events | 1 + hw/char/virtio-console.c | 35 ++++++++++++++++-- hw/char/virtio-serial-bus.c | 76 +++++++++++++++++++++++++++++++++++++-- hw/core/machine.c | 4 ++- hw/ipmi/ipmi_bmc_extern.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/usb/ccid-card-passthru.c | 1 + hw/usb/dev-serial.c | 1 + hw/usb/redirect.c | 1 + hw/virtio/vhost-user-base.c | 1 + hw/virtio/vhost-user-scmi.c | 1 + include/chardev/char-fe.h | 10 ++++++ include/chardev/char.h | 9 +++++ include/hw/virtio/virtio-serial.h | 5 +++ include/qemu/main-loop.h | 4 +++ monitor/hmp.c | 1 + monitor/qmp.c | 1 + net/passt.c | 1 + net/vhost-user.c | 1 + qapi/char.json | 31 ++++++++++++++++ ui/console-vc.c | 3 ++ ui/curses.c | 11 +++--- ui/gtk.c | 28 +++++++++++++++ util/main-loop.c | 21 +++++++++++ 32 files changed, 346 insertions(+), 12 deletions(-) --- base-commit: 38879a667fbb4ef54c70de71494882615f600a64 change-id: 20250912-console-resize-96c42140ba08 Best regards, -- Filip Hejsek <[email protected]>
