ui/vdagent: send empty clipboard when unhandled
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 5 Aug 2021 13:57:11 +0000 (17:57 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 31 Aug 2021 13:25:14 +0000 (17:25 +0400)
Rather than leaving the agent timing out or hanging, reply to it with an
empty result.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210805135715.857938-15-marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
ui/trace-events
ui/vdagent.c

index 1b5f87bc09665761452e0cd52e2863e0b2f52a79..b9c0dd0fa11dcf69995b9151b54065f42cbc5e51 100644 (file)
@@ -129,6 +129,7 @@ xkeymap_keymap(const char *name) "keymap '%s'"
 vdagent_open(void) ""
 vdagent_close(void) ""
 vdagent_send(const char *name) "msg %s"
+vdagent_send_empty_clipboard(void) ""
 vdagent_recv_chunk(uint32_t size) "size %d"
 vdagent_recv_msg(const char *name, uint32_t size) "msg %s, size %d"
 vdagent_peer_cap(const char *name) "cap %s"
index cd07937a4b31f2930699d9270ca6bf41295f8623..cd49da1ffaa1e53a9b70238dceb948b8d76aa97c 100644 (file)
@@ -375,6 +375,16 @@ static void vdagent_send_clipboard_data(VDAgentChardev *vd,
     vdagent_send_msg(vd, msg);
 }
 
+static void vdagent_send_empty_clipboard_data(VDAgentChardev *vd,
+                                              QemuClipboardSelection selection,
+                                              QemuClipboardType type)
+{
+    g_autoptr(QemuClipboardInfo) info = qemu_clipboard_info_new(&vd->cbpeer, selection);
+
+    trace_vdagent_send_empty_clipboard();
+    vdagent_send_clipboard_data(vd, info, type);
+}
+
 static void vdagent_clipboard_notify(Notifier *notifier, void *data)
 {
     VDAgentChardev *vd = container_of(notifier, VDAgentChardev, cbpeer.update);
@@ -482,6 +492,8 @@ static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32
             vd->cbpending[s] |= (1 << type);
             qemu_clipboard_request(info, type);
         }
+    } else {
+        vdagent_send_empty_clipboard_data(vd, s, type);
     }
 }