[PATCH v3 0/9] virtio-console: notify about the terminal size

Szymon Lukasz posted 9 patches 5 years, 7 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
backends/cryptodev-vhost-user.c   |  1 +
chardev/char-fe.c                 | 13 +++++++
chardev/char-mux.c                | 18 ++++++++-
chardev/char-stdio.c              | 29 ++++++++++++++
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       | 42 ++++++++++++++++++++-
hw/core/machine.c                 |  1 +
hw/ipmi/ipmi_bmc_extern.c         |  1 +
hw/usb/ccid-card-passthru.c       |  1 +
hw/usb/dev-serial.c               |  1 +
hw/usb/redirect.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/vhost-user.c                  |  1 +
qapi/char.json                    | 25 ++++++++++++
ui/curses.c                       | 11 +++---
util/main-loop.c                  | 21 +++++++++++
25 files changed, 274 insertions(+), 12 deletions(-)
[PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Szymon Lukasz 5 years, 7 months ago
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.

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.

This series adds support for a resizable terminal if a virtio console
device is connected to the stdio backend. 

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.


v3:
add resize messages over QMP, as suggested by Daniel

v2:
fix adding a new virtio feature bit to the virtio console device

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-resize 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              | 29 ++++++++++++++
 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       | 42 ++++++++++++++++++++-
 hw/core/machine.c                 |  1 +
 hw/ipmi/ipmi_bmc_extern.c         |  1 +
 hw/usb/ccid-card-passthru.c       |  1 +
 hw/usb/dev-serial.c               |  1 +
 hw/usb/redirect.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/vhost-user.c                  |  1 +
 qapi/char.json                    | 25 ++++++++++++
 ui/curses.c                       | 11 +++---
 util/main-loop.c                  | 21 +++++++++++
 25 files changed, 274 insertions(+), 12 deletions(-)

-- 
2.27.0


Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Filip Hejsek 2 years, 3 months ago
I have found this 3 year old patch adding virtio console resize
support, which seems to have been forgotten at that time. I would like
to see this feature merged.

Szymon, you have originally submitted this patch, would you be willing
to update it for the latest development tree and resubmit it?

If it turns out that Szymon doesn't want to work on this anymore for
any reason (or doesn't respond), could I resubmit the patch myself?
The contributing guidelines don't say anything about this. I'm
especially unsure how to deal with Signed-off-by, as in such case I
would be (re)submitting sombody else's work, but potentially with my
modifications. I'm willing to update and test the patch, and if
necessary, address any review feedback.

 - 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.
> 
> 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.
> 
> This series adds support for a resizable terminal if a virtio console
> device is connected to the stdio backend. 
> 
> 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.
> 
> 
> v3:
> add resize messages over QMP, as suggested by Daniel
> 
> v2:
> fix adding a new virtio feature bit to the virtio console device
> 
> 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-resize 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              | 29 ++++++++++++++
>  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       | 42 ++++++++++++++++++++-
>  hw/core/machine.c                 |  1 +
>  hw/ipmi/ipmi_bmc_extern.c         |  1 +
>  hw/usb/ccid-card-passthru.c       |  1 +
>  hw/usb/dev-serial.c               |  1 +
>  hw/usb/redirect.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/vhost-user.c                  |  1 +
>  qapi/char.json                    | 25 ++++++++++++
>  ui/curses.c                       | 11 +++---
>  util/main-loop.c                  | 21 +++++++++++
>  25 files changed, 274 insertions(+), 12 deletions(-)
> 

Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Dominique Martinet 5 months ago
Filip Hejsek wrote on Mon, Oct 23, 2023 at 05:12:14AM +0200:
> I have found this 3 year old patch adding virtio console resize
> support, which seems to have been forgotten at that time. I would like
> to see this feature merged.

It's been a couple more years... :)

Have you had a look at this, or did you find another way of handling
terminal resizes cleanly enough?


Thanks,
-- 
Dominique Martinet
Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Filip Hejsek 4 months, 4 weeks ago
On Tue, 2025-09-09 at 22:48 +0900, Dominique Martinet wrote:
> Filip Hejsek wrote on Mon, Oct 23, 2023 at 05:12:14AM +0200:
> > I have found this 3 year old patch adding virtio console resize
> > support, which seems to have been forgotten at that time. I would like
> > to see this feature merged.
> 
> It's been a couple more years... :)
> 
> Have you had a look at this, or did you find another way of handling
> terminal resizes cleanly enough?

I had indeed looked into this back in 2023 and even did some work on
it, but unfortunately I had abandoned it before getting to the finish
line.

From what I remember, I found that the patches didn't merge cleanly, so
I attempted to reconcile them with the changes made in QEMU master
since the original patches were submitted. As part of that work, I felt
that I needed to take responsibility for the patches, the same way I
would for a patch I wrote on my own.

Due to my yak shaving tendencies, I got distracted by several things. I
ended up investigating a test failure caused by a bug in unrelated code
(which I reported as issue #1969). I wrote terminal size detection code
for Windows. And I remember there being something in the patches that I
wasn't really happy about and intended to rewrite, but I never got
around to doing that. After a while, I lost my enthusiasm, and because
I had other things to worry about, this work ended up just sitting
there on my SSD for almost two years.

So anyway, for now I have now uploaded my version of the patches here:
https://gitlab.com/filip-hejsek/qemu/-/commits/console-resize-old

I will try to merge it with the current master again, which should be
ready in a short time. I can't promise much more than that, though. :)

Best regards,
Filip Hejsek
Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Filip Hejsek 4 months, 4 weeks ago
> I will try to merge it with the current master again, which should be
> ready in a short time.

Done. You can find an updated version of the patches at
<https://gitlab.com/filip-hejsek/qemu/-/commits/console-resize>.
I haven't tested the updated version though. I will maybe do some
testing and then submit it to the mailing list for review, although if
anyone else would like to take over then feel free to do so.
Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Filip Hejsek 4 months, 4 weeks ago
On Thu, 2025-09-11 at 18:43 +0200, Filip Hejsek wrote:
> > I will try to merge it with the current master again, which should be
> > ready in a short time.
> 
> Done. You can find an updated version of the patches at
> <https://gitlab.com/filip-hejsek/qemu/-/commits/console-resize>.
> I haven't tested the updated version though. I will maybe do some
> testing and then submit it to the mailing list for review, although if
> anyone else would like to take over then feel free to do so.

I have done some tests and it seems that lines and columns are swapped.
Maybe the implementation in the linux kernel was changed to conform to
the spec?
Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Dominique Martinet 4 months, 4 weeks ago
Filip Hejsek wrote on Thu, Sep 11, 2025 at 11:19:15PM +0200:
> > Done. You can find an updated version of the patches at
> > <https://gitlab.com/filip-hejsek/qemu/-/commits/console-resize>.
> > I haven't tested the updated version though. I will maybe do some
> > testing and then submit it to the mailing list for review, although if
> > anyone else would like to take over then feel free to do so.
> 
> I have done some tests and it seems that lines and columns are swapped.
> Maybe the implementation in the linux kernel was changed to conform to
> the spec?

Yes, they have:
https://git.kernel.org/linus/5326ab737a47278dbd16ed3ee7380b26c7056ddd

I had also rebased the patches but wasn't sure how it was supposed to
work, but perhaps that was why it appeared not to work instead...
(I assumed running qemu with something like that would "just resize",
but also tried the qmp command to no avail:
-serial none -device virtio-serial-pci -chardev stdio,id=foo -device virtconsole,chardev=foo
)

I'll retry with your branch, thank you !
-- 
Dominique Martinet | Asmadeus
Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Michael S. Tsirkin 5 months ago
On Tue, Sep 09, 2025 at 10:48:31PM +0900, Dominique Martinet wrote:
> Filip Hejsek wrote on Mon, Oct 23, 2023 at 05:12:14AM +0200:
> > I have found this 3 year old patch adding virtio console resize
> > support, which seems to have been forgotten at that time. I would like
> > to see this feature merged.
> 
> It's been a couple more years... :)
> 
> Have you had a look at this, or did you find another way of handling
> terminal resizes cleanly enough?
> 
> 
> Thanks,
> -- 
> Dominique Martinet

just resubmit the way Amit suggested at the time.
Re: [PATCH v3 0/9] virtio-console: notify about the terminal size
Posted by Amit Shah 2 years, 3 months ago
On Mon, 2023-10-23 at 05:12 +0200, Filip Hejsek wrote:
> I have found this 3 year old patch adding virtio console resize
> support, which seems to have been forgotten at that time. I would like
> to see this feature merged.
> 
> Szymon, you have originally submitted this patch, would you be willing
> to update it for the latest development tree and resubmit it?
> 
> If it turns out that Szymon doesn't want to work on this anymore for
> any reason (or doesn't respond), could I resubmit the patch myself?
> The contributing guidelines don't say anything about this. I'm
> especially unsure how to deal with Signed-off-by, as in such case I
> would be (re)submitting sombody else's work, but potentially with my
> modifications. I'm willing to update and test the patch, and if
> necessary, address any review feedback.

You should keep Szymon's SOB, mention your changes in the commit
message below that SOB and put in your own after.

	Amit