2472 Commits

Author SHA1 Message Date
Marc-André Lureau
c6e94d24fb ui/console: return completion status from gfx_update callback
Replace the two-field design (gfx_update void callback + gfx_update_async
flag) with a single bool return value from gfx_update. Returning true
means the update completed synchronously and graphic_hw_update_done()
should be called by the console layer. Returning false means the update
is deferred and the device will call graphic_hw_update_done() itself
later (as done by QXL/SPICE and Apple GFX).

This simplifies the interface and makes the async contract explicit at
each call site rather than relying on a separate struct field.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-04-28 18:53:58 +04:00
Marc-André Lureau
049f422117 ui/console: remove qemu_console_is_visible()
Drop the bookkeeping, we can simply afford an empty "foreach".

Notice that dpy_gfx_update_texture() is now called even when there are
no listeners. This is more correct, as the texture is not fully
refreshed when a listener connects, so it may be outdated/garbaged.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-28 18:39:36 +04:00
Marc-André Lureau
d276ad86eb ui: rename init_keyboard_layout->kbd_layout_new()
Use a more convential name.

Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-28 18:39:36 +04:00
Marc-André Lureau
fbea9d550a ui: minor code simplification
Drop memset() usage.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-28 18:39:36 +04:00
Marc-André Lureau
5a3bb1df57 ui: make unregister_displaychangelistener() skip unregistered
If the listener doesn't have associate ds / display state, it is already
unregistered.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-28 18:39:36 +04:00
Marc-André Lureau
842ef95b81 ui: make qemu_default_pixelformat() static inline
The function is a trivial wrapper around qemu_default_pixman_format()
and qemu_pixelformat_from_pixman(), so make it static inline in
qemu-pixman.h instead of a standalone function in console.c, allowing to
be easily reused.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-28 18:39:36 +04:00
Marc-André Lureau
dcc580c8d8 ui: move DisplaySurface functions to display-surface.c
Extract DisplaySurface creation and destruction functions from console.c
into their own file to reduce the size of console.c and improve code
organization.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-28 18:39:36 +04:00
Marc-André Lureau
690fbfcd98 ui: move FONT_WIDTH/HEIGHT to vgafont.h
Since those values are related to the VGA font, it make sense to move
them here.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-28 18:39:36 +04:00
Philippe Mathieu-Daudé
50362dd65a qom: Declare compat properties API in 'qom/compat-properties.h'
While most of QEMU files use the QOM concept, few of them
use the compatibility properties API (mostly use in system
emulation). Move its prototype to a new "qom/compat-properties.h"
header, keeping "qom/object.h" for generic QOM.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20260325151728.45378-5-philmd@linaro.org>
2026-04-24 21:27:21 +02:00
Stefan Hajnoczi
4bde339ecb Merge tag 'pull-11.1-virtio-gpu-hotfixes-230426-1' of https://gitlab.com/stsquad/qemu into staging
virtio-gpu fixes:

  - fix build on Windows due to EGL assumption
  - fix use-after-free on virgl resource

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmnqN/sACgkQ+9DbCVqe
# KkR+cAf+INMexc1Wzc81XUs3UamDOPQmIKTu/36P7K3PrVwvwtb/KhIjlgsiUDjy
# thP9wZcMVJNA8heCFOp3kMzydEBbZ3Ywiz5TWulrvGrwBwPDf93+bTlgr1cDzDwI
# bi2CjR4NUHtICGC/6Smh9UbRLMh5FkGB/XpyXr+Gkl+THT4s+evQXP8xYuvbfKZj
# qKsxz2oaCZNqYJRfUPBxNLaiS7VRGVJBaOLSuhLUegQZ4T0CzcyprOfreOfjolwC
# hmGcC1w/Sb1EJZkgE9ZKi30AMXS4NuHfMXHNCI76xIMYd/c9/B19AVUv3ZVIbuNs
# vAdamiBnIRffPLGhttOqhLCndNHGHA==
# =uXFe
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 23 Apr 2026 11:17:15 EDT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* tag 'pull-11.1-virtio-gpu-hotfixes-230426-1' of https://gitlab.com/stsquad/qemu:
  hw/display: don't accidentally autofree existing virgl resources
  ui/sdl2: Fix assumption of EGL presence at runtime

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-04-23 20:51:57 -04:00
Anthony Roberts
7077c83f71 ui/sdl2: Fix assumption of EGL presence at runtime
The original commit had a section of code which worked on the assumption
that if OpenGL was enabled at build, it was present on the end user machine,
and calls could be made to it. This is not always the case (such as Windows
on Arm devices).

This line should have also included a runtime check.

This commit moves the relevant line to inside a runtime check for OpenGL.

Fixes: 52053b7e0a ("ui/sdl2: Implement dpy dmabuf functions")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3347
Cc: qemu-stable@nongnu.org
Signed-off-by: Anthony Roberts <anthony.roberts@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20260409110256.684-1-anthony.roberts@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2026-04-23 16:13:36 +01:00
Marc-André Lureau
57c65e56e2 ui/vnc: explicitly link with png
The VNC code uses PNG directly.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:53:31 +04:00
Marc-André Lureau
58df32284e ui/vnc: remove left-over dead code
Since commit 5994dcb8d8 ("ui, monitor: remove deprecated VNC ACL option
and HMP commands"), this field is no longer used.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:53:29 +04:00
Marc-André Lureau
812ec936cd ui/vnc: make vnc_disconnect_finish() private
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:53:02 +04:00
Marc-André Lureau
1f9c9387b0 ui/vnc: fix vnc_display_init() leak on failure
Do not add the display state to the vnc list, if the initialization
failed. Add vnc_display_free(), to free the display state and associated
data in such case. The function is meant to be public and reused in the
following changes.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:52:56 +04:00
Marc-André Lureau
f6e25abf09 ui/keymaps: introduce kbd_layout_free()
Enable callers to properly tear down keyboard layouts.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:52:47 +04:00
Marc-André Lureau
9bd3bdd6ba ui/vnc: VncDisplay.id is not const
s/strdup/g_strdup to highlight the issue and be consistent with other
allocations.

The next patch is going to introduce vnc_display_free() to take care of
deallocating it.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:52:15 +04:00
Marc-André Lureau
f3cec33f08 ui/vnc: simplify vnc_init_func error handling
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:52:12 +04:00
Marc-André Lureau
2823b97cb1 ui/vnc: assert preconditions instead of silently returning
Replace defensive NULL guards with assert() in vnc_display_close()
and vnc_display_open(). These are internal functions whose callers
guarantee non-NULL arguments, so a NULL value would indicate a
programming error rather than a runtime condition.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:52:09 +04:00
Marc-André Lureau
edd36fa49a ui/vgafont: add SPDX license header
The vgafont was added without source origin, but it can be traced back
to Linux kernel, which used
GPL-2 (https://github.com/mpe/linux-fullhistory/blob/master/lib/fonts/font_8x16.c).

commit c6f37d0e4f
Author: Fabrice Bellard <fabrice@bellard.org>
Date:   Wed Jul 14 17:39:50 2004 +0000

    virtual console

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:51:23 +04:00
Marc-André Lureau
899d9fc33a ui: avoid duplicating vgafont16 in each translation unit
vgafont.h defined vgafont16 as a static const array, so every .c file
that included it (via console-priv.h) got its own 4 KiB copy, that
the linker may or not deduplicate?

Move the array definition into a new vgafont.c compilation unit and
turn the header into a proper extern declaration with an include guard.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:51:21 +04:00
Marc-André Lureau
54293f80a9 ui/console-vc: unify the write path
VT100 escape responses (DSR) used qemu_chr_be_write() to write directly
to the chardev backend, bypassing the output FIFO, while keyboard input
went through the FIFO and flush path. This inconsistency could lead to
out-of-order delivery when both paths are active.

Introduce qemu_text_console_write() that pushes data into the output
FIFO and flushes it, and use it for both keyboard input and VT100
responses. Remove the now-unnecessary vc_respond_str() helper. Rename
kbd_send_chars() to qemu_text_console_flush() to better reflect its
purpose.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:50:19 +04:00
Marc-André Lureau
f93cc8f331 ui/console-vc: move vc_put_lf() to VT100 layer as vt100_put_lf()
Decouple the line-feed handling from VCChardev by operating on
QemuVT100 directly. The function no longer needs the chardev or
console pointers — callers pass &s->vt instead. This continues the
effort to make the VT100 terminal emulation self-contained.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:50:12 +04:00
Marc-André Lureau
4da64afc29 ui/console-vc: refactor text_console_resize() into vt100_set_image()
Decouple the resize logic from QemuTextConsole by operating on
QemuVT100 and taking a pixman_image_t directly, instead of reaching
into the console's scanout surface. The callers now pass the image
explicitly, which makes the VT100 layer independent of the console
object hierarchy.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:52 +04:00
Marc-André Lureau
76ee1d2358 ui/console-vc: console_scroll() -> vt100_scroll()
This decouples glyph rendering from the console object, continuing the
QemuVT100 abstraction introduced in the previous commits.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:29 +04:00
Marc-André Lureau
cddc99e81c ui/console-vc: move cursor blinking logic into VT100 layer
Maintain a list of QemuVT100 instances so the cursor timer can directly
iterate over them and call vt100_refresh(), instead of going through
qemu_invalidate_text_consoles() which iterated over all consoles
(including graphic ones) and called back into the generic display layer.

This removes the qemu_invalidate_text_consoles() function from
console.c, further decoupling VT100 text rendering from the console
core.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:26 +04:00
Marc-André Lureau
1e4ded80b1 ui/console-vc: console_refresh() -> vt100_refresh()
This decouples glyph rendering from the console object, continuing the
QemuVT100 abstraction introduced in the previous commits.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:21 +04:00
Marc-André Lureau
3faf2b0ae1 ui/console-vc: decouple VT100 display updates via function pointer
Replace direct dpy_gfx_update() calls from the VT100 emulation code
with an indirect call through a new image_update function pointer in
QemuVT100. This decouples the VT100 terminal emulation from the
QEMU display layer, allowing different backends to provide their own
image update implementation.

The QemuVT100 typedef is changed to a forward-declared struct so the
function pointer signature can reference QemuVT100 itself.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:19 +04:00
Marc-André Lureau
130f8fbd55 ui/console-vc: make show_cursor() take vt100
Decouples glyph rendering from the console object,
continuing the QemuVT100 abstraction introduced in the previous commits.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:15 +04:00
Marc-André Lureau
1cce59bb82 ui/console-vc: make invalidate_xy() take vt100
This decouples glyph rendering from the console object, continuing the
QemuVT100 abstraction introduced in the previous commits.

Style fixes.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:10 +04:00
Marc-André Lureau
80eea7dd75 ui/console-vc: vga_putcharxy()->vt100_putcharxy()
Have the character rendering function operate on QemuVT100 directly
instead of taking a QemuConsole and extracting the VT100 state
internally. This decouples glyph rendering from the console object,
continuing the QemuVT100 abstraction introduced in the previous commits.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:08 +04:00
Marc-André Lureau
62fe54d284 ui/console-vc: set vt100 associated pixman image
Start removing dependency on DisplaySurface for vt100 handling.

Note that before, the rendering is done on the current DisplaySurface.
It's not obvious the QemuTextConsole associated surface isn't changed
over time, in particular if it was doing resize. But
qemu_console_resize() is only implemented for QemuGraphicConsole.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:49:02 +04:00
Marc-André Lureau
cd579196da ui/console-vc: introduce QemuVT100
Start moving VT100 emulation specific code in a different structure.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:48:56 +04:00
Marc-André Lureau
6640883afc ui/console: dispatch get_label() through QOM virtual method
Replace the type-checking chain in qemu_console_get_label() (using
QEMU_IS_GRAPHIC_CONSOLE/QEMU_IS_TEXT_CONSOLE) with a QemuConsoleClass
virtual method, allowing each console subclass to provide its own
get_label implementation.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:48:43 +04:00
Marc-André Lureau
8502b70f6e ui/console-vc: fix comment shift-out/in comments
14 is shift-out
15 is shift-in

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:48:41 +04:00
Marc-André Lureau
a53a41a545 ui/console-vc: ignore string-type escape sequences
Modern terminals and applications emit OSC (Operating System Command),
DCS, SOS, PM, and APC escape sequences (e.g. for setting window
titles).  The text console currently does not recognise these
string-type introducers, so each byte of the payload is interpreted as
a normal character or a new escape, producing garbage on screen.

Add a TTY_STATE_OSC state that silently consumes all bytes until the
sequence is terminated by BEL or ST (ESC \).

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:48:36 +04:00
Marc-André Lureau
181fdf8a7e ui/console-vc: fix off-by-one in CSI J 2 (clear entire screen)
The loop condition used `y <= s->height` instead of `y < s->height`,
causing vc_clear_xy() to be called with y == s->height. This clears
a row in the scrollback buffer beyond the visible screen.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:48:03 +04:00
Marc-André Lureau
4f6c5f8fe1 ui/vnc-jobs: drop redundant (and needless) qemu_thread_get_self()
The call is unnecessary, since "thread" is already set at creation time.
Furthermore, the "thread" field is mostly useless as the thread is
created DETACHED and isn't used for anything but perhaps debugging.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:48:01 +04:00
Marc-André Lureau
ed4c1c716d ui/vnc-jobs: narrow taking the queue lock
It's not needed unless manipulating the queue.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:47:59 +04:00
Marc-André Lureau
e79175c737 ui/vnc-jobs: remove vnc_queue_clear()
The function was never called, since the worker thread was never
exiting. Also it was incomplete (not clearing pending job list) and
mixing global queue and argument. Let's remove it.

Note: maybe the worker thread could be torn down when vnc_jobs_join()
realizes there is no job left.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:47:57 +04:00
Marc-André Lureau
a74cd53637 ui/vnc-jobs: remove dead VncJobQueue.exit
Since commit 09526058d0 ("ui/vnc: Remove vnc_stop_worker_thread()"),
it's not used anymore. It seems stopping worker thread hasn't been
supported ever.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:47:55 +04:00
Marc-André Lureau
3620f3bab7 ui/vnc-jobs: vnc_has_job_locked() argument cannot be NULL
The only caller, vnc_jobs_join() cannot take vs == NULL argument, or it
would later crash.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:47:54 +04:00
Marc-André Lureau
58f1f386b8 ui/vnc: clarify intent using buffer_empty() function
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:47:52 +04:00
Marc-André Lureau
3125f0fcf5 ui/vnc-jobs: remove needless buffer_reset() before end
vnc_async_encoding_end() does buffer_free() next.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:47:50 +04:00
GuoHan Zhao
208dfd7d08 ui/clipboard: clear deferred serial reset flag on resume
cb_reset_serial_on_resume defers a clipboard serial reset until the
machine runs again. qemu_clipboard_change_state() performs that reset
on resume, but leaves the flag set.

As a result, every later transition back to RUNNING triggers another
QEMU_CLIPBOARD_RESET_SERIAL notification even when no reset is pending.
That causes unnecessary reset handling in clipboard backends such as
vdagent and dbus.

Clear the deferred flag before resetting so the reset is performed only
once for each deferred request.

Fixes: c967ff606b ("ui/clipboard: delay clipboard update when not running")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260416070403.1683648-1-zhaoguohan@kylinos.cn>
2026-04-22 12:46:04 +04:00
GuoHan Zhao
52cf667ed2 ui/spice-app: detect runtime directory creation failures
spice_app_display_early_init() creates the per-VM runtime directory
with g_mkdir_with_parents() before setting up the Spice socket. The
code checks for "< -1", but g_mkdir_with_parents() returns -1 on
failure, so the error path is never taken.

This lets spice-app continue after a directory creation failure and
defers the problem to later setup steps.

Check for "< 0" instead so the failure is reported immediately and
spice-app exits before using an invalid runtime directory.

Fixes: d8aec9d9f1 ("display: add -display spice-app launching a Spice client")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260408031725.641417-1-zhaoguohan@kylinos.cn>
2026-04-22 12:37:44 +04:00
GuoHan Zhao
ee4ffe99dd ui/input-linux: close evdev fd when qemu_set_blocking fails
input_linux_complete() opens the evdev node before switching it to
non-blocking mode. If qemu_set_blocking() fails, the function returns
without closing the file descriptor.

The finalize path only closes initialized devices, so this leaks the fd
on an error path.

Jump to err_close when qemu_set_blocking() fails so the descriptor is
released before returning.

Fixes: c7b1172026 ("ui: replace qemu_set_nonblock()")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260408024024.606222-1-zhaoguohan@kylinos.cn>
2026-04-22 12:36:59 +04:00
Marc-André Lureau
eea54988fd ui/vnc-jobs: clear source tag
Avoid potentially removing a dangling source & simplify code.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-03-30 14:05:15 +04:00
Marc-André Lureau
3cae0b46be ui/vnc-jobs: fix VncRectEntry leak on job cleanup
When a VncJob is freed, its associated VncRectEntry list must also be
freed. Previously, vnc_job_push() and the disconnected path in
vnc_worker_thread_loop() called g_free(job) directly, leaking all
VncRectEntry allocations.

Introduce vnc_job_free() which iterates and frees the rectangle entries
before freeing the job itself, and use it in both paths.

Also add QLIST_REMOVE() in the worker loop before g_free(entry), so
that entries processed during normal operation are properly unlinked.
Without this, vnc_job_free() would iterate dangling pointers to
already-freed entries, causing use-after-free.

Fixes: bd023f953e ("vnc: threaded VNC server")
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-03-30 14:05:10 +04:00
GuoHan Zhao
e5ef268596 ui/dbus: tear down clipboard callbacks on display finalize
The clipboard D-Bus teardown path currently runs when the peer
disappears, but not when DBusDisplay itself is finalized.

That leaves pending clipboard requests and signal handlers associated
with the clipboard proxy active past display teardown.

Add an explicit clipboard fini hook and invoke it from
dbus_display_finalize() so the clipboard teardown also runs during
display destruction.

bixes: ff1a5810f6 ("ui/dbus: add clipboard interface")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Message-ID: <20260330091310.42868-1-zhaoguohan@kylinos.cn>
[ Marc-André - Move clipobard finalization to the function]
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-03-30 14:02:33 +04:00