Skip to content

Commit

Permalink
ui/vdagent: send empty clipboard when unhandled
Browse files Browse the repository at this point in the history
Rather than leaving the agent timing out or hanging, reply to it with an
empty result.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
  • Loading branch information
elmarco committed Aug 31, 2021
1 parent d2ed2c0 commit 3d3f0bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui/trace-events
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions ui/vdagent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 3d3f0bc

Please sign in to comment.