UI, Audio & Chardev fixes + Terminal Resize Support
[GIT PULL 01/40] ui/spice-app: honor gl=off option, reject core/es
In reply to Marc-André LureauWith -display spice-app, the value of the gl option is ignored: gl=off enables OpenGL exactly like gl=on. Only omitting the option keeps OpenGL disabled.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4639
--- ui/spice-app.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
ui/spice-app.c +8 -2
@@ -180,8 +180,14 @@ static void spice_app_display_early_init(DisplayOptions *opts)qemu_opt_set (qopts,"image-compression" ,"off" , &error_abort);qemu_opt_set (qopts,"streaming-video" ,"off" , &error_abort);#ifdef HAVE_SPICE_GL -qemu_opt_set (qopts,"gl" , opts->has_gl ?"on" :"off" , &error_abort); - display_opengl = opts->has_gl; +if (opts->has_gl && + opts->gl !=DISPLAY_GL_MODE_ON && + opts->gl !=DISPLAY_GL_MODE_OFF ) { +error_report ("spice-app only supports gl=on/off" ); +exit (1 ); + } + display_opengl = opts->has_gl && opts->gl !=DISPLAY_GL_MODE_OFF ; +qemu_opt_set (qopts,"gl" , display_opengl ?"on" :"off" , &error_abort);#endif }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 04/40] chardev: add qemu_chr_resize()
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
This function should be called whenever we learn about a new size of the terminal connected to a chardev.
Message-ID: <[email protected]>
--- chardev/char.c | 11 +++++++++++ include/chardev/char.h | 2 ++ 2 files changed, 13 insertions(+)
chardev/char.c +11 -0
@@ -386,6 +386,17 @@ int qemu_chr_wait_connected(Chardev *chr, Error **errp)return 0 ; } +void qemu_chr_resize (Chardev *chr,uint16_t cols,uint16_t rows) +{ +if (cols != chr->cols || rows != chr->rows) { + chr->cols = cols; + chr->rows = rows; +if (chr->be_open) { +qemu_chr_be_event (chr,CHR_EVENT_RESIZE ); + } + } +} +QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename,bool permit_mux_mon) {
include/chardev/char.h +2 -0
@@ -235,6 +235,8 @@ int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all);#define qemu_chr_write_all (s, buf, len) qemu_chr_write(s, buf, len, true)int qemu_chr_wait_connected (Chardev *chr,Error **errp); +void qemu_chr_resize (Chardev *chr,uint16_t cols,uint16_t rows); +#define TYPE_CHARDEV "chardev"OBJECT_DECLARE_TYPE (Chardev, ChardevClass,CHARDEV )
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 07/40] char-stdio: add support for the terminal size
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
Update the terminal size upon SIGWINCH delivery.
[Filip: use DECLARE_INSTANCE_CHECKER,
qemu_chr_resize_stdio -> stdio_chr_resize, remove notifier in char_stdio_finalize]
Message-ID: <[email protected]>
--- chardev/char-stdio.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
chardev/char-stdio.c +33 -0
@@ -34,7 +34,9 @@#include "chardev/char-win-stdio.h" #else #include <termios.h> +#include <sys/ioctl.h> #include "chardev/char-fd.h" +#include "qemu/main-loop.h" #endif #ifndef _WIN32
@@ -46,6 +48,14 @@ static bool stdio_in_use;static bool stdio_allow_signal;static bool stdio_echo_state; +typedef struct { +FDChardev parent; +Notifier resize_notifier; +}StdioChardev ; + +DECLARE_INSTANCE_CHECKER (StdioChardev,STDIO_CHARDEV , + TYPE_CHARDEV_STDIO) +static void term_exit (void ) {if (stdio_in_use) {
@@ -85,8 +95,23 @@ static void term_stdio_handler(int sig)stdio_chr_set_echo (NULL , stdio_echo_state); } +static void stdio_chr_resize (Chardev *chr) +{ +struct winsize ws; +if (ioctl (1 ,TIOCGWINSZ , &ws) !=-1 ) { +qemu_chr_resize (chr, ws.ws_col, ws.ws_row); + } +} + +static void term_resize_notify (Notifier *n,void *data) +{ +StdioChardev *s =container_of (n, StdioChardev, resize_notifier); +stdio_chr_resize (CHARDEV (s)); +} +static bool stdio_chr_open (Chardev *chr,ChardevBackend *backend,Error **errp) { +StdioChardev *s =STDIO_CHARDEV (chr);ChardevStdio *opts = backend->u.stdio.data;struct sigaction act;
@@ -121,6 +146,10 @@ static bool stdio_chr_open(Chardev *chr, ChardevBackend *backend, Error **errp) stdio_allow_signal = !opts->has_signal || opts->signal;stdio_chr_set_echo (chr, false); + s->resize_notifier.notify = term_resize_notify; +sigwinch_add_notifier (&s->resize_notifier); +stdio_chr_resize (chr); +qemu_chr_be_event (chr,CHR_EVENT_OPENED );return true; }
@@ -152,6 +181,9 @@ static void char_stdio_class_init(ObjectClass *oc, const void *data)static void char_stdio_finalize (Object *obj) {#ifndef _WIN32 +StdioChardev *s =STDIO_CHARDEV (obj); + +sigwinch_remove_notifier (&s->resize_notifier);term_exit ();#endif }
@@ -162,6 +194,7 @@ static const TypeInfo char_stdio_type_info = { .parent = TYPE_CHARDEV_WIN_STDIO, #else .parent = TYPE_CHARDEV_FD, + .instance_size = sizeof(StdioChardev), #endif .instance_finalize = char_stdio_finalize, .class_init = char_stdio_class_init,
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 10/40] ui/gtk: forward gtk console size to vc chardev
In reply to Marc-André LureauFrom: Filip Hejsek <[email protected]>
Query the terminal size from the vte library when creating the console and every time it might change. Vte doesn't send any signal specifically for terminal size changes, so instead we register callbacks for size-allocate and char-size-changed.
Message-ID: <[email protected]>
--- ui/gtk.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
ui/gtk.c +28 -0
@@ -2196,6 +2196,28 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,return TRUE; } +static void gd_vc_vte_update_size (VirtualConsole *vc) +{ +uint16_t cols, rows; + cols =vte_terminal_get_column_count (VTE_TERMINAL (vc->vte.terminal)); + rows =vte_terminal_get_row_count (VTE_TERMINAL (vc->vte.terminal)); +qemu_chr_resize (vc->vte.chr, cols, rows); +} + +static void gd_vc_size_allocate (VteTerminal *terminal, +GtkAllocation *allocation,gpointer user_data) +{ +VirtualConsole *vc = user_data; +gd_vc_vte_update_size (vc); +} + +static void gd_vc_char_size_changed (VteTerminal *terminal,guint width, +guint height,gpointer user_data) +{ +VirtualConsole *vc = user_data; +gd_vc_vte_update_size (vc); +} +static void gd_vc_vte_init (GtkDisplayState *s,VirtualConsole *vc,Chardev *chr,int idx) {
@@ -2258,6 +2280,12 @@ static void gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, gtk_label_new(vc->label));qemu_chr_be_event (vc->vte.chr,CHR_EVENT_OPENED ); + +g_signal_connect (vc->vte.terminal,"size-allocate" , +G_CALLBACK (gd_vc_size_allocate), vc); +g_signal_connect (vc->vte.terminal,"char-size-changed" , +G_CALLBACK (gd_vc_char_size_changed), vc); +gd_vc_vte_update_size (vc); }static void gd_vcs_init (GtkDisplayState *s)
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 09/40] ui/console-vc: forward text console size to vc chardev
In reply to Marc-André LureauFrom: Filip Hejsek <[email protected]>
Update the vc chardev size when initializing the console and after changing the surface image.
NOTE: There seems to be a bug in the code where the dpy_text_resize
callback is not called when the size changes due to changing the surface image. (Though it doesn't cause any problem in practice because the callback is only used by ui/ncurses for fixed consoles, whose size never changes.)
Message-ID: <[email protected]>
--- ui/console-vc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
ui/console-vc.c +8 -0
@@ -115,12 +115,19 @@ static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)return vt100_input (&s->vt, buf, len); } +static void text_console_chr_resize (QemuTextConsole *s) +{ +qemu_chr_resize (s->chr, s->vt.width, s->vt.height); +} +static void text_console_invalidate (void *opaque) {QemuTextConsole *s =QEMU_TEXT_CONSOLE (opaque);if (!QEMU_IS_FIXED_TEXT_CONSOLE (s)) {vt100_set_image (&s->vt,QEMU_CONSOLE (s)->surface->image); +text_console_chr_resize (s); +/* XXX Shouldn't qemu_text_console_update_size() also be called here? */ }vt100_refresh (&s->vt); }
@@ -254,6 +261,7 @@ static bool vc_chr_open(Chardev *chr, ChardevBackend *backend, Error **errp) s->vt.t_attrib =TEXT_ATTRIBUTES_DEFAULT ; } +text_console_chr_resize (s);qemu_chr_be_event (chr,CHR_EVENT_OPENED );qemu_console_notify (QEMU_CONSOLE_ADDED ,QEMU_CONSOLE (s));return true;
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 11/40] qmp: add chardev-window-size-changed command
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
The management software can use this command to notify QEMU about the size of the terminal connected to a chardev, QEMU can then forward this information to the guest if the chardev is connected to a virtio console device.
Message-ID: <[email protected]>
--- chardev/char.c | 14 ++++++++++++++ qapi/char.json | 31 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
chardev/char.c +14 -0
@@ -1347,6 +1347,20 @@ bool qmp_add_client_char(int fd, bool has_skipauth, bool skipauth,return true; } +void qmp_chardev_window_size_changed (const char *id,uint16_t cols, +uint16_t rows,Error **errp) +{ +Chardev *chr; + + chr =qemu_chr_find (id); +if (chr ==NULL ) { +error_setg (errp,"Chardev '%s' not found" , id); +return ; + } + +qemu_chr_resize (chr, cols, rows); +} +/* * Add a timeout callback for the chardev (in milliseconds), return * the GSource object created. Please use this to add timeout hook for
qapi/char.json +31 -0
@@ -862,6 +862,37 @@ { 'command': 'chardev-send-break', 'data': { 'id': 'str' } } +## +# @chardev-window-size-changed: +# +# Notifies a chardev about the current size of the terminal connected +# to this chardev. The information will be forwarded to the guest if +# the chardev is connected to a virtio console device. +# +# The initial size is 0x0, which should be interpreted as an unknown +# size. +# +# Some backends detect the terminal size automatically, in which case +# the size may unpredictably revert to the detected one at any time. +# +# @id: the chardev's ID +# +# @cols: the number of columns +# +# @rows: the number of rows +# +# Since: 11.2 +# +# .. qmp-example:: +# +# -> { "execute": "chardev-window-size-changed", "arguments": { "id": "foo", "cols": 80, "rows": 24 } } +# <- { "return": {} } +## +{ 'command': 'chardev-window-size-changed', + 'data': { 'id': 'str', + 'cols': 'uint16', + 'rows': 'uint16' } } + ## # @VSERPORT_CHANGE: # Emitted when the guest opens or closes a virtio-serial port.
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 03/40] chardev: add CHR_EVENT_RESIZE
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
Add a new chardev event, CHR_EVENT_RESIZE, which a backend should trigger if it detects the size of the connected terminal changed.
Message-ID: <[email protected]>
--- 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/display/vhost-user-media.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 + 18 files changed, 23 insertions(+)
backends/cryptodev-vhost-user.c +1 -0
@@ -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 ; }
chardev/char.c +1 -0
@@ -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 ; }
hw/block/vhost-user-blk.c +1 -0
@@ -441,6 +441,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 ; }
hw/char/terminal3270.c +1 -0
@@ -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 ; }
hw/char/virtio-console.c +1 -0
@@ -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 ; }
hw/display/vhost-user-media.c +1 -0
@@ -241,6 +241,7 @@ static void vu_media_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 ; }
hw/ipmi/ipmi_bmc_extern.c +1 -0
@@ -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 ; }
hw/scsi/vhost-user-scsi.c +1 -0
@@ -225,6 +225,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 ; }
hw/usb/ccid-card-passthru.c +1 -0
@@ -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 ; }
hw/usb/dev-serial.c +1 -0
@@ -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 ; }
hw/usb/redirect.c +1 -0
@@ -1390,6 +1390,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 ; }
hw/virtio/vhost-user-base.c +1 -0
@@ -277,6 +277,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 ; }
hw/virtio/vhost-user-scmi.c +1 -0
@@ -215,6 +215,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 ; }
include/chardev/char.h +6 -0
@@ -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
monitor/hmp.c +1 -0
@@ -1587,6 +1587,7 @@ static void monitor_event(void *opaque, QEMUChrEvent event)break ;case CHR_EVENT_BREAK : +case CHR_EVENT_RESIZE :/* Ignored */ break ; }
monitor/qmp.c +1 -0
@@ -663,6 +663,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 ; }
net/passt.c +1 -0
@@ -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 ; }
net/vhost-user.c +1 -0
@@ -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 ; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 08/40] char-win-stdio: add support for terminal size
In reply to Marc-André LureauFrom: Filip Hejsek <[email protected]>
Use GetConsoleScreenBufferInfo to obtain terminal size and set ENABLE_WINDOW_INPUT to receive resize notifications.
Message-ID: <[email protected]>
--- chardev/char-win-stdio.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
chardev/char-win-stdio.c +19 -0
@@ -44,6 +44,20 @@ typedef struct WinStdioChardev WinStdioChardev;DECLARE_INSTANCE_CHECKER (WinStdioChardev,WIN_STDIO_CHARDEV , TYPE_CHARDEV_WIN_STDIO) +static void win_stdio_chr_resize (Chardev *chr) +{ +HANDLE hStdOut =GetStdHandle (STD_OUTPUT_HANDLE ); +CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo; + +if (GetConsoleScreenBufferInfo (hStdOut, &ScreenBufferInfo)) { +uint16_t cols = ScreenBufferInfo.srWindow.Right +1 + - ScreenBufferInfo.srWindow.Left; +uint16_t rows = ScreenBufferInfo.srWindow.Bottom +1 + - ScreenBufferInfo.srWindow.Top; +qemu_chr_resize (chr, cols, rows); + } +} +static void win_stdio_wait_func (void *opaque) {Chardev *chr =CHARDEV (opaque);
@@ -75,6 +89,9 @@ static void win_stdio_wait_func(void *opaque) } } } +if (buf[i].EventType ==WINDOW_BUFFER_SIZE_EVENT ) { +win_stdio_chr_resize (chr); + } } }
@@ -201,6 +218,8 @@ static bool win_stdio_chr_open(Chardev *chr, }else { dwMode &= ~ENABLE_PROCESSED_INPUT ; } + dwMode |=ENABLE_WINDOW_INPUT ; +win_stdio_chr_resize (chr); }SetConsoleMode (stdio->hStdIn, dwMode);
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 15/40] virtio-gpu-rutabaga: make sure ctx_ids match
In reply to Marc-André LureauFrom: Gurchetan Singh <[email protected]>
The ctx_ids need to match as well as the ring ids for proper signaling.
v2: add r-b tags
Message-ID: <[email protected]>
--- hw/display/virtio-gpu-rutabaga.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/display/virtio-gpu-rutabaga.c +2 -1
@@ -902,7 +902,8 @@ virtio_gpu_rutabaga_aio_cb(void *opaque) }if (signaled_ctx_specific && - (cmd->cmd_hdr.ring_idx != fence_data.ring_idx)) { + ((cmd->cmd_hdr.ctx_id != fence_data.ctx_id) || + (cmd->cmd_hdr.ring_idx != fence_data.ring_idx))) {continue ; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 14/40] hw/display/virtio-gpu: Block migration with large blobs
In reply to Marc-André LureauFrom: Akihiko Odaki <[email protected]>
The blob size is encoded as a 64-bit integer in the virtio protocol, but it is encoded as a 32-bit integer in the migration stream, and a large blob whose size cannot be expressed in a 32-bit integer will be corrupted after migration.
Block migration with such large blobs, and, if it is not possible, deny creating a large blob.
Message-ID: <[email protected]>
--- hw/display/virtio-gpu.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
hw/display/virtio-gpu.c +32 -0
@@ -27,6 +27,7 @@#include "hw/virtio/virtio-gpu-pixman.h" #include "hw/virtio/virtio-bus.h" #include "hw/core/qdev-properties.h" +#include "migration/blocker.h" #include "qemu/log.h" #include "qemu/memfd.h" #include "qemu/module.h"
@@ -35,6 +36,9 @@#define VIRTIO_GPU_VM_VERSION 1 +static size_t num_large_blobs; +static Error *large_blob_blocker; +static struct virtio_gpu_simple_resource *virtio_gpu_find_check_resource (VirtIOGPU *g,uint32_t resource_id,const char *caller,uint32_t *error);
@@ -355,6 +359,7 @@ end:static void virtio_gpu_resource_create_blob (VirtIOGPU *g,struct virtio_gpu_ctrl_command *cmd) { +Error *local_err =NULL ;struct virtio_gpu_simple_resource *res;struct virtio_gpu_resource_create_blob cblob;int ret;
@@ -415,6 +420,26 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *g, } } +if (cblob.size >UINT32_MAX ) { +if (!num_large_blobs) { +error_setg (&large_blob_blocker, +"a large virtio-gpu blob is present" ); +if (migrate_add_blocker (&large_blob_blocker, &local_err)) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: blocking migration for a large blob failed: %s\n" , + __func__,error_get_pretty (local_err)); +error_free (local_err); + cmd->error =VIRTIO_GPU_RESP_ERR_UNSPEC ; +virtio_gpu_fini_udmabuf (res); +virtio_gpu_cleanup_mapping (g, res); +g_free (res); +return ; + } + } + + num_large_blobs++; + } +QTAILQ_INSERT_HEAD (&g->reslist, res, next); }
@@ -460,6 +485,13 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g, {virtio_gpu_disable_scanout_for_resource (g, res->resource_id); +if (res->blob_size >UINT32_MAX ) { + num_large_blobs--; +if (!num_large_blobs) { +migrate_del_blocker (&large_blob_blocker); + } + } +qemu_pixman_image_unref (res->image);virtio_gpu_cleanup_mapping (g, res);QTAILQ_REMOVE (&g->reslist, res, next);
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 17/40] virtio-gpu: fix memory leaks in virgl and rutabaga
In reply to Marc-André LureauFrom: Tom Desnoyers <[email protected]>
When a gpu buffer backed by a guest-memory blob is unreferenced, virgl and rutabaga free the resource but not its addrs field, leaking memory on every unref.
In virtio-gpu-virgl.c, call virtio_gpu_cleanup_mapping() instead of virtio_gpu_cleanup_mapping_iov(). In virtio-gpu-rutabaga.c, call virtio_gpu_cleanup_mapping() before freeing the resource.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4634
Message-ID: <[email protected]>
--- hw/display/virtio-gpu-rutabaga.c | 2 ++ hw/display/virtio-gpu-virgl.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-)
hw/display/virtio-gpu-rutabaga.c +2 -0
@@ -164,6 +164,8 @@ virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, }QTAILQ_REMOVE (&g->reslist, res, next); + +virtio_gpu_cleanup_mapping (g, res);g_free (res); }
hw/display/virtio-gpu-virgl.c +3 -3
@@ -451,13 +451,13 @@ virtio_gpu_virgl_resource_unref(VirtIOGPU *g,virgl_renderer_resource_detach_iov (res->base.resource_id, &res_iovs, &num_iovs); -if (res_iovs !=NULL && num_iovs !=0 ) { -virtio_gpu_cleanup_mapping_iov (g, res_iovs, num_iovs); - } + res->base.iov = res_iovs; + res->base.iov_cnt = num_iovs;virgl_renderer_resource_unref (res->base.resource_id);QTAILQ_REMOVE (&g->reslist, &res->base, next); +virtio_gpu_cleanup_mapping (g, &res->base);g_free (res);return 0 ;
Signature · 1 line
2.56.0.116.g6de20f6092dc
The following changes since commit 615ece3c406b262996e569f29ea6eed0d81c4d8d:
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2026-10-09 15:49:53 +0200)
are available in the Git repository at:
https://gitlab.com/marcandre.lureau/qemu.git tags/ui-pr-v1
for you to fetch changes up to 919711cab29776f12209b375a4db251007c6d96e:
chardev/char: fix use-after-free on mux creation failure (2026-10-13 17:22:49 +0400)
----------------------------------------------------------------
UI, Audio & Chardev fixes + Terminal Resize Support
Adds end-to-end support for propagating terminal size changes from the host to the guest. This includes a new CHR_EVENT_RESIZE chardev event, qemu_chr_resize() API, a chardev-window-size-changed QMP command, SIGWINCH handling, and wiring through mux/stdio/win-stdio chardevs, virtio-serial, virtio-console, GTK, and text console backends.
- collect ui, audio, chardev and display fixes
----------------------------------------------------------------
Akihiko Odaki (1):
hw/display/virtio-gpu: Block migration with large blobs
Filip Hejsek (4):
char-win-stdio: add support for terminal size ui/console-vc: forward text console size to vc chardev ui/gtk: forward gtk console size to vc chardev
virtio-serial-bus: add terminal resize messages
Gurchetan Singh (1):
virtio-gpu-rutabaga: make sure ctx_ids match
Marc-André Lureau (25):
ui/spice-app: honor gl=off option, reject core/es hw/display/vga: fix OOB writes after external surface resize audio/ossaudio: fix ioctl passing address-of-pointer instead of pointer audio/dbusaudio: fix off-by-one in volume channel assertion audio/ossaudio: fix off-by-one in mmap buffer size assertion audio/paaudio: fix server string in PAConnection audio/paaudio: avoid pidfile path truncation
audio/pwaudio: fix capture buffer leak on early return paths audio/pwaudio: clamp overrun writes to remaining ring buffer space audio/pwaudio: fix integer underflow in qpw_read() audio/pwaudio: handle negative avail in qpw_write and qpw_buffer_get_free audio/pwaudio: bail out on underrun in qpw_write audio/audio-mixeng-be: add upper bounds to audio settings validation audio/wavcapture: prevent freq overflow and corrupted WAV header ui/clipboard: clean up vm change state handler on last peer unregister ui/console: skip empty update regions in qemu_console_update ui/console: use QLIST_FOREACH_SAFE in dpy_refresh
ui/input: fix integer overflow in qemu_input_scale_axis ui/vnc-enc-zrle: propagate zrle_compress_data error ui/vnc-jobs: assert rect coordinates and dimensions in vnc_job_add_rect chardev/char-pty: free pty_name in finalize chardev/char-ringbuf: reject zero size with is_power_of_2 chardev/char-ringbuf: use actual read length in qmp_ringbuf_read chardev/char-udp: clarify read_poll return value with pending data chardev/char: fix use-after-free on mux creation failure
Szymon Lukasz (8):
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-window-size-changed command
virtio-console: notify the guest about terminal resizes
Tom Desnoyers (1):
virtio-gpu: fix memory leaks in virgl and rutabaga
audio/audio-mixeng-be.c | 4 +- audio/dbusaudio.c | 4 +- audio/ossaudio.c | 4 +- audio/paaudio.c | 6 ++- audio/pwaudio.c | 22 ++++++++++- audio/wavcapture.c | 6 +++ backends/cryptodev-vhost-user.c | 1 + chardev/char-fe.c | 13 +++++++ chardev/char-mux.c | 19 ++++++++- chardev/char-pty.c | 1 + chardev/char-ringbuf.c | 10 +++-- chardev/char-stdio.c | 33 ++++++++++++++++ chardev/char-udp.c | 4 ++ chardev/char-win-stdio.c | 19 +++++++++ chardev/char.c | 27 +++++++++++++ hw/block/vhost-user-blk.c | 1 + hw/char/terminal3270.c | 1 + hw/char/trace-events | 1 + hw/char/virtio-console.c | 35 +++++++++++++++-- hw/char/virtio-serial-bus.c | 81 ++++++++++++++++++++++++++++++++++++++- hw/display/vga.c | 8 ++-- hw/display/vhost-user-media.c | 1 + hw/display/virtio-gpu-rutabaga.c | 5 ++- hw/display/virtio-gpu-virgl.c | 6 +-- hw/display/virtio-gpu.c | 32 ++++++++++++++++ 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-fe.h | 10 +++++ include/chardev/char.h | 9 +++++ include/hw/virtio/virtio-serial.h | 7 ++++ include/qemu/main-loop.h | 5 +++ monitor/hmp.c | 1 + monitor/qmp.c | 1 + net/passt.c | 1 + net/vhost-user.c | 1 + qapi/char.json | 31 +++++++++++++++ ui/clipboard.c | 4 ++ ui/console-vc.c | 8 ++++ ui/console.c | 7 +++- ui/curses.c | 21 +++++++--- ui/gtk.c | 28 ++++++++++++++ ui/input.c | 8 +++- ui/spice-app.c | 10 ++++- ui/vnc-enc-zrle.c | 19 ++++++--- ui/vnc-jobs.c | 1 + util/main-loop.c | 33 ++++++++++++++++ 51 files changed, 513 insertions(+), 43 deletions(-)
[GIT PULL 22/40] audio/paaudio: avoid pidfile path truncation
The pidfile path is built with snprintf() into a 64-byte stack buffer, which can silently truncate when XDG_RUNTIME_DIR is long. Use g_strdup_printf() with g_autofree instead.
Message-ID: <[email protected]>
--- audio/paaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
audio/paaudio.c +2 -2
@@ -819,7 +819,7 @@ audio_pa_realize(AudioBackend *abe, Audiodev *dev, Error **errp) }if (!popts->server) { -char pidfile[64 ]; + g_autofree char *pidfile = NULL;char *runtime;struct stat st;
@@ -828,7 +828,7 @@ audio_pa_realize(AudioBackend *abe, Audiodev *dev, Error **errp)error_setg (errp,"XDG_RUNTIME_DIR not set" );return false; } -snprintf (pidfile,sizeof (pidfile),"%s/pulse/pid" , runtime); + pidfile =g_strdup_printf ("%s/pulse/pid" , runtime);if (stat (pidfile, &st) !=0 ) {error_setg_errno (errp, errno,"could not stat pidfile %s" , pidfile);return false;
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 02/40] chardev: add cols, rows fields
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
These fields should be interpreted as the size of the terminal connected to a given chardev.
Message-ID: <[email protected]>
--- chardev/char-fe.c | 13 +++++++++++++ include/chardev/char-fe.h | 10 ++++++++++ include/chardev/char.h | 1 + 3 files changed, 24 insertions(+)
chardev/char-fe.c +13 -0
@@ -329,6 +329,19 @@ void qemu_chr_fe_set_echo(CharFrontend *c, bool echo) } } +void qemu_chr_fe_get_winsize (CharFrontend *c,uint16_t *cols,uint16_t *rows) +{ +Chardev *chr = c->chr; + +if (chr) { + *cols = chr->cols; + *rows = chr->rows; + }else { + *cols =0 ; + *rows =0 ; + } +} +void qemu_chr_fe_set_open (CharFrontend *c,bool is_open) {Chardev *chr = c->chr;
include/chardev/char-fe.h +10 -0
@@ -168,6 +168,16 @@ int qemu_chr_fe_wait_connected(CharFrontend *c, Error **errp);*/ void qemu_chr_fe_set_echo (CharFrontend *c,bool echo); +/** +* qemu_chr_fe_get_winsize: +* @cols: the address for storing columns +* @rows: the address for storing rows +* +* Get the size of the terminal connected to the chardev backend. +* Returns *cols = *rows = 0, if no associated Chardev. +*/ +void qemu_chr_fe_get_winsize (CharFrontend *c,uint16_t *cols,uint16_t *rows); +/** * qemu_chr_fe_set_open: * @c: a CharFrontend
include/chardev/char.h +1 -0
@@ -66,6 +66,7 @@ struct Chardev {bool logtimestamp;bool log_line_start;int be_open; +uint16_t cols, rows;/* used to coordinate the chardev-change special-case: */ bool handover_yank_instance;GSource *gsource;
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 27/40] audio/pwaudio: bail out on underrun in qpw_write
In reply to Marc-André LureauWhen filled is negative (underrun), qpw_write() logs an error but falls through to spa_ringbuffer_write_data(). Bail out instead.
Message-ID: <[email protected]>
--- audio/pwaudio.c | 2 ++ 1 file changed, 2 insertions(+)
audio/pwaudio.c +2 -0
@@ -326,6 +326,8 @@ qpw_write(HWVoiceOut *hw, void *data, size_t len)if (filled <0 ) {error_report ("%p: underrun write:%u filled:%d" , pw, index, filled); + len =0 ; + goto done_unlock; }else {if ((uint32_t ) filled + len >RINGBUFFER_SIZE ) { error_report("%p: overrun write:%u filled:%d + size:%zu > max:%u",
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 38/40] chardev/char-ringbuf: use actual read length in qmp_ringbuf_read
In reply to Marc-André Lureauqmp_ringbuf_read() used the requested size rather than the actual number of bytes returned by ringbuf_chr_read() for base64 encoding and null-termination. Since ringbuf_count() is called without the lock, a concurrent writer can advance the consumer index, leaving fewer bytes available by the time ringbuf_chr_read() runs. This could encode uninitialized data or misplace the null terminator.
Message-ID: <[email protected]>
--- chardev/char-ringbuf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
chardev/char-ringbuf.c +4 -3
@@ -167,6 +167,7 @@ char *qmp_ringbuf_read(const char *device, int64_t size,Chardev *chr;uint8_t *read_data;size_t count; +int actual;char *data; chr =qemu_chr_find (device);
@@ -189,10 +190,10 @@ char *qmp_ringbuf_read(const char *device, int64_t size, size = size > count ? count : size; read_data =g_malloc (size +1 ); -ringbuf_chr_read (chr, read_data, size); + actual =ringbuf_chr_read (chr, read_data, size);if (has_format && (format ==DATA_FORMAT_BASE64 )) { - data =g_base64_encode (read_data, size); + data =g_base64_encode (read_data, actual);g_free (read_data); }else {/*
@@ -202,7 +203,7 @@ char *qmp_ringbuf_read(const char *device, int64_t size,* when) ring buffer lost characters since last read, initial * continuation characters should be dropped. */ - read_data[size] =0 ; + read_data[actual] =0 ; data = (char *)read_data; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 23/40] audio/pwaudio: fix capture buffer leak on early return paths
In reply to Marc-André Lureaucapture_on_process() leaks the PipeWire buffer on the p == NULL and underrun early-return paths by not calling pw_stream_queue_buffer(). The stream eventually starves from its buffer pool.
Message-ID: <[email protected]>
--- audio/pwaudio.c | 3 +++ 1 file changed, 3 insertions(+)
audio/pwaudio.c +3 -0
@@ -171,6 +171,7 @@ capture_on_process(void *data) buf = b->buffer; p = buf->datas[0 ].data;if (p ==NULL ) { +pw_stream_queue_buffer (v->stream, b);return ; } offs =SPA_MIN (buf->datas[0 ].chunk->offset, buf->datas[0 ].maxsize);
@@ -181,6 +182,8 @@ capture_on_process(void *data)if (filled <0 ) {error_report ("%p: underrun write:%u filled:%d" , p, index, filled); +pw_stream_queue_buffer (v->stream, b); +return ; }else {if ((uint32_t ) filled + n_bytes >RINGBUFFER_SIZE ) { error_report("%p: overrun write:%u filled:%d + size:%u > max:%u",
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 33/40] ui/input: fix integer overflow in qemu_input_scale_axis
In reply to Marc-André LureauThe multiplication of (value - min_in) * range_out can overflow int64_t when both operands are large. Use muldiv64() to compute the scaled result without overflow. Note that muldiv64() takes uint32_t for its multiplier and divisor, which is sufficient here since all function parameters are int (32-bit on all supported host architectures).
Message-ID: <[email protected]>
--- ui/input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
ui/input.c +7 -1
@@ -5,6 +5,7 @@#include "trace.h" #include "ui/input.h" #include "ui/console.h" +#include "qemu/host-utils.h" #include "system/replay.h" #include "system/runstate.h"
@@ -492,11 +493,16 @@ int qemu_input_scale_axis(int value, {int64_t range_in = (int64_t )max_in - min_in;int64_t range_out = (int64_t )max_out - min_out; +int64_t diff = (int64_t )value - min_in; +bool neg; +int64_t scaled;if (range_in <1 ) {return min_out + range_out /2 ; } -return ((int64_t )value - min_in) * range_out / range_in + min_out; + neg = (diff <0 ) != (range_out <0 ); + scaled =muldiv64 (llabs (diff),llabs (range_out),llabs (range_in)); +return (neg ? -scaled : scaled) + min_out; }void qemu_input_queue_rel (QemuConsole *src,InputAxis axis,int value)
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 31/40] ui/console: skip empty update regions in qemu_console_update
In reply to Marc-André LureauAfter clamping coordinates to the surface dimensions, the resulting width or height can be zero. Proceeding with such values would pass degenerate rectangles to display listeners. Return early to avoid useless work.
Message-ID: <[email protected]>
--- ui/console.c | 3 +++ 1 file changed, 3 insertions(+)
ui/console.c +3 -0
@@ -740,6 +740,9 @@ void qemu_console_update(QemuConsole *con, int x, int y, int w, int h) y =MIN (y, height); w =MIN (w, width - x); h =MIN (h, height - y); +if (w <=0 || h <=0 ) { +return ; + }dpy_gfx_update_texture (con, con->surface, x, y, w, h); QLIST_FOREACH(dcl, &s->listeners, next) {
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 12/40] virtio-serial-bus: add terminal resize messages
In reply to Marc-André LureauFrom: Filip Hejsek <[email protected]>
Implement the part of the virtio spec that allows to notify the virtio driver about terminal resizes. Gate the new resize support behind the console-size property, which defaults to off. To implement the property, restore VirtIOSerial::host_features (previously removed by commit d0660e5b7fc7e97926232d13d2500a16df32b310).
The virtio spec contains two methods to inform the guest about console size:
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. Unfortunately, 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 running an old guest kernel, the number of rows and columns will be swapped.
Based on a patch originally written by Szymon Lukasz <[email protected]>, but partially rewritten to fix various corner cases.
Message-ID: <[email protected]>
--- hw/char/trace-events | 1 + hw/char/virtio-serial-bus.c | 81 ++++++++++++++++++++++++++++++++++++++- include/hw/virtio/virtio-serial.h | 7 ++++ 3 files changed, 87 insertions(+), 2 deletions(-)
hw/char/trace-events +1 -0
@@ -11,6 +11,7 @@ serial_update_parameters(uint64_t baudrate, char parity, int data_bits, int stop # virtio-serial-bus.c virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t value) "port %u, event %u, value %u" +virtio_serial_send_console_resize(unsigned int port, uint16_t cols, uint16_t rows) "port %u, cols %u, rows %u" virtio_serial_throttle_port(unsigned int port, bool throttle) "port %u, throttle %d" virtio_serial_handle_control_message(uint16_t event, uint16_t value) "event %u, value %u" virtio_serial_handle_control_message_port(unsigned int port) "port %u"
hw/char/virtio-serial-bus.c +79 -2
120 lines not on this page · raw message
include/hw/virtio/virtio-serial.h +7 -0
@@ -145,6 +145,9 @@ struct VirtIOSerialPort {bool host_connected;/* Do apps not want to receive data? */ bool throttled; + +/* Terminal size reported to the guest. Only used for consoles. */ +uint16_t cols, rows; };/* The virtio-serial bus on top of which the ports will ride as devices */
@@ -186,6 +189,8 @@ struct VirtIOSerial {struct VirtIOSerialPostLoad *post_load;virtio_serial_conf serial; + +uint64_t host_features; };/* Interface to the virtio-serial bus */
@@ -220,5 +225,7 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port);*/ void virtio_serial_throttle_port (VirtIOSerialPort *port,bool throttle); +void virtio_serial_resize_console (VirtIOSerialPort *port, +uint16_t cols,uint16_t rows);#endif
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 24/40] audio/pwaudio: clamp overrun writes to remaining ring buffer space
In reply to Marc-André LureauOn overrun in both capture and playback paths, the code logs an error but proceeds to write the full unclamped size. This advances the write index past read_index + RINGBUFFER_SIZE, causing filled to exceed the buffer capacity on subsequent calls. Once in that state, avail goes negative and the signed/unsigned comparison fails to clamp further writes, leaving the ring buffer in a degenerate state.
Clamp to the remaining space so the write index stays within bounds.
Message-ID: <[email protected]>
--- audio/pwaudio.c | 2 ++ 1 file changed, 2 insertions(+)
audio/pwaudio.c +2 -0
@@ -188,6 +188,7 @@ capture_on_process(void *data)if ((uint32_t ) filled + n_bytes >RINGBUFFER_SIZE ) {error_report ("%p: overrun write:%u filled:%d + size:%u > max:%u" , p, index, filled, n_bytes,RINGBUFFER_SIZE ); + n_bytes =RINGBUFFER_SIZE - (uint32_t )filled; } } spa_ringbuffer_write_data(&v->ring,
@@ -318,6 +319,7 @@ qpw_write(HWVoiceOut *hw, void *data, size_t len)if ((uint32_t ) filled + len >RINGBUFFER_SIZE ) {error_report ("%p: overrun write:%u filled:%d + size:%zu > max:%u" , pw, index, filled, len,RINGBUFFER_SIZE ); + len =RINGBUFFER_SIZE - (uint32_t )filled; } }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 35/40] ui/vnc-jobs: assert rect coordinates and dimensions in vnc_job_add_rect
In reply to Marc-André LureauAll callers guarantee non-negative coordinates and positive dimensions. Add an assert to document the invariant that vnc_worker_clamp_rect relies on.
Message-ID: <[email protected]>
--- ui/vnc-jobs.c | 1 + 1 file changed, 1 insertion(+)
ui/vnc-jobs.c +1 -0
@@ -87,6 +87,7 @@ int vnc_job_add_rect(VncJob *job, int x, int y, int w, int h)trace_vnc_job_add_rect (job->vs, job, x, y, w, h);assert (!QTAILQ_IN_USE (job, next)); +assert (x >=0 && y >=0 && w >0 && h >0 ); entry->rect.x = x; entry->rect.y = y;
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 16/40] hw/display/vga: fix OOB writes after external surface resize
In reply to Marc-André Lureauvirtio-vga has two renderers (VGA core and virtio-gpu) sharing a single QemuConsole, with no invalidation protocol between them. When virtio-gpu replaces the surface (SET_SCANOUT) or destroys it (reset via qemu_console_set_surface(con, NULL)), the VGA renderer's cached geometry (last_scr_width, last_height, last_depth, etc.) is never cleared:vga_common_reset() does not run during a virtio-gpu reset.
The text draw path was fixed by 418396be80 (CVE-2026-77913), but vga_draw_blank() and vga_draw_graphic() still trust stale cache against a foreign surface:
vga_draw_blank() uses last_scr_width/height to memset the display surface. When the surface has been replaced by a smaller one (e.g. after a text-to-graphics mode switch, or a virtio-gpu reset installing a 16x16 placeholder), the memset writes past the surface buffer. Use the actual surface dimensions for the memset bounds instead of the cached last_scr values.
vga_draw_graphic() decides whether to recreate the DisplaySurface based solely on VGA register state (line_offset, width, height, depth, byteswap, allocated). When virtio-gpu replaces the surface with a smaller one, the predicate sees no change and the drawing loop writes a full VGA-geometry frame into the undersized surface. Add surface dimension checks to the predicate so that a foreign surface whose size does not match the VGA geometry triggers a resize before drawing.
Ideally the two renderers could coordinate through a console-level invalidation callback, but these defensive checks are needed regardless as a safety net against any path that replaces the surface.
Fixes: CVE-2026-97889
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4579
Message-ID: <[email protected]>
--- hw/display/vga.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/display/vga.c +5 -3
@@ -1641,7 +1641,9 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) height != s->last_height || s->last_depth != depth || s->last_byteswap != byteswap || - allocate_surface != surface_is_allocated(surface)) { + allocate_surface !=surface_is_allocated (surface) || + disp_width !=surface_width (surface) || + height != surface_height(surface)) { /* display parameters changed -> need new display surface */ s->last_scr_width = disp_width; s->last_scr_height = height;
@@ -1789,9 +1791,9 @@ static void vga_draw_blank(VGACommonState *s, int full_update)qemu_console_set_surface (s->con, surface); } - w = s->last_scr_width *surface_bytes_per_pixel (surface); + w =surface_width (surface) *surface_bytes_per_pixel (surface); d =surface_data (surface); -for (i =0 ; i < s->last_scr_height; i++) { +for (i =0 ; i <surface_height (surface); i++) {memset (d,0 , w); d +=surface_stride (surface); }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 05/40] char-mux: add support for the terminal size
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
The terminal size of a mux chardev should be the same as the real chardev, so listen for CHR_EVENT_RESIZE to be up to date.
We forward CHR_EVENT_RESIZE only to the focused frontend. This means frontends should update their view of the terminal size on receiving CHR_EVENT_MUX_IN.
Message-ID: <[email protected]>
--- chardev/char-mux.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
chardev/char-mux.c +18 -1
@@ -264,9 +264,24 @@ void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event) } } +static void mux_update_winsize (Chardev *chr) +{ +MuxChardev *d =MUX_CHARDEV (chr); +uint16_t cols, rows; + +qemu_chr_fe_get_winsize (&d->chr, &cols, &rows); +qemu_chr_resize (chr, cols, rows); +} +static void mux_chr_event (void *opaque,QEMUChrEvent event) { -mux_chr_send_all_event (CHARDEV (opaque), event); +Chardev *chr =CHARDEV (opaque); + +if (event ==CHR_EVENT_RESIZE ) { +mux_update_winsize (chr); + }else { +mux_chr_send_all_event (chr, event); + } }static GSource *mux_chr_add_watch (Chardev *s,GIOCondition cond)
@@ -378,6 +393,8 @@ static bool mux_chr_open(Chardev *chr, ChardevBackend *backend, Error **errp)return false; } +mux_update_winsize (chr); +/* * Only move to opened state if we've realized * the initial set of muxes:
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 32/40] ui/console: use QLIST_FOREACH_SAFE in dpy_refresh
In reply to Marc-André LureauA display listener's dpy_refresh callback could potentially unregister itself from the listener list, which would invalidate the iteration pointer. Switch to QLIST_FOREACH_SAFE to allow safe removal during traversal.
Message-ID: <[email protected]>
--- ui/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ui/console.c +2 -2
@@ -828,9 +828,9 @@ bool qemu_console_check_format(QemuConsole *con,static void dpy_refresh (DisplayState *s) { -DisplayChangeListener *dcl; +DisplayChangeListener *dcl, *next_dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { + QLIST_FOREACH_SAFE(dcl, &s->listeners, next, next_dcl) {if (dcl->ops->dpy_refresh) { dcl->ops->dpy_refresh (dcl); }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 36/40] chardev/char-pty: free pty_name in finalize
In reply to Marc-André LureauThe pty_name field was added to PtyChardev state but never freed on object finalize, leaking the allocated string.
Message-ID: <[email protected]>
--- chardev/char-pty.c | 1 + 1 file changed, 1 insertion(+)
chardev/char-pty.c +1 -0
@@ -215,6 +215,7 @@ static void char_pty_finalize(Object *obj)unlink (s->path);g_free (s->path); } +g_clear_pointer (&s->pty_name, g_free);pty_chr_state (chr,0 );object_unref (OBJECT (s->ioc));
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 21/40] audio/paaudio: fix server string in PAConnection
In reply to Marc-André Lureauqpa_conn_init() receives a server string but never stores it. Save a copy with g_strdup() and free it in qpa_conn_fini(), as intended in original commit to allow connection reuse.
Message-ID: <[email protected]>
--- audio/paaudio.c | 2 ++ 1 file changed, 2 insertions(+)
audio/paaudio.c +2 -0
@@ -747,6 +747,7 @@ static void qpa_validate_per_direction_opts(Audiodev *dev,static void *qpa_conn_init (const char *server) {PAConnection *c =g_new0 (PAConnection,1 ); + c->server =g_strdup (server);QTAILQ_INSERT_TAIL (&pa_conns, c, list); c->mainloop =pa_threaded_mainloop_new ();
@@ -875,6 +876,7 @@ static void qpa_conn_fini(PAConnection *c) }QTAILQ_REMOVE (&pa_conns, c, list); +g_free (c->server);g_free (c); }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 25/40] audio/pwaudio: fix integer underflow in qpw_read()
In reply to Marc-André Lureauqpw_read() casts len to int32_t for comparison with int32_t avail, which can underflow when avail is negative. Check for non-positive avail first, then cast to size_t for the comparison.
Message-ID: <[email protected]>
--- audio/pwaudio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
audio/pwaudio.c +5 -1
@@ -247,8 +247,12 @@ qpw_read(HWVoiceIn *hw, void *data, size_t len) avail =spa_ringbuffer_get_read_index (&v->ring, &index);trace_pw_read (avail, index, len); +if (avail <=0 ) { + l =0 ; + goto done_unlock; + } -if (avail < (int32_t ) len) { +if ((size_t )avail < len) { len = avail; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 19/40] audio/dbusaudio: fix off-by-one in volume channel assertion
In reply to Marc-André LureauThe assertion vol->channels < sizeof(vol->vol) rejects the valid case where channels exactly equals the array size. Use <= instead.
Message-ID: <[email protected]>
--- audio/dbusaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
audio/dbusaudio.c +2 -2
@@ -242,7 +242,7 @@ dbus_volume_out_listener(HWVoiceOut *hw,return ; } -assert (vol->channels <sizeof (vol->vol)); +assert (vol->channels <=sizeof (vol->vol)); bytes =g_bytes_new (vol->vol, vol->channels); v_vol =g_variant_new_from_bytes (G_VARIANT_TYPE ("ay" ), bytes, TRUE); qemu_dbus_display1_audio_out_listener_call_set_volume(
@@ -332,7 +332,7 @@ dbus_volume_in_listener(HWVoiceIn *hw,return ; } -assert (vol->channels <sizeof (vol->vol)); +assert (vol->channels <=sizeof (vol->vol)); bytes =g_bytes_new (vol->vol, vol->channels); v_vol =g_variant_new_from_bytes (G_VARIANT_TYPE ("ay" ), bytes, TRUE); qemu_dbus_display1_audio_in_listener_call_set_volume(
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 28/40] audio/audio-mixeng-be: add upper bounds to audio settings validation
In reply to Marc-André LureauReject channel counts above 16 and sample rates above 384 kHz in audio_validate_settings(). Without upper bounds, extreme values can cause excessive memory allocation or arithmetic overflow downstream.
Message-ID: <[email protected]>
--- audio/audio-mixeng-be.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
audio/audio-mixeng-be.c +2 -2
@@ -78,7 +78,7 @@ static int audio_validate_settings (const struct audsettings *as) {int invalid; - invalid = as->nchannels <1 ; + invalid = as->nchannels <1 || as->nchannels >16 ;switch (as->fmt) {case AUDIO_FORMAT_S8 :
@@ -94,7 +94,7 @@ static int audio_validate_settings (const struct audsettings *as)break ; } - invalid |= as->freq <=0 ; + invalid |= as->freq <=0 || as->freq >384000 ;return invalid ?-1 :0 ; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 06/40] main-loop: change the handling of SIGWINCH
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
Block SIGWINCH, so it is delivered only via signalfd. Install a handler that uses NotifierList to tell interested parties about SIGWINCH delivery.
Message-ID: <[email protected]>
--- include/qemu/main-loop.h | 5 +++++ ui/curses.c | 21 +++++++++++++++------ util/main-loop.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-)
include/qemu/main-loop.h +5 -0
@@ -449,4 +449,9 @@ typedef struct MainLoopPoll {void main_loop_poll_add_notifier (Notifier *notify);void main_loop_poll_remove_notifier (Notifier *notify); +#ifndef _WIN32 +void sigwinch_add_notifier (Notifier *n); +void sigwinch_remove_notifier (Notifier *n); +#endif +#endif
ui/curses.c +15 -6
@@ -33,6 +33,7 @@#include <iconv.h> #include "qapi/error.h" +#include "qemu/main-loop.h" #include "qemu/module.h" #include "ui/console.h" #include "ui/input.h"
@@ -149,7 +150,7 @@ static void curses_resize(DisplayChangeListener *dcl, } #if !defined(_WIN32) && defined(SIGWINCH) && defined(KEY_RESIZE) -static volatile sig_atomic_t got_sigwinch; +static bool got_sigwinch; static void curses_winch_check(void) { struct winsize {
@@ -172,21 +173,28 @@ static void curses_winch_check(void) invalidate =1 ; } -static void curses_winch_handler (int signum) +static void curses_winch_handler (Notifier *n,void *data) { got_sigwinch = true; } +static Notifier winch_notifier = { + .notify = curses_winch_handler +}; +static void curses_winch_init (void ) { -struct sigaction old, winch = { - .sa_handler = curses_winch_handler, - }; -sigaction (SIGWINCH , &winch, &old); +sigwinch_add_notifier (&winch_notifier); +} + +static void curses_winch_cleanup (void ) +{ +sigwinch_remove_notifier (&winch_notifier); }#else static void curses_winch_check (void ) {}static void curses_winch_init (void ) {} +static void curses_winch_cleanup (void ) {}#endif static void curses_cursor_position(DisplayChangeListener *dcl,
@@ -417,6 +425,7 @@ static void curses_cleanup(void)return ; } +curses_winch_cleanup ();endwin ();qemu_console_unregister_listener (dcl);g_clear_pointer (&dcl, g_free);
util/main-loop.c +33 -0
@@ -100,6 +100,7 @@ static int qemu_signal_init(Error **errp)sigaddset (&set,SIGIO );sigaddset (&set,SIGALRM );sigaddset (&set,SIGBUS ); +sigaddset (&set,SIGWINCH );/* SIGINT cannot be handled via signalfd, so that ^C can be used * to interrupt QEMU when it is being run under gdb. SIGHUP and * SIGTERM are also handled asynchronously, even though it is not
@@ -124,6 +125,38 @@ static int qemu_signal_init(Error **errp)return 0 ; } +static NotifierList sigwinch_notifiers = +NOTIFIER_LIST_INITIALIZER (sigwinch_notifiers); + +static void sigwinch_handler (int signum) +{ +notifier_list_notify (&sigwinch_notifiers,NULL ); +} + +void sigwinch_add_notifier (Notifier *n) +{ +if (notifier_list_empty (&sigwinch_notifiers)) { +struct sigaction action = { + .sa_handler = sigwinch_handler, + }; +sigaction (SIGWINCH , &action,NULL ); + } + +notifier_list_add (&sigwinch_notifiers, n); +} + +void sigwinch_remove_notifier (Notifier *n) +{ +notifier_remove (n); + +if (notifier_list_empty (&sigwinch_notifiers)) { +struct sigaction action = { + .sa_handler =SIG_DFL , + }; +sigaction (SIGWINCH , &action,NULL ); + } +} +#else /* _WIN32 */ static int qemu_signal_init (Error **errp)
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 30/40] ui/clipboard: clean up vm change state handler on last peer unregister
In reply to Marc-André LureauWhen the last clipboard peer unregisters, the vm change state handler is left dangling. Remove it to avoid stale callbacks after all peers are gone.
Message-ID: <[email protected]>
--- ui/clipboard.c | 4 ++++ 1 file changed, 4 insertions(+)
ui/clipboard.c +4 -0
@@ -76,6 +76,10 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer)qemu_clipboard_peer_release (peer, i); }notifier_remove (&peer->notifier); +if (QLIST_EMPTY (&clipboard_notifiers.notifiers)) { +g_clear_pointer (&cb_change_state_entry, + qemu_del_vm_change_state_handler); + } } bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer,
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 26/40] audio/pwaudio: handle negative avail in qpw_write and qpw_buffer_get_free
In reply to Marc-André Lureauqpw_write() and qpw_buffer_get_free() do not handle negative avail (highwater_mark - filled), which can occur transiently. In qpw_buffer_get_free(), clamp to zero. In qpw_write(), bail out early and fix the signed/unsigned comparison with len.
Message-ID: <[email protected]>
--- audio/pwaudio.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
audio/pwaudio.c +8 -1
@@ -286,6 +286,9 @@ static size_t qpw_buffer_get_free(HWVoiceOut *hw) filled =spa_ringbuffer_get_write_index (&v->ring, &index); avail = v->highwater_mark - filled; +if (avail <0 ) { + avail =0 ; + } done_unlock:pw_thread_loop_unlock (c->thread_loop);
@@ -312,8 +315,12 @@ qpw_write(HWVoiceOut *hw, void *data, size_t len) avail = v->highwater_mark - filled;trace_pw_write (filled, avail, index, len); +if (avail <=0 ) { + len =0 ; + goto done_unlock; + } -if (len > avail) { +if (len > (size_t )avail) { len = avail; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 13/40] virtio-console: notify the guest about terminal resizes
In reply to Marc-André LureauFrom: Szymon Lukasz <[email protected]>
If a virtio serial port is a console port, forward terminal resize messages from the chardev backend to the guest.
Message-ID: <[email protected]>
--- hw/char/virtio-console.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)
hw/char/virtio-console.c +31 -3
@@ -107,6 +107,15 @@ static ssize_t flush_buf(VirtIOSerialPort *port,return ret; } +static void virtconsole_update_size (VirtIOSerialPort *port) +{ +uint16_t cols, rows; +VirtConsole *vcon =VIRTIO_CONSOLE (port); + +qemu_chr_fe_get_winsize (&vcon->chr, &cols, &rows); +virtio_serial_resize_console (port, cols, rows); +} +/* Callback function that's called when the guest opens/closes the port */ static void set_guest_connected (VirtIOSerialPort *port,int guest_connected) {
@@ -171,6 +180,23 @@ static void chr_event(void *opaque, QEMUChrEvent event) } } +static void chr_event_console (void *opaque,QEMUChrEvent event) +{ +VirtConsole *vcon = opaque; +VirtIOSerialPort *port =VIRTIO_SERIAL_PORT (vcon); + +trace_virtio_console_chr_event (port->id, event); +switch (event) { +case CHR_EVENT_OPENED : +case CHR_EVENT_MUX_IN : +case CHR_EVENT_RESIZE : +virtconsole_update_size (port); +break ; +default : +break ; + } +} +static int chr_be_change (void *opaque) {VirtConsole *vcon = opaque;
@@ -179,7 +205,9 @@ static int chr_be_change(void *opaque)if (k->is_console) {qemu_chr_fe_set_handlers (&vcon->chr, chr_can_read, chr_read, -NULL , chr_be_change, vcon,NULL , true); + chr_event_console, chr_be_change, + vcon,NULL , true); +virtconsole_update_size (port); }else {qemu_chr_fe_set_handlers (&vcon->chr, chr_can_read, chr_read, chr_event, chr_be_change, vcon,NULL , false);
@@ -207,7 +235,7 @@ static void virtconsole_enable_backend(VirtIOSerialPort *port, bool enable)VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_GET_CLASS (port);qemu_chr_fe_set_handlers (&vcon->chr, chr_can_read, chr_read, - k->is_console ?NULL : chr_event, + k->is_console ? chr_event_console : chr_event, chr_be_change, vcon,NULL , false); }else { qemu_chr_fe_set_handlers(&vcon->chr, NULL, NULL, NULL,
@@ -239,7 +267,7 @@ static void virtconsole_realize(DeviceState *dev, Error **errp)*/ if (k->is_console) {qemu_chr_fe_set_handlers (&vcon->chr, chr_can_read, chr_read, -NULL , chr_be_change, + chr_event_console, chr_be_change, vcon,NULL , true);virtio_serial_open (port); }else {
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 29/40] audio/wavcapture: prevent freq overflow and corrupted WAV header
In reply to Marc-André LureauReject freq <= 0 in wav_start_capture() early, before it is used to compute the WAV header fields.
Message-ID: <[email protected]>
--- audio/wavcapture.c | 6 ++++++ 1 file changed, 6 insertions(+)
audio/wavcapture.c +6 -0
@@ -131,6 +131,12 @@ int wav_start_capture(AudioBackend *state, CaptureState *s, const char *path,return -1 ; } +if (freq <=0 || freq >384000 ) { +error_report ("invalid frequency %d, must be between 1 and 384000" , + freq); +return -1 ; + } + stereo = nchannels ==2 ; bits16 = bits ==16 ;
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 34/40] ui/vnc-enc-zrle: propagate zrle_compress_data error
In reply to Marc-André Lureauzrle_compress_data() returns -1 on failure, but the caller stored the result in a size_t, silently converting the error to a large positive value. Change to int to match the return type, add an Error **errp parameter replacing fprintf to stderr, and check for errors before using the result.
Message-ID: <[email protected]>
--- ui/vnc-enc-zrle.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
ui/vnc-enc-zrle.c +14 -5
@@ -27,6 +27,8 @@*/ #include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" #include "vnc.h" #include "vnc-enc-zrle.h"
@@ -69,7 +71,8 @@ static void *zrle_convert_fb(VncState *vs, VncZrle *zrle,return zrle->fb.buffer; } -static int zrle_compress_data (VncState *vs,VncZrle *zrle,int level) +static int zrle_compress_data (VncState *vs,VncZrle *zrle,int level, +Error **errp) {z_streamp zstream = &zrle->stream;
@@ -85,7 +88,7 @@ static int zrle_compress_data(VncState *vs, VncZrle *zrle, int level) MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);if (err !=Z_OK ) { -fprintf (stderr,"VNC: error initializing zlib\n" ); +error_setg (errp,"ZRLE: error initializing zlib" );return -1 ; }
@@ -104,7 +107,7 @@ static int zrle_compress_data(VncState *vs, VncZrle *zrle, int level)/* start encoding */ if (deflate (zstream,Z_SYNC_FLUSH ) !=Z_OK ) { -fprintf (stderr,"VNC: error during zrle compression\n" ); +error_setg (errp,"ZRLE: error during compression" );return -1 ; }
@@ -256,7 +259,8 @@ static int zrle_send_framebuffer_update(VncState *vs, VncWorker *worker, int x, int y, int w, int h) { bool be = vs->client_endian == G_BIG_ENDIAN; -size_t bytes; +Error *error =NULL ; +int bytes;int zywrle_level;if (worker->zrle.type ==VNC_ENCODING_ZYWRLE ) {
@@ -336,7 +340,12 @@ static int zrle_send_framebuffer_update(VncState *vs, VncWorker *worker, }vnc_zrle_stop (vs, &worker->zrle); - bytes =zrle_compress_data (vs, &worker->zrle,Z_DEFAULT_COMPRESSION ); + bytes =zrle_compress_data (vs, &worker->zrle,Z_DEFAULT_COMPRESSION , + &error); +if (bytes <0 ) { +error_report_err (error); +return -1 ; + }vnc_framebuffer_update (vs, x, y, w, h, worker->zrle.type);vnc_write_u32 (vs, bytes);vnc_write (vs, worker->zrle.zlib.buffer, worker->zrle.zlib.offset);
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 37/40] chardev/char-ringbuf: reject zero size with is_power_of_2
In reply to Marc-André LureauThe power-of-two validation did not reject size=0, since (0 & (0-1)) == 0. With a zero size, the ring buffer mask wraps to SIZE_MAX, causing out-of-bounds memory access. Use is_power_of_2() which handles zero correctly.
Message-ID: <[email protected]>
--- chardev/char-ringbuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-ringbuf.c +2 -1
@@ -27,6 +27,7 @@#include "qapi/error.h" #include "qapi/qapi-commands-char.h" #include "qemu/base64.h" +#include "qemu/host-utils.h" #include "qemu/module.h" #include "qemu/option.h" #include "qom/object.h"
@@ -102,7 +103,7 @@ static bool ringbuf_chr_open(Chardev *chr, d->size = opts->has_size ? opts->size :65536 ;/* The size must be power of 2 */ -if (d->size & (d->size -1 )) { +if (!is_power_of_2 (d->size)) {error_setg (errp,"size of ringbuf chardev must be power of two" );return false; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 39/40] chardev/char-udp: clarify read_poll return value with pending data
In reply to Marc-André LureauAdd a comment explaining why returning s->max_size is safe when there is unflushed data in the buffer: udp_chr_flush_buffer() loops while max_size > 0, so max_size is guaranteed to be 0 when pending data remains.
Message-ID: <[email protected]>
--- chardev/char-udp.c | 4 ++++ 1 file changed, 4 insertions(+)
chardev/char-udp.c +4 -0
@@ -81,6 +81,10 @@ static int udp_chr_read_poll(void *opaque)*/ udp_chr_flush_buffer (s); +/* +* udp_chr_flush_buffer() loops while max_size > 0 && bufptr < bufcnt, +* so when pending data remains it must be because max_size hit 0. +*/ return s->max_size; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 40/40] chardev/char: fix use-after-free on mux creation failure
In reply to Marc-André LureauWhen mux creation fails, object_unparent() drops the last reference on the base chardev, but 'base' was left dangling. The 'out' label then passes it to qemu_chardev_set_replay(), causing a use-after-free.
Set base to NULL after unparent so the replay path is skipped.
Message-ID: <[email protected]>
--- chardev/char.c | 1 + 1 file changed, 1 insertion(+)
chardev/char.c +1 -0
@@ -759,6 +759,7 @@ static Chardev *do_qemu_chr_new_from_opts(QemuOpts *opts, GMainContext *context, mux =qemu_chardev_new (id,TYPE_CHARDEV_MUX , backend, context, errp);if (mux ==NULL ) {object_unparent (OBJECT (chr)); + base =NULL ; chr =NULL ; goto out; }
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 20/40] audio/ossaudio: fix off-by-one in mmap buffer size assertion
In reply to Marc-André Lureauoss_put_buffer_out() asserts size < hw->size_emul, but a write that fills the entire buffer (size == size_emul) is valid. Use <= instead.
Message-ID: <[email protected]>
--- audio/ossaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
audio/ossaudio.c +1 -1
@@ -393,7 +393,7 @@ static size_t oss_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) {OSSVoiceOut *oss = (OSSVoiceOut *) hw;if (oss->mmapped) { -assert (buf == hw->buf_emul + hw->pos_emul && size < hw->size_emul); +assert (buf == hw->buf_emul + hw->pos_emul && size <= hw->size_emul); hw->pos_emul = (hw->pos_emul + size) % hw->size_emul;return size;
Signature · 1 line
2.56.0.116.g6de20f6092dc
[GIT PULL 18/40] audio/ossaudio: fix ioctl passing address-of-pointer instead of pointer
In reply to Marc-André Lureauoss_get_version() passes &version to ioctl(), but version is already an int*, so &version is int** which writes to the wrong address on the stack. Pass version directly.
Message-ID: <[email protected]>
--- audio/ossaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
audio/ossaudio.c +1 -1
@@ -204,7 +204,7 @@ static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, bool *big_endian)#ifdef USE_DSP_POLICY static int oss_get_version (int fd,int *version,const char *typ) { -if (ioctl (fd,OSS_GETVERSION , &version)) { +if (ioctl (fd,OSS_GETVERSION , version)) {#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)/* * Looks like atm (20100109) FreeBSD knows OSS_GETVERSION
Signature · 1 line
2.56.0.116.g6de20f6092dc
Richard Henderson
AppliedQuoted 21 lines · Marc-André Lureau
The following changes since commit
615ece3c406b262996e569f29ea6eed0d81c4d8d:Merge tag 'for-upstream' ofhttps://gitlab.com/bonzini/qemu into staging (2026-10-09 15:49:53 +0200)are available in the Git repository at:
https://gitlab.com/marcandre.lureau/qemu.git tags/ui-pr-v1
for you to fetch changes up to
919711cab29776f12209b375a4db251007c6d96e:chardev/char: fix use-after-free on mux creation failure (2026-10-13 17:22:49 +0400)----------------------------------------------------------------
UI, Audio & Chardev fixes + Terminal Resize SupportAdds end-to-end support for propagating terminal size changes from the host to the guest. This includes a new
CHR_EVENT_RESIZEchardev event,qemu_chr_resize()API, a chardev-window-size-changed QMP command, SIGWINCH handling, and wiring through mux/stdio/win-stdio chardevs, virtio-serial, virtio-console, GTK, and text console backends.
Quoted 3 lines
- collect ui, audio, chardev and display fixes
Signed-off-by Marc-André Lureau<[email protected]>
Applied, thanks.
r~