Skip to contentSkip to conversation

ui/vdagent: Fix two bugs about disconnect event handling

PATCH In review [email protected] 2 participants 8 messages Aug 17, 2023 – Sep 4, 2023

lore
Share & tools
lore
#0 lore raw

cover ui/vdagent: Fix two bugs about disconnect event handling

From: Guoyi Tu <[email protected]>

and resource leak

Guoyi Tu (2):
ui/vdagent: call vdagent_disconnect() when agent connection is lost ui/vdagent: Unregister input handler of mouse during finalization

 ui/vdagent.c | 6 ++++++
 1 file changed, 6 insertions(+)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 ui/vdagent: call vdagent_disconnect() when agent connection is lost

From: Guoyi Tu <[email protected]>

when the agent connection is lost, the input handler of the mouse doesn't deactivate, which results in unresponsive mouse events in VNC windows.

To fix this issue, call vdagent_disconnect() to reset the state each time the frontend disconncect

---
 ui/vdagent.c | 3 +++
 1 file changed, 3 insertions(+)
ui/vdagent.c +3 -0
index 8a651492f0..4b9a1fb7c5 100644
@@ -870,8 +870,11 @@ static void vdagent_disconnect(VDAgentChardev *vd)
 
 static void vdagent_chr_set_fe_open(struct Chardev *chr, int fe_open)
 {
+    VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(chr);
+
     if (!fe_open) {
         trace_vdagent_close();
+        vdagent_disconnect(vd);
         /* To reset_serial, we CLOSED our side. Make sure the other end knows we
          * are ready again. */
         qemu_chr_be_event(chr, CHR_EVENT_OPENED);
Signature · 1 line
2.27.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] ui/vdagent: call vdagent_disconnect() when agent connection is lost

Quoted 7 lines · On Thu, Aug 17, 2023 at 6:24 PM <[email protected]> wrote:

From: Guoyi Tu <[email protected]>

when the agent connection is lost, the input handler of the mouse doesn't deactivate, which results in unresponsive mouse events in VNC windows.

Quoted 5 lines

To fix this issue, call vdagent_disconnect() to reset the state each time the frontend disconncect

Quoted 24 lines
---
 ui/vdagent.c | 3 +++
 1 file changed, 3 insertions(+)
ui/vdagent.c +3 -1
index 8a651492f0..4b9a1fb7c5 100644
@@ -870,8 +870,11 @@ static void vdagent_disconnect(VDAgentChardev *vd)
 
 static void vdagent_chr_set_fe_open(struct Chardev *chr, int fe_open)
 {
+    VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(chr);
+
     if (!fe_open) {
         trace_vdagent_close();
+        vdagent_disconnect(vd);
         /* To reset_serial, we CLOSED our side. Make sure the other end knows we
          * are ready again. */
         qemu_chr_be_event(chr, CHR_EVENT_OPENED);
--

2.27.0

Signature · 1 line
Marc-André Lureau
#3 lore raw

PATCH 2/2 ui/vdagent: Unregister input handler of mouse during finalization

In reply to [email protected]

From: Guoyi Tu <[email protected]>

Input handler resource should be released when
VDAgentChardev object finalize

---
 ui/vdagent.c | 3 +++
 1 file changed, 3 insertions(+)
ui/vdagent.c +3 -0
index 4b9a1fb7c5..00d36a8677 100644
@@ -926,6 +926,9 @@ static void vdagent_chr_fini(Object *obj)
 
     migrate_del_blocker(vd->migration_blocker);
     vdagent_disconnect(vd);
+    if (vd->mouse_hs) {
+        qemu_input_handler_unregister(vd->mouse_hs);
+    }
     buffer_free(&vd->outbuf);
     error_free(vd->migration_blocker);
 }
Signature · 1 line
2.27.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 2/2] ui/vdagent: Unregister input handler of mouse during finalization

Quoted 8 lines · On Thu, Aug 17, 2023 at 6:24 PM <[email protected]> wrote:

From: Guoyi Tu <[email protected]>

Input handler resource should be released when
VDAgentChardev object finalize

Quoted 22 lines
---
 ui/vdagent.c | 3 +++
 1 file changed, 3 insertions(+)
ui/vdagent.c +3 -1
index 4b9a1fb7c5..00d36a8677 100644
@@ -926,6 +926,9 @@ static void vdagent_chr_fini(Object *obj)
 
     migrate_del_blocker(vd->migration_blocker);
     vdagent_disconnect(vd);
+    if (vd->mouse_hs) {
+        qemu_input_handler_unregister(vd->mouse_hs);
+    }
     buffer_free(&vd->outbuf);
     error_free(vd->migration_blocker);
 }
--

2.27.0

Signature · 1 line
Marc-André Lureau
author
#5 lore raw
In reply to [email protected]

Hi Gerd, what do you think of these two patches? Can they be merged into the upstream?

Quoted 11 lines · On 2023/8/17 22:12, [email protected] wrote:

From: Guoyi Tu <[email protected]>

and resource leak

Guoyi Tu (2):
ui/vdagent: call vdagent_disconnect() when agent connection is lost ui/vdagent: Unregister input handler of mouse during finalization

  ui/vdagent.c | 6 ++++++
  1 file changed, 6 insertions(+)
#6 lore raw

Hi

Quoted 3 lines · Guoyi Tu

Hi Gerd, what do you think of these two patches? Can they be merged into the upstream?

I'll queue them.

thanks

Signature · 1 line
Marc-André Lureau
author
#7 lore raw
Quoted 13 lines · Marc-André Lureau

Hi

Quoted 3 lines · Guoyi Tu

Hi Gerd, what do you think of these two patches? Can they be merged into the upstream?

I'll queue them.

thanks

I'm glad they can be merged. Thank you.