[PATCH v7 00/12] virtio-console: notify about the terminal size

Filip Hejsek posted 12 patches 2 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260609-console-resize-v7-0-0c550fdcec15@gmail.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, zhenwei pi <zhenwei.pi@linux.dev>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Raphael Norwitz <rnorwitz@nvidia.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, "Collin L. Walling" <walling@linux.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Laurent Vivier <lvivier@redhat.com>, Amit Shah <amit@kernel.org>, Corey Minyard <minyard@acm.org>, Fam Zheng <fam@euphon.net>, Samuel Thibault <samuel.thibault@ens-lyon.org>, "Alex Bennée" <alex.bennee@linaro.org>, Milan Zamazal <mzamazal@redhat.com>, "Dr. David Alan Gilbert" <dave@treblig.org>, Markus Armbruster <armbru@redhat.com>, Jason Wang <jasowang@redhat.com>, Eric Blake <eblake@redhat.com>
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/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 ++++++++++
31 files changed, 356 insertions(+), 11 deletions(-)
[PATCH v7 00/12] virtio-console: notify about the terminal size
Posted by Filip Hejsek 2 hours ago
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 still no documentation for the console-size property, which
would be nice to have so that people can discover this functionality.

Resizing support for the spice version of 'vc' chardev is still missing.

After migration, the guest is not informed about the new console size
(fixing this requires migration stream changes).

Full Changelog
--------------

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/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 ++++++++++
 31 files changed, 356 insertions(+), 11 deletions(-)
---
base-commit: cc329c491768b2d91eb0b0984f3baa0bf805776d
change-id: 20250912-console-resize-96c42140ba08

Best regards,
--  
Filip Hejsek <filip.hejsek@gmail.com>