[PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class

marcandre.lureau@redhat.com posted 67 patches 2 years, 5 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Dr. David Alan Gilbert" <dave@treblig.org>, Peter Maydell <peter.maydell@linaro.org>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, "Daniel P. Berrangé" <berrange@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Akihiko Odaki <akihiko.odaki@daynix.com>
[PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
Posted by marcandre.lureau@redhat.com 2 years, 5 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

The timer is only relevant when a text console exists.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/console.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ui/console.c b/ui/console.c
index 8c4a2c83fa..ffa68c3a22 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1399,6 +1399,10 @@ qemu_text_console_finalize(Object *obj)
 static void
 qemu_text_console_class_init(ObjectClass *oc, void *data)
 {
+    if (!cursor_timer) {
+        cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
+                                    text_console_update_cursor, NULL);
+    }
 }
 
 static void
@@ -2144,8 +2148,6 @@ static DisplayState *get_alloc_displaystate(void)
 {
     if (!display_state) {
         display_state = g_new0(DisplayState, 1);
-        cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
-                                    text_console_update_cursor, NULL);
     }
     return display_state;
 }
-- 
2.41.0


Re: [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
Posted by Daniel P. Berrangé 2 years, 5 months ago
On Wed, Aug 30, 2023 at 01:38:00PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> The timer is only relevant when a text console exists.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  ui/console.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> diff --git a/ui/console.c b/ui/console.c
> index 8c4a2c83fa..ffa68c3a22 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -1399,6 +1399,10 @@ qemu_text_console_finalize(Object *obj)
>  static void
>  qemu_text_console_class_init(ObjectClass *oc, void *data)
>  {
> +    if (!cursor_timer) {
> +        cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
> +                                    text_console_update_cursor, NULL);
> +    }

Any possibility of moving 'cursor_timer' into a field in
QemuTextConsole ?


With regards,
Daniel
-- 
|: 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 :|


Re: [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
Posted by Marc-André Lureau 2 years, 5 months ago
Hi

On Fri, Sep 1, 2023 at 6:29 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 01:38:00PM +0400, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > The timer is only relevant when a text console exists.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  ui/console.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> > diff --git a/ui/console.c b/ui/console.c
> > index 8c4a2c83fa..ffa68c3a22 100644
> > --- a/ui/console.c
> > +++ b/ui/console.c
> > @@ -1399,6 +1399,10 @@ qemu_text_console_finalize(Object *obj)
> >  static void
> >  qemu_text_console_class_init(ObjectClass *oc, void *data)
> >  {
> > +    if (!cursor_timer) {
> > +        cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
> > +                                    text_console_update_cursor, NULL);
> > +    }
>
> Any possibility of moving 'cursor_timer' into a field in
> QemuTextConsole ?
>

It's global, so all consoles blink at the same time I suppose. It's
not obvious to me how we could make it a class field either.

thanks

-- 
Marc-André Lureau