From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Laurent Vivier" <lvivier@redhat.com>,
"Alex Williamson" <alex@shazbot.org>,
"Cédric Le Goater" <clg@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>
Subject: Re: [PATCH v2 13/33] ui/spice: add cleanup on shutdown
Date: Mon, 8 Jun 2026 10:42:31 +0100 [thread overview]
Message-ID: <aiaOh9w3KPkB1urR@redhat.com> (raw)
In-Reply-To: <20260608-b4-ui-v2-13-9ea6355ea08f@redhat.com>
On Mon, Jun 08, 2026 at 11:16:31AM +0400, Marc-André Lureau wrote:
> SPICE resources were never freed on shutdown. Add per-subsystem
> cleanup (display, input, core) and call it from qemu_cleanup().
>
> Move spice-module.c into libui so the qemu_spice ops table links
> with the rest of the UI code. Add an LSan suppression for a known
> spice-server leak.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/ui/qemu-spice-module.h | 1 +
> include/ui/qemu-spice.h | 2 ++
> system/runstate.c | 4 ++++
> ui/spice-core.c | 25 ++++++++++++++++++--
> ui/spice-display.c | 52 ++++++++++++++++++++++++++++++++++++++++++
> ui/spice-input.c | 52 ++++++++++++++++++++++++++++--------------
> ui/spice-module.c | 5 ++++
> scripts/lsan_suppressions.txt | 5 ++++
> ui/meson.build | 4 ++--
> 9 files changed, 129 insertions(+), 21 deletions(-)
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index e3716127203..75c7df7bb5e 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -34,6 +34,8 @@ bool spice_opengl;
> bool spice_remote_client;
> int spice_max_refresh_rate;
>
> +static GPtrArray *spice_displays;
> +
> int qemu_spice_rect_is_empty(const QXLRect* r)
> {
> return r->top == r->bottom || r->left == r->right;
> @@ -1421,6 +1423,54 @@ static void qemu_spice_display_init_one(QemuConsole *con)
> qemu_console_set_display_gl_ctx(con, &ssd->dgc);
> }
> qemu_console_register_listener(con, &ssd->dcl, ops);
> + g_ptr_array_add(spice_displays, ssd);
> +}
> +
> +void qemu_spice_display_cleanup(void)
Nitpicking, I would suggest separating it so that we have
qemu_spice_displays_cleanup(void)
and
qemu_spice_display_cleanup(SimpleSpiceDisplay *ssd)
> +{
> + if (!spice_displays) {
> + return;
> + }
> +
> + for (guint i = 0; i < spice_displays->len; i++) {
> + SimpleSpiceDisplay *ssd = g_ptr_array_index(spice_displays, i);
> + SimpleSpiceUpdate *update;
> +
> + qemu_console_unregister_listener(&ssd->dcl);
> +#ifdef HAVE_SPICE_GL
> + if (spice_opengl) {
> + qemu_console_set_display_gl_ctx(ssd->dcl.con, NULL);
> + }
> +#endif
> +
> + if (ssd->ds) {
> + qemu_spice_destroy_host_primary(ssd);
> + }
> + qemu_spice_del_memslot(ssd, MEMSLOT_GROUP_HOST, 0);
> + spice_server_remove_interface(&ssd->qxl.base);
> +
> + while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
> + QTAILQ_REMOVE(&ssd->updates, update, next);
> + qemu_spice_destroy_update(ssd, update);
> + }
> + g_clear_pointer(&ssd->ptr_define, g_free);
> + g_clear_pointer(&ssd->ptr_move, g_free);
> + g_clear_pointer(&ssd->cursor, cursor_unref);
> + g_clear_pointer(&ssd->surface, pixman_image_unref);
> + g_clear_pointer(&ssd->mirror, pixman_image_unref);
> + g_clear_pointer(&ssd->buf, g_free);
> +#ifdef HAVE_SPICE_GL
> + g_clear_pointer(&ssd->gl_unblock_bh, qemu_bh_delete);
> + g_clear_pointer(&ssd->gl_unblock_timer, timer_free);
> + g_clear_pointer(&ssd->gls, qemu_gl_fini_shader);
> + egl_fb_destroy(&ssd->guest_fb);
> + egl_fb_destroy(&ssd->blit_fb);
> + egl_fb_destroy(&ssd->cursor_fb);
> +#endif
> + qemu_mutex_destroy(&ssd->lock);
> + g_free(ssd);
> + }
> + g_clear_pointer(&spice_displays, g_ptr_array_unref);
> }
None the less
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-06-08 9:43 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 7:16 [PATCH v2 00/33] ui: better console hotplug support Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 01/33] ui/gtk: fix bad widget realize on non-GFX VC Marc-André Lureau
2026-06-08 8:56 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 02/33] build-sys: build with -fno-omit-frame-pointer with ASAN Marc-André Lureau
2026-06-08 8:58 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 03/33] irq: add per-IRQ observer to fix qemu_irq_intercept_in leak Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 04/33] scripts/lsan_suppressions: suppress fontconfig leaks Marc-André Lureau
2026-06-08 9:09 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 05/33] vfio/pci: close display console during unrealize, not finalize Marc-André Lureau
2026-06-08 12:50 ` Cédric Le Goater
2026-06-08 7:16 ` [PATCH v2 06/33] glib-compat: add fallback for g_clear_fd/g_autofd Marc-André Lureau
2026-06-08 9:11 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 07/33] ui/dbus: remove mouse handler on dispose Marc-André Lureau
2026-06-08 9:12 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 08/33] ui/dbus: remove led handler Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 09/33] ui/qmp: keep a reference of console across yield Marc-André Lureau
2026-06-08 9:16 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 10/33] ui: stop ui timer when closing Marc-André Lureau
2026-06-08 9:16 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 11/33] ui/console: init gl_unblock_timer in qemu_console_init Marc-André Lureau
2026-06-08 9:17 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 12/33] ui/spice: remove dead spice_displays Marc-André Lureau
2026-06-08 9:18 ` Daniel P. Berrangé
2026-06-08 7:16 ` [PATCH v2 13/33] ui/spice: add cleanup on shutdown Marc-André Lureau
2026-06-08 9:42 ` Daniel P. Berrangé [this message]
2026-06-08 7:16 ` [PATCH v2 14/33] ui: add display cleanup infrastructure Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 15/33] ui/curses: implement display cleanup Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 16/33] ui/sdl2: " Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 17/33] ui/spice-app: " Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 18/33] ui/egl: implement display and EGL cleanup Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 19/33] ui/cocoa: implement display cleanup Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 20/33] ui/dbus: " Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 21/33] ui/gtk: " Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 22/33] ui/console: add console event notifier infrastructure Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 23/33] ui/console: fire console ADDED/REMOVED notifications Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 24/33] ui/console-vc: fire " Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 25/33] ui/gtk: convert VirtualConsole storage from fixed array to GPtrArray Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 26/33] ui/gtk: move global display settings out of per-console init Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 27/33] ui/gtk: fix tab re-insertion order on window close Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 28/33] ui/gtk: centralize console menu and shortcut management Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 29/33] ui/gtk: handle console hotplug/unplug events Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 30/33] ui/console: register console in QOM tree dynamically Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 31/33] ui/console: unregister console from QOM tree on close Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 32/33] ui/dbus: handle console hotplug/unplug events Marc-André Lureau
2026-06-08 7:16 ` [PATCH v2 33/33] tests/qtest: add D-Bus display hotplug test Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiaOh9w3KPkB1urR@redhat.com \
--to=berrange@redhat.com \
--cc=alex@shazbot.org \
--cc=clg@redhat.com \
--cc=farosas@suse.de \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.