[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/52] ui/console: allocate ui_timer in QemuConsole
From: |
marcandre . lureau |
Subject: |
[PULL 25/52] ui/console: allocate ui_timer in QemuConsole |
Date: |
Mon, 4 Sep 2023 15:52:22 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Although at this point only QemuGraphicConsole have hw_ops that
implements ui_info() callback, it makes sense to keep the code in the
base QemuConsole, to simplify conditions for the caller.
As of now, the code didn't reach a NULL timer because dpy_set_ui_info()
checks if dpy_ui_info_supported() (hw_ops->ui_info != NULL), which is
false for text_console_ops. This is a bit fragile, let simply allocate
and free the timer in the base class.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230830093843.3531473-26-marcandre.lureau@redhat.com>
---
ui/console.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index a9a922b6e3..8c4a2c83fa 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -197,6 +197,7 @@ static bool
displaychangelistener_has_dmabuf(DisplayChangeListener *dcl);
static bool console_compatible_with(QemuConsole *con,
DisplayChangeListener *dcl, Error **errp);
static QemuConsole *qemu_graphic_console_lookup_unused(void);
+static void dpy_set_ui_info_timer(void *opaque);
static void gui_update(void *opaque)
{
@@ -1334,6 +1335,9 @@ qemu_console_register(QemuConsole *c)
static void
qemu_console_finalize(Object *obj)
{
+ QemuConsole *c = QEMU_CONSOLE(obj);
+
+ g_clear_pointer(&c->ui_timer, timer_free);
/* TODO: should unregister from consoles and free itself */
}
@@ -1367,6 +1371,8 @@ qemu_console_init(Object *obj)
qemu_co_queue_init(&c->dump_queue);
c->ds = ds;
c->window_id = -1;
+ c->ui_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
+ dpy_set_ui_info_timer, c);
qemu_console_register(c);
}
@@ -2193,8 +2199,6 @@ QemuConsole *graphic_console_init(DeviceState *dev,
uint32_t head,
} else {
trace_console_gfx_new();
s = (QemuConsole *)object_new(TYPE_QEMU_GRAPHIC_CONSOLE);
- s->ui_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
- dpy_set_ui_info_timer, s);
}
s->head = head;
graphic_console_set_hwops(s, hw_ops, opaque);
--
2.41.0
- [PULL 18/52] ui/console: change new_console() to use object initialization, (continued)
- [PULL 18/52] ui/console: change new_console() to use object initialization, marcandre . lureau, 2023/09/04
- [PULL 20/52] ui/console: instantiate a specific console type, marcandre . lureau, 2023/09/04
- [PULL 19/52] ui/console: introduce different console objects, marcandre . lureau, 2023/09/04
- [PULL 21/52] ui/console: register the console from qemu_console_init(), marcandre . lureau, 2023/09/04
- [PULL 23/52] ui/console: specialize console_lookup_unused(), marcandre . lureau, 2023/09/04
- [PULL 26/52] ui/vc: move cursor_timer initialization to QemuTextConsole class, marcandre . lureau, 2023/09/04
- [PULL 27/52] ui/console: free more QemuConsole resources, marcandre . lureau, 2023/09/04
- [PULL 24/52] ui/console: update the head from unused QemuConsole, marcandre . lureau, 2023/09/04
- [PULL 22/52] ui/console: remove new_console(), marcandre . lureau, 2023/09/04
- [PULL 28/52] ui/vc: move text fields to QemuTextConsole, marcandre . lureau, 2023/09/04
- [PULL 25/52] ui/console: allocate ui_timer in QemuConsole,
marcandre . lureau <=
- [PULL 29/52] ui/console: move graphic fields to QemuGraphicConsole, marcandre . lureau, 2023/09/04
- [PULL 30/52] ui/vc: fold text_console_do_init() in vc_chr_open(), marcandre . lureau, 2023/09/04
- [PULL 31/52] ui/vc: move some text console initialization to qom handlers, marcandre . lureau, 2023/09/04
- [PULL 32/52] ui/console: simplify getting active_console size, marcandre . lureau, 2023/09/04
- [PULL 35/52] ui/console: declare console types in console.h, marcandre . lureau, 2023/09/04
- [PULL 37/52] ui/console: rename vga_ functions with qemu_console_, marcandre . lureau, 2023/09/04
- [PULL 33/52] ui/console: remove need for g_width/g_height, marcandre . lureau, 2023/09/04
- [PULL 34/52] ui/vc: use common text console surface creation, marcandre . lureau, 2023/09/04
- [PULL 36/52] ui/console: use QEMU_PIXMAN_COLOR helpers, marcandre . lureau, 2023/09/04
- [PULL 38/52] ui/console: assert(surface) where appropriate, marcandre . lureau, 2023/09/04