ui/vnc: Update display update interval when VM state changes to RUNNING
PATCH 1/1 ui/vnc: Update display update interval when VM state changes to RUNNING
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by VNC_REFRESH_INTERVAL_INC (50 ms). The update interval can then grow up to VNC_REFRESH_INTERVAL_MAX (3000 ms).
When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The update_displaychangelistener() function updates the internal timer, and the display is refreshed immediately if the timer is expired.
--- ui/vnc.c | 12 ++++++++++++ ui/vnc.h | 2 ++ 2 files changed, 14 insertions(+)
ui/vnc.c +12 -0
@@ -3384,6 +3384,16 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = vnc_dpy_cursor_define, }; +static void vmstate_change_handler (void *opaque,bool running,RunState state) +{ +VncDisplay *vd = opaque; + +if (state !=RUN_STATE_RUNNING ) { +return ; + } +update_displaychangelistener (&vd->dcl,VNC_REFRESH_INTERVAL_BASE ); +} +void vnc_display_init (const char *id,Error **errp) {VncDisplay *vd;
@@ -3420,6 +3430,8 @@ void vnc_display_init(const char *id, Error **errp) vd->dcl.ops = &dcl_ops;register_displaychangelistener (&vd->dcl); vd->kbd =qkbd_state_init (vd->dcl.con); + vd->vmstate_handler_entry =qemu_add_vm_change_state_handler ( + &vmstate_change_handler, vd); }
ui/vnc.h +2 -0
@@ -185,6 +185,8 @@ struct VncDisplay#endif AudioState *audio_state; + +VMChangeStateEntry *vmstate_handler_entry; }; typedef struct VncTight {
Signature · 1 line
2.49.0
Quoted 20 lines · Juraj Marcin
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by
VNC_REFRESH_INTERVAL_INC(50 ms). The update interval can then grow up toVNC_REFRESH_INTERVAL_MAX(3000 ms).When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The
update_displaychangelistener()function updates the internal timer, and the display is refreshed immediately if the timer is expired.
Quoted 5 lines
Signed-off-by Juraj Marcin <[email protected]>--- ui/vnc.c | 12 ++++++++++++ ui/vnc.h | 2 ++ 2 files changed, 14 insertions(+)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 15 lines · Juraj Marcin
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by
VNC_REFRESH_INTERVAL_INC(50 ms). The update interval can then grow up toVNC_REFRESH_INTERVAL_MAX(3000 ms).When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
Quoted 6 lines
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The
update_displaychangelistener()function updates the internal timer, and the display is refreshed immediately if the timer is expired.Signed-off-by Juraj Marcin <[email protected]>
Thanks for looking into it!
One trivial comment (and partly, pure question) below,
Quoted 10 lines
--- ui/vnc.c | 12 ++++++++++++ ui/vnc.h | 2 ++ 2 files changed, 14 insertions(+)ui/vnc.c +0
-0
ui/vnc.c static const DisplayChangeListenerOps dcl_ops = { · line 3391
Quoted 8 lines
ui/vnc.c +5
-0@@ -3384,6 +3384,16 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = vnc_dpy_cursor_define, }; +static void vmstate_change_handler (void *opaque,bool running,RunState state) +{ +VncDisplay *vd = opaque; + +if (state !=RUN_STATE_RUNNING ) {
Just to mention in vm_prepare_start() it's possible we migrate a VM that used to be suspended, if so it'll keep suspended after migration:
RunState state = vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_RUNNING;
Here I'm not sure whether SUSPENDED would also like to update the display freq. I don't think it matters hugely, but just to say, if we want we can simply check "running=true" instead of checking the state to cover both RUNNING|SUSPENDED cases.
Quoted 33 lines
ui/vnc.c +7
-0+return ; + } +update_displaychangelistener (&vd->dcl,VNC_REFRESH_INTERVAL_BASE ); +} +void vnc_display_init (const char *id,Error **errp) {VncDisplay *vd;@@ -3420,6 +3430,8 @@ void vnc_display_init(const char *id, Error **errp) vd->dcl.ops = &dcl_ops;register_displaychangelistener (&vd->dcl); vd->kbd =qkbd_state_init (vd->dcl.con); + vd->vmstate_handler_entry =qemu_add_vm_change_state_handler ( + &vmstate_change_handler, vd); }ui/vnc.h +2
-0@@ -185,6 +185,8 @@ struct VncDisplay#endif AudioState *audio_state; + +VMChangeStateEntry *vmstate_handler_entry; }; typedef struct VncTight {Signature · 1 line
2.49.0
Signature · 1 line
Peter Xu
Hi Peter
Quoted 51 lines · Peter Xu
Quoted 15 lines · Juraj Marcin
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by
VNC_REFRESH_INTERVAL_INC(50 ms). The update interval can then grow up toVNC_REFRESH_INTERVAL_MAX(3000 ms).When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
Quoted 6 lines
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The
update_displaychangelistener()function updates the internal timer, and the display is refreshed immediately if the timer is expired.Signed-off-by Juraj Marcin <[email protected]>Thanks for looking into it!
Reviewed-by Peter Xu <[email protected]>One trivial comment (and partly, pure question) below,
Quoted 10 lines
--- ui/vnc.c | 12 ++++++++++++ ui/vnc.h | 2 ++ 2 files changed, 14 insertions(+)ui/vnc.c +0
-0ui/vnc.c static const DisplayChangeListenerOps dcl_ops = { · line 3391
Quoted 8 lines
ui/vnc.c +5
-0@@ -3384,6 +3384,16 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = vnc_dpy_cursor_define, }; +static void vmstate_change_handler (void *opaque,bool running,RunState state) +{ +VncDisplay *vd = opaque; + +if (state !=RUN_STATE_RUNNING ) {Just to mention in
vm_prepare_start()it's possible we migrate a VM that used to be suspended, if so it'll keep suspended after migration:
Quoted 6 lines
RunState state = vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_RUNNING;Here I'm not sure whether SUSPENDED would also like to update the display freq. I don't think it matters hugely, but just to say, if we want we can simply check "running=true" instead of checking the state to cover both RUNNING|SUSPENDED cases.
Thank you for the comment. I don't think it is necessary to update the screen frequency if the machine is suspended. In case there is an explicit request for that, we can change it then. The display frequency is still updated when the machine is resumed, same as if it was just suspended and then resumed without migration.
Best regards
Juraj Marcin
Quoted 38 lines
Quoted 34 lines
ui/vnc.c +7
-0+return ; + } +update_displaychangelistener (&vd->dcl,VNC_REFRESH_INTERVAL_BASE ); +} +void vnc_display_init (const char *id,Error **errp) {VncDisplay *vd;@@ -3420,6 +3430,8 @@ void vnc_display_init(const char *id, Error **errp) vd->dcl.ops = &dcl_ops;register_displaychangelistener (&vd->dcl); vd->kbd =qkbd_state_init (vd->dcl.con); + vd->vmstate_handler_entry =qemu_add_vm_change_state_handler ( + &vmstate_change_handler, vd); }ui/vnc.h +2
-0@@ -185,6 +185,8 @@ struct VncDisplay#endif AudioState *audio_state; + +VMChangeStateEntry *vmstate_handler_entry; }; typedef struct VncTight {Signature · 1 line
2.49.0Signature · 1 line
Peter Xu
Quoted 16 lines · Juraj Marcin
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by
VNC_REFRESH_INTERVAL_INC(50 ms). The update interval can then grow up toVNC_REFRESH_INTERVAL_MAX(3000 ms).When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
Quoted 6 lines
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The
update_displaychangelistener()function updates the internal timer, and the display is refreshed immediately if the timer is expired.Signed-off-by Juraj Marcin <[email protected]>
Quoted 52 lines
--- ui/vnc.c | 12 ++++++++++++ ui/vnc.h | 2 ++ 2 files changed, 14 insertions(+)ui/vnc.c +12
-0@@ -3384,6 +3384,16 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = vnc_dpy_cursor_define, }; +static void vmstate_change_handler (void *opaque,bool running,RunState state) +{ +VncDisplay *vd = opaque; + +if (state !=RUN_STATE_RUNNING ) { +return ; + } +update_displaychangelistener (&vd->dcl,VNC_REFRESH_INTERVAL_BASE ); +} +void vnc_display_init (const char *id,Error **errp) {VncDisplay *vd;@@ -3420,6 +3430,8 @@ void vnc_display_init(const char *id, Error **errp) vd->dcl.ops = &dcl_ops;register_displaychangelistener (&vd->dcl); vd->kbd =qkbd_state_init (vd->dcl.con); + vd->vmstate_handler_entry =qemu_add_vm_change_state_handler ( + &vmstate_change_handler, vd); }ui/vnc.h +2
-1@@ -185,6 +185,8 @@ struct VncDisplay#endif AudioState *audio_state; + +VMChangeStateEntry *vmstate_handler_entry; }; typedef struct VncTight { --2.49.0
Signature · 1 line
Marc-André Lureau
Quoted 15 lines · Juraj Marcin
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by
VNC_REFRESH_INTERVAL_INC(50 ms). The update interval can then grow up toVNC_REFRESH_INTERVAL_MAX(3000 ms).When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
Quoted 6 lines
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The
update_displaychangelistener()function updates the internal timer, and the display is refreshed immediately if the timer is expired.Signed-off-by Juraj Marcin <[email protected]>
[add Dan]
Ping - anyone is willing to pick this one up?
Thanks,
Signature · 1 line
Peter Xu
Hi
Quoted 21 lines · Peter Xu
Quoted 20 lines · Juraj Marcin
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by
VNC_REFRESH_INTERVAL_INC(50 ms). The update interval can then grow up toVNC_REFRESH_INTERVAL_MAX(3000 ms).When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The
update_displaychangelistener()function updates the internal timer, and the display is refreshed immediately if the timer is expired.
Quoted 6 lines
Quoted 1 line
Signed-off-by Juraj Marcin <[email protected]>[add Dan]
Ping - anyone is willing to pick this one up?
I haven't started gathering pending UI patches. Feel free to pick it up
Quoted 25 lines · Marc-André Lureau
Hi
Quoted 21 lines · Peter Xu
Quoted 20 lines · Juraj Marcin
From: Juraj Marcin <[email protected]>
If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by
VNC_REFRESH_INTERVAL_INC(50 ms). The update interval can then grow up toVNC_REFRESH_INTERVAL_MAX(3000 ms).When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again.
This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The
update_displaychangelistener()function updates the internal timer, and the display is refreshed immediately if the timer is expired.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Juraj Marcin <[email protected]>[add Dan]
Ping - anyone is willing to pick this one up?
I haven't started gathering pending UI patches. Feel free to pick it up
I'm queuing it for migration if no one beats me to it. Thanks!
Signature · 1 line
Peter Xu