On September 18, 2025 10:23:33 AM GMT+02:00, "Daniel P. Berrangé" 
<berra...@redhat.com> wrote:
> On Fri, Sep 12, 2025 at 05:39:53AM +0200, Filip Hejsek wrote:
> > From: Szymon Lukasz <noh4...@gmail.com>
> > 
> > Implement the part of the virtio spec that allows to notify the virtio
> > driver about terminal resizes. The virtio spec contains two methods to
> > achieve that:
> > 
> > For legacy drivers, we have only one port and we put the terminal size
> > in the config space and inject the config changed interrupt.
> > 
> > For multiport devices, we use the control virtqueue to send a packet
> > containing the terminal size. Note that old versions of the Linux kernel
> > used an incorrect order for the fields (rows then cols instead of cols
> > then rows), until it was fixed by commit 
> > 5326ab737a47278dbd16ed3ee7380b26c7056ddd.
> > 
> > As a result, when using a Linux kernel older than 6.15, the number of rows
> > and columns will be swapped.
> > 
> > Signed-off-by: Szymon Lukasz <noh4...@gmail.com>
> > Reviewed-by: Michael S. Tsirkin <m...@redhat.com>
> > Signed-off-by: Filip Hejsek <filip.hej...@gmail.com>
> > ---
> >  [...]
> > +        vser->port0_cols = cols;
> > +        vser->port0_rows = rows;
> > +        virtio_notify_config(vdev);
> 
> IIUC, we should skip sending this if port->id does NOT reflect
> the primary port 0, as the virtio spec indicates F_SIZE only
> applies to port 0 unless we have F_MULTIPORT  set.

I have already changed this in my working version. I'm on a phone
and don't have access to it right now, but it was something like this 
pseudocode:

if "console-size" enabled:
  if port id == 0:
    port0_{cols,rows} = {cols,rows}
  if multiport:
    send VIRTIO_CONSOLE_RESIZE
  else:
    notify config

I guess I should make the config notification conditional on port 0 too.

Reply via email to