git: 765615997a3a - main - virtio_console: Handle VIRTIO_CONSOLE_RESIZE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 03 Oct 2026 12:42:00 UTC
The branch main has been updated by kfv:
URL: https://cgit.FreeBSD.org/src/commit/?id=765615997a3a3ab649505d58087b7375736fdff7
commit 765615997a3a3ab649505d58087b7375736fdff7
Author: Faraz Vahedi <kfv@FreeBSD.org>
AuthorDate: 2026-10-03 12:40:45 +0000
Commit: Faraz Vahedi <kfv@FreeBSD.org>
CommitDate: 2026-10-03 12:40:45 +0000
virtio_console: Handle VIRTIO_CONSOLE_RESIZE
Multiport devices report console size per port by control event,
which was ignored and hence their ttys could never have a window
size.
Reviewed by: markj
Approved by: fuz (mentor)
Differential Revision: https://reviews.freebsd.org/D60094
---
sys/dev/virtio/console/virtio_console.c | 38 +++++++++++++++++++++++++++++++++
sys/dev/virtio/console/virtio_console.h | 5 +++++
2 files changed, 43 insertions(+)
diff --git a/sys/dev/virtio/console/virtio_console.c b/sys/dev/virtio/console/virtio_console.c
index 7dc6b531ea0e..bfa90b865d02 100644
--- a/sys/dev/virtio/console/virtio_console.c
+++ b/sys/dev/virtio/console/virtio_console.c
@@ -181,6 +181,8 @@ static void vtcon_ctrl_port_add_event(struct vtcon_softc *, int);
static void vtcon_ctrl_port_remove_event(struct vtcon_softc *, int);
static void vtcon_ctrl_port_console_event(struct vtcon_softc *, int);
static void vtcon_ctrl_port_open_event(struct vtcon_softc *, int);
+static void vtcon_ctrl_port_resize_event(struct vtcon_softc *, int,
+ const void *, size_t);
static void vtcon_ctrl_port_name_event(struct vtcon_softc *, int,
const char *, size_t);
static void vtcon_ctrl_process_event(struct vtcon_softc *,
@@ -819,6 +821,41 @@ vtcon_ctrl_port_open_event(struct vtcon_softc *sc, int id)
VTCON_PORT_UNLOCK(port);
}
+static void
+vtcon_ctrl_port_resize_event(struct vtcon_softc *sc, int id, const void *data,
+ size_t len)
+{
+ device_t dev;
+ struct vtcon_softc_port *scport;
+ struct vtcon_port *port;
+ struct virtio_console_resize resize;
+
+ dev = sc->vtcon_dev;
+ scport = &sc->vtcon_ports[id];
+
+ if (data == NULL || len < sizeof(resize)) {
+ device_printf(dev, "%s: resize port %d, but no size\n",
+ __func__, id);
+ return;
+ }
+ memcpy(&resize, data, sizeof(resize));
+
+ VTCON_LOCK(sc);
+ port = scport->vcsp_port;
+ if (port == NULL) {
+ VTCON_UNLOCK(sc);
+ device_printf(dev, "%s: resize port %d, but does not exist\n",
+ __func__, id);
+ return;
+ }
+
+ VTCON_PORT_LOCK(port);
+ VTCON_UNLOCK(sc);
+ vtcon_port_change_size(port, vtcon_htog16(sc, resize.cols),
+ vtcon_htog16(sc, resize.rows));
+ VTCON_PORT_UNLOCK(port);
+}
+
static void
vtcon_ctrl_port_name_event(struct vtcon_softc *sc, int id, const char *name,
size_t len)
@@ -889,6 +926,7 @@ vtcon_ctrl_process_event(struct vtcon_softc *sc,
break;
case VIRTIO_CONSOLE_RESIZE:
+ vtcon_ctrl_port_resize_event(sc, id, data, data_len);
break;
case VIRTIO_CONSOLE_PORT_OPEN:
diff --git a/sys/dev/virtio/console/virtio_console.h b/sys/dev/virtio/console/virtio_console.h
index 98daec9ecc10..fa16e7bc7c4b 100644
--- a/sys/dev/virtio/console/virtio_console.h
+++ b/sys/dev/virtio/console/virtio_console.h
@@ -60,6 +60,11 @@ struct virtio_console_control {
uint16_t value; /* Extra information for the key */
};
+struct virtio_console_resize {
+ uint16_t cols;
+ uint16_t rows;
+} __packed;
+
/* Some events for control messages */
#define VIRTIO_CONSOLE_DEVICE_READY 0
#define VIRTIO_CONSOLE_PORT_ADD 1