[PATCH] ui/dbus: forward guest clipboard grabs that lack a serial

Rick Vernam posted 1 patch 2 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260907211233.501672-1-rtvernam@gmail.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/dbus-clipboard.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ui/dbus: forward guest clipboard grabs that lack a serial
Posted by Rick Vernam 2 weeks, 4 days ago
dbus_clipboard_update_info() drops any incoming grab whose
QemuClipboardInfo has no serial number:

    if (self_update || !info->has_serial) {
        return;
    }

For grabs coming from ui/vdagent.c, has_serial is only set when the
guest's vdagent client has negotiated VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL
(see vdagent_clipboard_recv_grab()). When the guest doesn't negotiate
it, the grab is silently dropped here and never forwarded to the
D-Bus display client via Clipboard.Grab.

It seems other protocols (ui/gtk-clipboard.c, ui/vnc-clipboard.c) do not
incorporate a validation on has_serial, so this patch matches their
behavior.

Signed-off-by: Rick Vernam <rtvernam@gmail.com>
---
 ui/dbus-clipboard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/dbus-clipboard.c b/ui/dbus-clipboard.c
index 90318384ee..1389ec0edc 100644
--- a/ui/dbus-clipboard.c
+++ b/ui/dbus-clipboard.c
@@ -72,7 +72,7 @@ dbus_clipboard_update_info(DBusDisplay *dpy, QemuClipboardInfo *info)
         return;
     }
 
-    if (self_update || !info->has_serial) {
+    if (self_update) {
         return;
     }
 
-- 
2.55.0
Re: [PATCH] ui/dbus: forward guest clipboard grabs that lack a serial
Posted by Marc-André Lureau 2 weeks, 4 days ago
Hi

On Tue, Sep 8, 2026 at 1:13 AM Rick Vernam <rtvernam@gmail.com> wrote:
>
> dbus_clipboard_update_info() drops any incoming grab whose
> QemuClipboardInfo has no serial number:
>
>     if (self_update || !info->has_serial) {
>         return;
>     }
>
> For grabs coming from ui/vdagent.c, has_serial is only set when the
> guest's vdagent client has negotiated VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL
> (see vdagent_clipboard_recv_grab()). When the guest doesn't negotiate
> it, the grab is silently dropped here and never forwarded to the
> D-Bus display client via Clipboard.Grab.
>
> It seems other protocols (ui/gtk-clipboard.c, ui/vnc-clipboard.c) do not
> incorporate a validation on has_serial, so this patch matches their
> behavior.

But dbus display relies on "serial" being valid. The client has no way
to check !info->serial. Iow, the agent must support
VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL. When not supported, the clipboard
state get out of sync due to races.

>
> Signed-off-by: Rick Vernam <rtvernam@gmail.com>
> ---
>  ui/dbus-clipboard.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ui/dbus-clipboard.c b/ui/dbus-clipboard.c
> index 90318384ee..1389ec0edc 100644
> --- a/ui/dbus-clipboard.c
> +++ b/ui/dbus-clipboard.c
> @@ -72,7 +72,7 @@ dbus_clipboard_update_info(DBusDisplay *dpy, QemuClipboardInfo *info)
>          return;
>      }
>
> -    if (self_update || !info->has_serial) {
> +    if (self_update) {
>          return;
>      }
>
> --
> 2.55.0
>