ui/vdagent: Fix two bugs about disconnect event handling
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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ui/vdagent.c +3 -1
@@ -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 );
@@ -922,7 +925,6 @@ static void vdagent_chr_fini(Object *obj)VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj);migrate_del_blocker (vd->migration_blocker); -vdagent_disconnect (vd);buffer_free (&vd->outbuf);error_free (vd->migration_blocker); }
Signature · 1 line
2.27.0
Re: [PATCH 1/2] ui/vdagent: call vdagent_disconnect() when agent connection is lost
Hi
Quoted 33 lines · On Thu, Aug 17, 2023 at 3:32 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.
To fix this issue, call
vdagent_disconnect()to reset the state each time the frontend disconncectSigned-off-by Guoyi Tu <[email protected]>Signed-off-by dengpengcheng <[email protected]>--- ui/vdagent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)ui/vdagent.c +3
-0@@ -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 );
ui/vdagent.c static void vdagent_chr_fini(Object *obj) · line 925
Quoted 4 lines
ui/vdagent.c +0
-1@@ -922,7 +925,6 @@ static void vdagent_chr_fini(Object *obj)VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj);migrate_del_blocker (vd->migration_blocker); -vdagent_disconnect (vd);
why remove this cleanup ? (the function seems safe to call multiple times, if it is the case during finalize)
Quoted 7 lines
ui/vdagent.c +0
-1buffer_free (&vd->outbuf);error_free (vd->migration_blocker); } --2.27.0
Signature · 1 line
Marc-André Lureau
Re: [PATCH 1/2] ui/vdagent: call vdagent_disconnect() when agent connection is lost
Quoted 38 lines · 【外部账号】Marc-André Lureau
Hi
Quoted 35 lines · On Thu, Aug 17, 2023 at 3:32 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.
To fix this issue, call
vdagent_disconnect()to reset the state each time the frontend disconncectSigned-off-by Guoyi Tu <[email protected]>Signed-off-by dengpengcheng <[email protected]>--- ui/vdagent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)ui/vdagent.c +3
-0@@ -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 );@@ -922,7 +925,6 @@ static void vdagent_chr_fini(Object *obj)VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj);
Quoted 6 lines
ui/vdagent.c static void vdagent_chr_fini(Object *obj) · line 925
Quoted 2 lines
ui/vdagent.c +0
-1migrate_del_blocker (vd->migration_blocker); -vdagent_disconnect (vd);why remove this cleanup ? (the function seems safe to call multiple times, if it is the case during finalize)
Before the instance finalize, the connection will be closed and the vdagent_chr_set_fe_open() will be called with be_open set to false, which in turn call vdagent_disconnect to clean up resources.
Quoted 9 lines
Quoted 7 lines
ui/vdagent.c +0
-1buffer_free (&vd->outbuf);error_free (vd->migration_blocker); } --2.27.0
Re: [PATCH 1/2] ui/vdagent: call vdagent_disconnect() when agent connection is lost
Hi
Quoted 48 lines · Guoyi Tu
Quoted 38 lines · 【外部账号】Marc-André Lureau
Hi
Quoted 35 lines · On Thu, Aug 17, 2023 at 3:32 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.
To fix this issue, call
vdagent_disconnect()to reset the state each time the frontend disconncectSigned-off-by Guoyi Tu <[email protected]>Signed-off-by dengpengcheng <[email protected]>--- ui/vdagent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)ui/vdagent.c +3
-0@@ -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 );@@ -922,7 +925,6 @@ static void vdagent_chr_fini(Object *obj)VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj);Quoted 6 lines
ui/vdagent.c static void vdagent_chr_fini(Object *obj) · line 925
Quoted 2 lines
ui/vdagent.c +0
-1migrate_del_blocker (vd->migration_blocker); -vdagent_disconnect (vd);why remove this cleanup ? (the function seems safe to call multiple times, if it is the case during finalize)
Quoted 3 lines
Before the instance finalize, the connection will be closed and the
vdagent_chr_set_fe_open()will be called withbe_openset to false, which in turn callvdagent_disconnectto clean up resources.
Let's leave it, as it's more straightforward and safe, even if it's called two times in some code paths.
Signature · 1 line
Marc-André Lureau
Re: [PATCH 1/2] ui/vdagent: call vdagent_disconnect() when agent connection is lost
Quoted 51 lines · 【外部账号】Marc-André Lureau
Hi
Quoted 48 lines · Guoyi Tu
Quoted 44 lines · 【外部账号】Marc-André Lureau
Hi
Quoted 33 lines · On Thu, Aug 17, 2023 at 3:32 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.
To fix this issue, call
vdagent_disconnect()to reset the state each time the frontend disconncectSigned-off-by Guoyi Tu <[email protected]>Signed-off-by dengpengcheng <[email protected]>--- ui/vdagent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)ui/vdagent.c +3
-0@@ -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 );ui/vdagent.c static void vdagent_chr_fini(Object *obj) · line 925
Quoted 4 lines
ui/vdagent.c +0
-1@@ -922,7 +925,6 @@ static void vdagent_chr_fini(Object *obj)VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj);migrate_del_blocker (vd->migration_blocker); -vdagent_disconnect (vd);why remove this cleanup ? (the function seems safe to call multiple times, if it is the case during finalize)
Quoted 7 lines
Quoted 3 lines
Before the instance finalize, the connection will be closed and the
vdagent_chr_set_fe_open()will be called withbe_openset to false, which in turn callvdagent_disconnectto clean up resources.Let's leave it, as it's more straightforward and safe, even if it's called two times in some code paths.
Okay, it sounds reasonable, i will send another patches
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
@@ -924,6 +924,9 @@ static void vdagent_chr_fini(Object *obj) {VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj); +if (vd->mouse_hs) { +qemu_input_handler_unregister (vd->mouse_hs); + }migrate_del_blocker (vd->migration_blocker);buffer_free (&vd->outbuf);error_free (vd->migration_blocker);
Signature · 1 line
2.27.0
Re: [PATCH 2/2] ui/vdagent: Unregister input handler of mouse during finalization
Quoted 8 lines · On Thu, Aug 17, 2023 at 3:33 PM <[email protected]> wrote:
From: Guoyi Tu <[email protected]>
Input handler resource should be released when
VDAgentChardev object finalizeSigned-off-by Guoyi Tu <[email protected]>Signed-off-by dengpengcheng <[email protected]>
Quoted 22 lines
--- ui/vdagent.c | 3 +++ 1 file changed, 3 insertions(+)ui/vdagent.c +3
-1@@ -924,6 +924,9 @@ static void vdagent_chr_fini(Object *obj) {VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj); +if (vd->mouse_hs) { +qemu_input_handler_unregister (vd->mouse_hs); + }migrate_del_blocker (vd->migration_blocker);buffer_free (&vd->outbuf);error_free (vd->migration_blocker); --2.27.0
Signature · 1 line
Marc-André Lureau