* [PULL 1/4] ui/vdagent: fix windows agent regression
2025-11-25 14:17 [PULL 0/4] ui/chardev patches marcandre.lureau
@ 2025-11-25 14:17 ` marcandre.lureau
2025-11-25 14:17 ` [PULL 2/4] chardev/char-file: fix failure path marcandre.lureau
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: marcandre.lureau @ 2025-11-25 14:17 UTC (permalink / raw)
To: qemu-devel; +Cc: richard.henderson, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Since commit f626116f ("ui/vdagent: factor out clipboard peer
registration"), the QEMU clipboard serial is reset whenever the vdagent
chardev receives the guest caps. This triggers a CHR_EVENT_CLOSED which
is handled by virtio_serial_close() to notify the guest.
The "reconnection logic" is there to reset the agent when a
client (dbus, spice etc) reconnects, or the agent is restarted.
It is required to sync the clipboard serials and to prevent races or
loops due to clipboard managers on both ends (but this is not
implemented by windows vdagent).
The Unix agent has been reconnecting without resending caps, thus
working with this approach.
However, the Windows agent does not seem to have a way to handle
VIRTIO_CONSOLE_PORT_OPEN=0 event and do not receive further data...
Let's not trigger this disconnection/reset logic if the agent does not
support VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL.
Fixes: f626116f ("ui/vdagent: factor out clipboard peer registration")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reported-by: Lucas Kornicki <lucas.kornicki@nutanix.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Lucas Kornicki <lucas.kornicki@nutanix.com>
---
ui/vdagent.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/ui/vdagent.c b/ui/vdagent.c
index ddb91e75c6..660686c9c0 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -316,6 +316,15 @@ static bool have_selection(VDAgentChardev *vd)
return vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_SELECTION);
}
+static bool have_clipboard_serial(VDAgentChardev *vd)
+{
+#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1)
+ return vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL);
+#else
+ return false;
+#endif
+}
+
static uint32_t type_qemu_to_vdagent(enum QemuClipboardType type)
{
switch (type) {
@@ -345,8 +354,7 @@ static void vdagent_send_clipboard_grab(VDAgentChardev *vd,
return;
}
-#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1)
- if (vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)) {
+ if (have_clipboard_serial(vd)) {
if (!info->has_serial) {
/* client should win */
info->serial = vd->last_serial[info->selection]++;
@@ -356,7 +364,6 @@ static void vdagent_send_clipboard_grab(VDAgentChardev *vd,
data++;
msg->size += sizeof(uint32_t);
}
-#endif
for (q = 0; q < QEMU_CLIPBOARD_TYPE__COUNT; q++) {
type = type_qemu_to_vdagent(q);
@@ -464,6 +471,9 @@ static void vdagent_clipboard_reset_serial(VDAgentChardev *vd)
{
Chardev *chr = CHARDEV(vd);
+ if (!have_clipboard_serial(vd)) {
+ return;
+ }
/* reopen the agent connection to reset the serial state */
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
/* OPENED again after the guest disconnected, see set_fe_open */
@@ -518,8 +528,7 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uint32_t
trace_vdagent_cb_grab_selection(GET_NAME(sel_name, s));
info = qemu_clipboard_info_new(&vd->cbpeer, s);
-#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1)
- if (vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)) {
+ if (have_clipboard_serial(vd)) {
if (size < sizeof(uint32_t)) {
/* this shouldn't happen! */
return;
@@ -537,7 +546,6 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uint32_t
data += sizeof(uint32_t);
size -= sizeof(uint32_t);
}
-#endif
if (size > sizeof(uint32_t) * 10) {
/*
* spice has 6 types as of 2021. Limiting to 10 entries
--
2.51.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PULL 2/4] chardev/char-file: fix failure path
2025-11-25 14:17 [PULL 0/4] ui/chardev patches marcandre.lureau
2025-11-25 14:17 ` [PULL 1/4] ui/vdagent: fix windows agent regression marcandre.lureau
@ 2025-11-25 14:17 ` marcandre.lureau
2025-11-25 14:17 ` [PULL 3/4] chardev/char-pty: Do not ignore chr_write() failures marcandre.lureau
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: marcandre.lureau @ 2025-11-25 14:17 UTC (permalink / raw)
To: qemu-devel
Cc: richard.henderson, Marc-André Lureau,
Vladimir Sementsov-Ogievskiy, Paolo Bonzini
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
'in' will be -1 when file->in is unset. Let's not try to close
invalid fd.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Coverity: CID 1630444
Fixes: 69620c091d62f "chardev: qemu_chr_open_fd(): add errp"
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20251014145029.949285-1-vsementsov@yandex-team.ru>
---
chardev/char-file.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/chardev/char-file.c b/chardev/char-file.c
index 89e9cb849c..1f7adf592f 100644
--- a/chardev/char-file.c
+++ b/chardev/char-file.c
@@ -94,7 +94,9 @@ static void qmp_chardev_open_file(Chardev *chr,
if (!qemu_chr_open_fd(chr, in, out, errp)) {
qemu_close(out);
- qemu_close(in);
+ if (in >= 0) {
+ qemu_close(in);
+ }
return;
}
#endif
--
2.51.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PULL 3/4] chardev/char-pty: Do not ignore chr_write() failures
2025-11-25 14:17 [PULL 0/4] ui/chardev patches marcandre.lureau
2025-11-25 14:17 ` [PULL 1/4] ui/vdagent: fix windows agent regression marcandre.lureau
2025-11-25 14:17 ` [PULL 2/4] chardev/char-file: fix failure path marcandre.lureau
@ 2025-11-25 14:17 ` marcandre.lureau
2025-11-25 14:17 ` [PULL 4/4] ui/vnc: Fix qemu abort when query vnc info marcandre.lureau
2025-11-25 18:22 ` [PULL 0/4] ui/chardev patches Richard Henderson
4 siblings, 0 replies; 7+ messages in thread
From: marcandre.lureau @ 2025-11-25 14:17 UTC (permalink / raw)
To: qemu-devel
Cc: richard.henderson, Marc-André Lureau,
Philippe Mathieu-Daudé, qemu-stable, Paolo Bonzini
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20251022150743.78183-6-philmd@linaro.org>
---
chardev/char-pty.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index b066f01412..652b0bd9e7 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -125,7 +125,7 @@ static int char_pty_chr_write(Chardev *chr, const uint8_t *buf, int len)
rc = RETRY_ON_EINTR(g_poll(&pfd, 1, 0));
g_assert(rc >= 0);
if (!(pfd.revents & G_IO_HUP) && (pfd.revents & G_IO_OUT)) {
- io_channel_send(s->ioc, buf, len);
+ return io_channel_send(s->ioc, buf, len);
}
return len;
--
2.51.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PULL 4/4] ui/vnc: Fix qemu abort when query vnc info
2025-11-25 14:17 [PULL 0/4] ui/chardev patches marcandre.lureau
` (2 preceding siblings ...)
2025-11-25 14:17 ` [PULL 3/4] chardev/char-pty: Do not ignore chr_write() failures marcandre.lureau
@ 2025-11-25 14:17 ` marcandre.lureau
2025-11-25 15:37 ` Philippe Mathieu-Daudé
2025-11-25 18:22 ` [PULL 0/4] ui/chardev patches Richard Henderson
4 siblings, 1 reply; 7+ messages in thread
From: marcandre.lureau @ 2025-11-25 14:17 UTC (permalink / raw)
To: qemu-devel; +Cc: richard.henderson, Marc-André Lureau, AlanoSong@163.com
From: "AlanoSong@163.com" <AlanoSong@163.com>
When there is no display device on qemu machine,
and user only access qemu by remote vnc.
At the same time user input `info vnc` by QMP,
the qemu will abort.
To avoid the abort above, I add display device check,
when query vnc info in qmp_query_vnc_servers().
Reviewed-by: Marc-AndréLureau <marcandre.lureau@redhat.com>
Signed-off-by: Alano Song <AlanoSong@163.com>
[ Marc-André - removed useless Error *err ]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20251125131955.7024-1-AlanoSong@163.com>
---
ui/vnc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index 0d499b208b..e6bcf0e1cf 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -556,9 +556,12 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
qmp_query_auth(vd->auth, vd->subauth, &info->auth,
&info->vencrypt, &info->has_vencrypt);
if (vd->dcl.con) {
- dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),
- "device", &error_abort));
- info->display = g_strdup(dev->id);
+ Object *obj = object_property_get_link(OBJECT(vd->dcl.con),
+ "device", NULL);
+ if (obj) {
+ dev = DEVICE(obj);
+ info->display = g_strdup(dev->id);
+ }
}
if (vd->listener != NULL) {
nsioc = qio_net_listener_nsioc(vd->listener);
--
2.51.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PULL 4/4] ui/vnc: Fix qemu abort when query vnc info
2025-11-25 14:17 ` [PULL 4/4] ui/vnc: Fix qemu abort when query vnc info marcandre.lureau
@ 2025-11-25 15:37 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-25 15:37 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: richard.henderson, AlanoSong@163.com
On 25/11/25 15:17, marcandre.lureau@redhat.com wrote:
> From: "AlanoSong@163.com" <AlanoSong@163.com>
>
> When there is no display device on qemu machine,
> and user only access qemu by remote vnc.
> At the same time user input `info vnc` by QMP,
> the qemu will abort.
>
> To avoid the abort above, I add display device check,
> when query vnc info in qmp_query_vnc_servers().
>
> Reviewed-by: Marc-AndréLureau <marcandre.lureau@redhat.com>
^
> Signed-off-by: Alano Song <AlanoSong@163.com>
> [ Marc-André - removed useless Error *err ]
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Message-ID: <20251125131955.7024-1-AlanoSong@163.com>
> ---
> ui/vnc.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PULL 0/4] ui/chardev patches
2025-11-25 14:17 [PULL 0/4] ui/chardev patches marcandre.lureau
` (3 preceding siblings ...)
2025-11-25 14:17 ` [PULL 4/4] ui/vnc: Fix qemu abort when query vnc info marcandre.lureau
@ 2025-11-25 18:22 ` Richard Henderson
4 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2025-11-25 18:22 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
On 11/25/25 06:17, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The following changes since commit de074358e99b8eb5076d3efa267e44c292c90e3e:
>
> Merge tag 'pull-target-arm-20251124' of https://gitlab.com/pm215/qemu into staging (2025-11-24 09:03:12 -0800)
>
> are available in the Git repository at:
>
> https://gitlab.com/marcandre.lureau/qemu.git tags/fix-pull-request
>
> for you to fetch changes up to 4c1646e23f761e3dc6d88c8995f13be8f668a012:
>
> ui/vnc: Fix qemu abort when query vnc info (2025-11-25 18:03:13 +0400)
>
> ----------------------------------------------------------------
> ui/chardev fixes for v10.2
>
> ----------------------------------------------------------------
>
> AlanoSong@163.com (1):
> ui/vnc: Fix qemu abort when query vnc info
>
> Marc-André Lureau (1):
> ui/vdagent: fix windows agent regression
>
> Philippe Mathieu-Daudé (1):
> chardev/char-pty: Do not ignore chr_write() failures
>
> Vladimir Sementsov-Ogievskiy (1):
> chardev/char-file: fix failure path
>
> chardev/char-file.c | 4 +++-
> chardev/char-pty.c | 2 +-
> ui/vdagent.c | 20 ++++++++++++++------
> ui/vnc.c | 9 ++++++---
> 4 files changed, 24 insertions(+), 11 deletions(-)
>
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/10.2 as appropriate.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread