aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2025-03-11 18:03:47 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2025-05-24 16:33:18 +0200
commitf626116f9897b95f68e5514a08098d590349c22e (patch)
tree657f72181bbec2416df83b8618983ff6dd09baeb
parent688ff4cbdf4993c60ee250afc48e15c0880f28de (diff)
downloadqemu-f626116f9897b95f68e5514a08098d590349c22e.zip
qemu-f626116f9897b95f68e5514a08098d590349c22e.tar.gz
qemu-f626116f9897b95f68e5514a08098d590349c22e.tar.bz2
ui/vdagent: factor out clipboard peer registration
This allows common code reuse during migration. Note that resetting the serial is now done regardless if the clipboard peer was registered or not. This should still be correct. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r--ui/vdagent.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/ui/vdagent.c b/ui/vdagent.c
index 210b8c1..fcbd7b1 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -694,6 +694,18 @@ static void vdagent_chr_open(Chardev *chr,
*be_opened = true;
}
+static void vdagent_clipboard_peer_register(VDAgentChardev *vd)
+{
+ if (vd->cbpeer.notifier.notify != NULL) {
+ return;
+ }
+
+ vd->cbpeer.name = "vdagent";
+ vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
+ vd->cbpeer.request = vdagent_clipboard_request;
+ qemu_clipboard_peer_register(&vd->cbpeer);
+}
+
static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
{
VDAgentAnnounceCapabilities *caps = (void *)msg->data;
@@ -720,13 +732,9 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
memset(vd->last_serial, 0, sizeof(vd->last_serial));
- if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {
+ if (have_clipboard(vd)) {
qemu_clipboard_reset_serial();
-
- vd->cbpeer.name = "vdagent";
- vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
- vd->cbpeer.request = vdagent_clipboard_request;
- qemu_clipboard_peer_register(&vd->cbpeer);
+ vdagent_clipboard_peer_register(vd);
}
}