[PATCH] ui/clipboard: clear deferred serial reset flag on resume

GuoHan Zhao posted 1 patch 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260416070403.1683648-1-zhaoguohan@kylinos.cn
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/clipboard.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] ui/clipboard: clear deferred serial reset flag on resume
Posted by GuoHan Zhao 1 month, 2 weeks ago
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: c967ff606b99 ("ui/clipboard: delay clipboard update when not running")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
---
 ui/clipboard.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui/clipboard.c b/ui/clipboard.c
index ec00a0b8ec75..e3d8a31ba9f7 100644
--- a/ui/clipboard.c
+++ b/ui/clipboard.c
@@ -47,6 +47,7 @@ static void qemu_clipboard_change_state(void *opaque, bool running, RunState sta
     }
 
     if (cb_reset_serial_on_resume) {
+        cb_reset_serial_on_resume = false;
         qemu_clipboard_reset_serial();
     }
 
-- 
2.43.0
Re: [PATCH] ui/clipboard: clear deferred serial reset flag on resume
Posted by Marc-André Lureau 1 month, 2 weeks ago
On Thu, Apr 16, 2026 at 11:04 AM GuoHan Zhao <zhaoguohan@kylinos.cn> wrote:
>
> 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: c967ff606b99 ("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>

> ---
>  ui/clipboard.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ui/clipboard.c b/ui/clipboard.c
> index ec00a0b8ec75..e3d8a31ba9f7 100644
> --- a/ui/clipboard.c
> +++ b/ui/clipboard.c
> @@ -47,6 +47,7 @@ static void qemu_clipboard_change_state(void *opaque, bool running, RunState sta
>      }
>
>      if (cb_reset_serial_on_resume) {
> +        cb_reset_serial_on_resume = false;
>          qemu_clipboard_reset_serial();
>      }
>
> --
> 2.43.0
>