On 9/21/26 8:16 AM, Maximilian Immanuel Brandtner wrote:
> Adds a tty code to indicate a resize frame. The body contains two big
> endian 16-bit integers rows and columns.
>
> Signed-off-by: Maximilian Immanuel Brandtner <[email protected]>
> ---
> Requires the following pre-req:
> [PATCH v7 00/12] virtio-console: notify about the terminal size
>
> (https://lore.kernel.org/qemu-devel/[email protected]/)
>
> Testing:
> - Tested on QEMU: commit 38879a667f with the following patches applied:
> [PATCH v7 00/12] virtio-console: notify about the terminal size
> - Tested on linux-next (commit c1f49dea2b8f) with the following patches
> applied:
> [PATCH 0/2] s390/sclp: Resize for sclp-vt220 console
> ---
> hw/char/sclpconsole.c | 52 ++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c
> index 179d12745c..acf1fea6b5 100644
> --- a/hw/char/sclpconsole.c
> +++ b/hw/char/sclpconsole.c
> @@ -42,6 +42,7 @@ struct SCLPConsole {
> uint32_t iov_data_len; /* length of byte stream in buffer */
> uint32_t iov_sclp_rest; /* length of byte stream not read via SCLP */
> bool notify; /* qemu_notify_event() req'd if true */
> + bool resize;
Does this need to be in vmstate_sclpconsole / included in migration so
we don't miss pending resize events during a migration?
Also, should the resize value be explicitly set to false during
console_reset()?
[...]
> @@ -105,6 +128,28 @@ static void get_console_data(SCLPEvent *event, uint8_t
> *buf, size_t *size,
> int avail)
> {
> SCLPConsole *cons = SCLP_CONSOLE(event);
> + uint16_t be_rows, be_cols, rows, cols;
> +
> + if (cons->resize) {
> + if (avail < 5) {
I dislike the use of a magic number here, when it's tied directly to the
combined sizes of a few structures. Can you derive the size instead e.g.
sizeof(*buf) + sizeof(be_rows) + sizeof(be_cols);
> + *size = 0;
> + return;
> + }
> +
> + qemu_chr_fe_get_winsize(&cons->chr, &cols, &rows);
> + be_rows = cpu_to_be16(rows);
> + be_cols = cpu_to_be16(cols);
> +
> + /* first byte hex 0x08 indicates a new terminal size follows */
> + *buf++ = 0x08;
> + memcpy(buf, &be_rows, sizeof(be_rows));
> + memcpy(buf + 2, &be_cols, sizeof(be_cols));
> + *size = 5;
Ditto