From: Filip Hejsek <filip.hejsek@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Amit Shah" <amit@kernel.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Maximilian Immanuel Brandtner" <maxbr@linux.ibm.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Szymon Lukasz" <noh4hss@gmail.com>
Subject: [PATCH v7 02/12] chardev: add CHR_EVENT_RESIZE
Date: Tue, 09 Jun 2026 21:16:12 +0200 [thread overview]
Message-ID: <20260609-console-resize-v7-2-0c550fdcec15@gmail.com> (raw)
In-Reply-To: <20260609-console-resize-v7-0-0c550fdcec15@gmail.com>
From: Szymon Lukasz <noh4hss@gmail.com>
Add a new chardev event, CHR_EVENT_RESIZE, which a backend should
trigger if it detects the size of the connected terminal changed.
Signed-off-by: Szymon Lukasz <noh4hss@gmail.com>
[Filip: add note that only the focused frontend gets the event]
Signed-off-by: Filip Hejsek <filip.hejsek@gmail.com>
---
backends/cryptodev-vhost-user.c | 1 +
chardev/char.c | 1 +
hw/block/vhost-user-blk.c | 1 +
hw/char/terminal3270.c | 1 +
hw/char/virtio-console.c | 1 +
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.h | 6 ++++++
monitor/hmp.c | 1 +
monitor/qmp.c | 1 +
net/passt.c | 1 +
net/vhost-user.c | 1 +
17 files changed, 22 insertions(+)
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index cc478d9902..36564d4307 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -173,6 +173,7 @@ static void cryptodev_vhost_user_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/chardev/char.c b/chardev/char.c
index ca8b37ed8d..5e62f2949e 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -75,6 +75,7 @@ void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index c151e83677..16c1a536f1 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -413,6 +413,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c
index 989b6f6ee1..acd754bcfa 100644
--- a/hw/char/terminal3270.c
+++ b/hw/char/terminal3270.c
@@ -169,6 +169,7 @@ static void chr_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
index 4737b9a56e..36ad2ddc3f 100644
--- a/hw/char/virtio-console.c
+++ b/hw/char/virtio-console.c
@@ -165,6 +165,7 @@ static void chr_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index fa08ed6c21..bd7c61b2d2 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -436,6 +436,7 @@ static void chr_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 3612897d4b..5601097bc9 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -226,6 +226,7 @@ static void vhost_user_scsi_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 5ab7855272..3f4052ec82 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -323,6 +323,7 @@ static void ccid_card_vscard_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
case CHR_EVENT_CLOSED:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index b238cb7937..98d2abbd56 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -576,6 +576,7 @@ static void usb_serial_event(void *opaque, QEMUChrEvent event)
break;
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index bde821e214..7a492c1e54 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1387,6 +1387,7 @@ static void usbredir_chardev_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c
index 01ab9ca56b..fd3a9d6265 100644
--- a/hw/virtio/vhost-user-base.c
+++ b/hw/virtio/vhost-user-base.c
@@ -267,6 +267,7 @@ static void vub_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c
index f9264c4374..180787ec6d 100644
--- a/hw/virtio/vhost-user-scmi.c
+++ b/hw/virtio/vhost-user-scmi.c
@@ -214,6 +214,7 @@ static void vu_scmi_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/include/chardev/char.h b/include/chardev/char.h
index 6394ec2ffe..ee9f24038b 100644
--- a/include/chardev/char.h
+++ b/include/chardev/char.h
@@ -22,6 +22,12 @@ typedef enum {
CHR_EVENT_OPENED, /* new connection established */
CHR_EVENT_MUX_IN, /* mux-focus was set to this terminal */
CHR_EVENT_MUX_OUT, /* mux-focus will move on */
+ CHR_EVENT_RESIZE, /*
+ * the size of the terminal connected to
+ * the chardev has changed. NOTE: this event is only
+ * sent to the focused frontend, so you should also
+ * update the size on receiving CHR_EVENT_MUX_IN.
+ */
CHR_EVENT_CLOSED /* connection closed. NOTE: currently this event
* is only bound to the read port of the chardev.
* Normally the read port and write port of a
diff --git a/monitor/hmp.c b/monitor/hmp.c
index cc4390486e..67d3fcba6d 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1496,6 +1496,7 @@ static void monitor_event(void *opaque, QEMUChrEvent event)
break;
case CHR_EVENT_BREAK:
+ case CHR_EVENT_RESIZE:
/* Ignored */
break;
}
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 687019811f..3d5ab8ff4f 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -486,6 +486,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/net/passt.c b/net/passt.c
index 45440c399b..e65198960e 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -428,6 +428,7 @@ static void passt_vhost_user_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 2d0fc49b4d..b849de92da 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -363,6 +363,7 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
case CHR_EVENT_BREAK:
case CHR_EVENT_MUX_IN:
case CHR_EVENT_MUX_OUT:
+ case CHR_EVENT_RESIZE:
/* Ignore */
break;
}
--
2.54.0
next prev parent reply other threads:[~2026-06-09 19:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 19:16 [PATCH v7 00/12] virtio-console: notify about the terminal size Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 01/12] chardev: add cols, rows fields Filip Hejsek
2026-06-09 19:16 ` Filip Hejsek [this message]
2026-06-10 13:25 ` [PATCH v7 02/12] chardev: add CHR_EVENT_RESIZE Daniel P. Berrangé
2026-06-09 19:16 ` [PATCH v7 03/12] chardev: add qemu_chr_resize() Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 04/12] char-mux: add support for the terminal size Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 05/12] main-loop: change the handling of SIGWINCH Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 06/12] char-stdio: add support for the terminal size Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 07/12] char-win-stdio: add support for " Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 08/12] ui/console-vc: forward text console size to vc chardev Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 09/12] ui/gtk: forward gtk " Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 10/12] qmp: add chardev-window-size-changed command Filip Hejsek
2026-06-09 19:16 ` [PATCH v7 11/12] virtio-serial-bus: add terminal resize messages Filip Hejsek
2026-06-09 21:48 ` marcandre.lureau
2026-06-10 13:31 ` Daniel P. Berrangé
2026-06-09 19:16 ` [PATCH v7 12/12] virtio-console: notify the guest about terminal resizes Filip Hejsek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260609-console-resize-v7-2-0c550fdcec15@gmail.com \
--to=filip.hejsek@gmail.com \
--cc=amit@kernel.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=maxbr@linux.ibm.com \
--cc=mst@redhat.com \
--cc=noh4hss@gmail.com \
--cc=pbonzini@redhat.com \
--cc=philmd@mailo.com \
--cc=qemu-devel@nongnu.org \
--cc=wangyanan55@huawei.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.