[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.0.4 20/57] ui/dbus: fix filtering all update messages
From: |
Michael Tokarev |
Subject: |
[Stable-9.0.4 20/57] ui/dbus: fix filtering all update messages |
Date: |
Sat, 9 Nov 2024 15:07:22 +0300 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Filtering pending messages when a new scanout is given shouldn't discard
pending cursor changes, for example.
Since filtering happens in a different thread, use atomic set/get.
Fixes: fa88b85dea ("ui/dbus: filter out pending messages when scanout")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-ID: <20241008125028.1177932-6-marcandre.lureau@redhat.com>
(cherry picked from commit cf59889781297a5618f1735a5f31402caa806b42)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c
index 83140f602d..b4b7e2666b 100644
--- a/ui/dbus-listener.c
+++ b/ui/dbus-listener.c
@@ -26,6 +26,7 @@
#include "qapi/error.h"
#include "sysemu/sysemu.h"
#include "dbus.h"
+#include "glib.h"
#ifdef G_OS_UNIX
#include <gio/gunixfdlist.h>
#endif
@@ -85,7 +86,7 @@ struct _DBusDisplayListener {
#endif
guint dbus_filter;
- guint32 out_serial_to_discard;
+ guint32 display_serial_to_discard;
};
G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listener, G_TYPE_OBJECT)
@@ -93,10 +94,12 @@ G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listener,
G_TYPE_OBJECT)
static void dbus_gfx_update(DisplayChangeListener *dcl,
int x, int y, int w, int h);
-static void ddl_discard_pending_messages(DBusDisplayListener *ddl)
+static void ddl_discard_display_messages(DBusDisplayListener *ddl)
{
- ddl->out_serial_to_discard = g_dbus_connection_get_last_serial(
+ guint32 serial = g_dbus_connection_get_last_serial(
g_dbus_proxy_get_connection(G_DBUS_PROXY(ddl->proxy)));
+
+ g_atomic_int_set(&ddl->display_serial_to_discard, serial);
}
#ifdef CONFIG_OPENGL
@@ -285,7 +288,7 @@ static void dbus_scanout_dmabuf(DisplayChangeListener *dcl,
return;
}
- ddl_discard_pending_messages(ddl);
+ ddl_discard_display_messages(ddl);
/* FIXME: add missing x/y/w/h support */
qemu_dbus_display1_listener_call_scanout_dmabuf(
@@ -334,7 +337,7 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl)
return false;
}
- ddl_discard_pending_messages(ddl);
+ ddl_discard_display_messages(ddl);
if (!qemu_dbus_display1_listener_win32_map_call_scanout_map_sync(
ddl->map_proxy,
@@ -397,7 +400,7 @@ dbus_scanout_share_d3d_texture(
return false;
}
- ddl_discard_pending_messages(ddl);
+ ddl_discard_display_messages(ddl);
qemu_dbus_display1_listener_win32_d3d11_call_scanout_texture2d(
ddl->d3d11_proxy,
@@ -654,7 +657,7 @@ static void ddl_scanout(DBusDisplayListener *ddl)
surface_stride(ddl->ds) * surface_height(ddl->ds), TRUE,
(GDestroyNotify)pixman_image_unref, pixman_image_ref(ddl->ds->image));
- ddl_discard_pending_messages(ddl);
+ ddl_discard_display_messages(ddl);
qemu_dbus_display1_listener_call_scanout(
ddl->proxy, surface_width(ddl->ds), surface_height(ddl->ds),
@@ -987,17 +990,35 @@ dbus_filter(GDBusConnection *connection,
gpointer user_data)
{
DBusDisplayListener *ddl = DBUS_DISPLAY_LISTENER(user_data);
- guint32 serial;
+ guint32 serial, discard_serial;
if (incoming) {
return message;
}
serial = g_dbus_message_get_serial(message);
- if (serial <= ddl->out_serial_to_discard) {
- trace_dbus_filter(serial, ddl->out_serial_to_discard);
- g_object_unref(message);
- return NULL;
+
+ discard_serial = g_atomic_int_get(&ddl->display_serial_to_discard);
+ if (serial <= discard_serial) {
+ const char *member = g_dbus_message_get_member(message);
+ static const char *const display_messages[] = {
+ "Scanout",
+ "Update",
+#ifdef CONFIG_GBM
+ "ScanoutDMABUF",
+ "UpdateDMABUF",
+#endif
+ "ScanoutMap",
+ "UpdateMap",
+ "Disable",
+ NULL,
+ };
+
+ if (g_strv_contains(display_messages, member)) {
+ trace_dbus_filter(serial, discard_serial);
+ g_object_unref(message);
+ return NULL;
+ }
}
return message;
--
2.39.5
- [Stable-9.0.4 10/57] vnc: fix crash when no console attached, (continued)
- [Stable-9.0.4 10/57] vnc: fix crash when no console attached, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 11/57] linux-user/flatload: Take mmap_lock in load_flt_binary(), Michael Tokarev, 2024/11/09
- [Stable-9.0.4 13/57] tcg/ppc: Use TCG_REG_TMP2 for scratch tcg_out_qemu_st, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 12/57] linux-user: Fix parse_elf_properties GNU0_MAGIC check, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 15/57] target/m68k: Always return a temporary from gen_lea_mode, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 14/57] tcg/ppc: Use TCG_REG_TMP2 for scratch index in prepare_host_addr, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 16/57] hw/intc/arm_gicv3_cpuif: Add cast to match the documentation, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 17/57] hw/audio/hda: free timer on exit, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 18/57] ui/dbus: fix leak on message filtering, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 19/57] ui/win32: fix potential use-after-free with dbus shared memory, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 20/57] ui/dbus: fix filtering all update messages,
Michael Tokarev <=
- [Stable-9.0.4 21/57] tcg/s390x: fix constraint for 32-bit TSTEQ/TSTNE, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 23/57] tests: Wait for migration completion on destination QEMU to avoid failures, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 24/57] Revert "hw/sh4/r2d: Realize IDE controller before accessing it", Michael Tokarev, 2024/11/09
- [Stable-9.0.4 25/57] tests/qemu-iotests/211.out: Update to expect MapEntry 'compressed' field, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 22/57] KVM: Dynamic sized kvm memslots array, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 27/57] tcg: Reset data_gen_ptr correctly, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 26/57] raw-format: Fix error message for invalid offset/size, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 28/57] target/i386: Walk NPT in guest real mode, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 30/57] linux-user: Emulate /proc/self/maps under mmap_lock, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 29/57] target/i386: Use probe_access_full_mmu in ptw_translate, Michael Tokarev, 2024/11/09