qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v5 00/12] virtio-console: notify about the terminal size
@ 2025-09-20 23:45 Filip Hejsek
  2025-09-20 23:45 ` [PATCH RFC v5 01/12] chardev: add cols, rows fields Filip Hejsek
                   ` (11 more replies)
  0 siblings, 12 replies; 41+ messages in thread
From: Filip Hejsek @ 2025-09-20 23:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Paolo Bonzini, Michael S. Tsirkin,
	Laurent Vivier, Amit Shah, Markus Armbruster, Eric Blake,
	Eduardo Habkost, Marcel Apfelbaum, Philippe Mathieu-Daudé,
	Yanan Wang, Zhao Liu, Daniel P. Berrangé,
	Maximilian Immanuel Brandtner, Szymon Lukasz, Filip Hejsek

The goal of this series is to have a resizable terminal into a guest
without having to set up networking and using, e.g. ssh.

I tagged this version as an RFC as we still need to wait for a decision
on the swapped rows/cols issue by the virtio maintainers, so it cannot
be merged right away. I would still like to request a review especially
for the two (small) 'vc' chardev patches, which are new in this version.

The virtio spec allows a virtio-console device to notify the guest about
terminal resizes in the host. Linux Kernel implements the driver part of
the spec. This series implement the device part in QEMU.

Terminal size support is added for stdio and vc backends. It would make
sense to also add size support to the pty and serial backends, however
it's not possible to receive resize notifications for tty devices other
than a process' controlling terminal. For the serial backend, it might
still be useful to query the initial dimensions. (In a previous
discussion, only the pty backend was considered, where the initial
dimensions are useless.)

The 'vc' chardev changes are incomplete, because this chardev has
multiple implementations in QEMU. This series contains adds size support
to the generic and gtk/vte implementations. I think I also need to add
a spice implementation, please let me know if there is anything else.

I would also like some advice on how to test resizing the virtual
console. I tried resizing the window of the sdl backend, but that didn't
change the dimensions of the console (instead rescaling the console
image to fit the window).

This series also introduces resize messages that can be sent over QMP to
notify QEMU about the size of the terminal connented to some chardev.
In the libvirt setting, it will allow to implement a resizable terminal
for virsh console and other libvirt clients.

For a long time, the Linux implementation of virtio-console had rows and
columns swapped. This was fixed in Linux 6.15, but older versions will
interpret the dimensions incorrectly. There are two ways this might be
resolved:
 - It has been proposed to change the virtio spec to match historical
   Linux behavior. If the change is accepted, the fix would be reverted
   and we would end up with only two or three broken Linux versions.
 - Alternately, the Linux fix would be kept and backported to LTS
   versions.

In any case, users of broken Linux versions can disable the feature
using the console-size property.

Thanks to Markus, Daniel and Max for their feedback on v4,
and to Michael for helping with the swapped rows/cols issue.

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 (3):
      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 (9):
      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-serial-bus: add terminal resize messages
      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          | 63 ++++++++++++++++++++++++++++++++++++---
 hw/char/virtio-serial-bus.c       | 51 +++++++++++++++++++++++++++++--
 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            |  7 +++++
 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                    | 30 +++++++++++++++++++
 ui/console-vc.c                   |  3 ++
 ui/curses.c                       | 11 +++----
 ui/gtk.c                          | 27 +++++++++++++++++
 util/main-loop.c                  | 21 +++++++++++++
 32 files changed, 344 insertions(+), 13 deletions(-)
---
base-commit: 190d5d7fd725ff754f94e8e0cbfb69f279c82b5d
change-id: 20250912-console-resize-96c42140ba08

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



^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2025-10-13  5:47 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-20 23:45 [PATCH RFC v5 00/12] virtio-console: notify about the terminal size Filip Hejsek
2025-09-20 23:45 ` [PATCH RFC v5 01/12] chardev: add cols, rows fields Filip Hejsek
2025-09-22  8:13   ` Daniel P. Berrangé
2025-10-13  5:09   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 02/12] chardev: add CHR_EVENT_RESIZE Filip Hejsek
2025-09-22  8:16   ` Daniel P. Berrangé
2025-10-13  5:11   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 03/12] chardev: add qemu_chr_resize() Filip Hejsek
2025-09-22  8:19   ` Daniel P. Berrangé
2025-10-13  5:12   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 04/12] char-mux: add support for the terminal size Filip Hejsek
2025-09-22  8:21   ` Daniel P. Berrangé
2025-10-13  5:13   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 05/12] main-loop: change the handling of SIGWINCH Filip Hejsek
2025-09-22  8:29   ` Daniel P. Berrangé
2025-10-13  5:13   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 06/12] char-stdio: add support for the terminal size Filip Hejsek
2025-09-22  8:33   ` Daniel P. Berrangé
2025-10-13  5:14   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 07/12] qmp: add chardev-window-size-changed command Filip Hejsek
2025-09-22  6:45   ` Markus Armbruster
2025-09-22  8:52     ` Filip Hejsek
2025-09-22  9:38       ` Markus Armbruster
2025-09-22  8:35   ` Daniel P. Berrangé
2025-10-13  5:18   ` Dominique Martinet
2025-10-13  5:23   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 08/12] virtio-serial-bus: add terminal resize messages Filip Hejsek
2025-09-22  8:53   ` Daniel P. Berrangé
2025-10-13  5:19   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 09/12] virtio-console: notify the guest about terminal resizes Filip Hejsek
2025-09-22  8:45   ` Daniel P. Berrangé
2025-10-13  5:28   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 10/12] char-win-stdio: add support for terminal size Filip Hejsek
2025-09-22  8:38   ` Daniel P. Berrangé
2025-10-13  5:29   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 11/12] ui/console-vc: forward text console size to vc chardev Filip Hejsek
2025-09-22  8:41   ` Daniel P. Berrangé
2025-10-13  5:29   ` Dominique Martinet
2025-09-20 23:45 ` [PATCH RFC v5 12/12] ui/gtk: forward gtk " Filip Hejsek
2025-09-22  8:41   ` Daniel P. Berrangé
2025-10-13  5:44   ` Dominique Martinet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).