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 was a bug in Linux versions prior to 6.15 which caused the
dimensions to be interpreted incorrectly by the guest. The fix has
been backported to currently supported kernels, but to avoid making the
terminal harder to use on out of date guests, the feature is disabled
by default and must be enabled with the console-size property.
Limitations
-----------
There is no documentation for the virtio-serial device. I'm working on
this and will submit it separately.
Resizing support for the spice version of 'vc' chardev is still missing.
After migration, the guest is not informed about the new console size.
I propably won't fix this any time soon unless someone helps me with
migration stream changes.
Full Changelog
--------------
v8:
- Rebased
- Fixed uninitialized buffer in send_console_resize
- "Since: 11.1" -> "Since: 11.2"
- Link to v7: https://lore.kernel.org/qemu-devel/20260609-console-resize-v7-0-0c550fdcec15@gmail.com
v7:
- Rebased
- Renamed some functions
- Made virtio size support disabled by default
- "Since: 11.0" -> "Since: 11.1"
- Dropped "must exist" from chardev id param description in qmp docs
- Link to v6: https://lore.kernel.org/qemu-devel/20260119-console-resize-v6-0-33a7b0330a7a@gmail.com
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/20250921-console-resize-v5-0-89e3c6727060@gmail.com
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/20250912-console-resize-v4-0-7925e444afc4@gmail.com
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/20200629164041.472528-1-noh4hss@gmail.com
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):
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
virtio-serial-bus: add terminal resize messages
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 | 19 ++++++++-
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 | 81 ++++++++++++++++++++++++++++++++++++++-
hw/display/vhost-user-media.c | 1 +
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 | 7 ++++
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 | 8 ++++
ui/curses.c | 11 +++---
ui/gtk.c | 28 ++++++++++++++
util/main-loop.c | 21 ++++++++++
32 files changed, 357 insertions(+), 11 deletions(-)
---
base-commit: 81ce3a87737aa50716c42db8886082d12783e0a1
change-id: 20250912-console-resize-96c42140ba08
Best regards,
--
Filip Hejsek <filip.hejsek@gmail.com>