Make pixman an optional dependency
cover Make pixman an optional dependency
From: Marc-André Lureau <[email protected]>
Hi,
QEMU system emulators can be made to compile and work without pixman.
Given how pervasively pixman types and API is used in all the code base, it was a bit difficult to figure out how to cut the dependency.
I decided that it was important to keep VGA and graphics device working for compatibility reasons, although some devices, such as xlnx Display Port, have stronger dependency and have to be disabled. The ui/console code also has a lot of pixman usage and a bit of a mess to deal with. I made large refactoring to allow to compile out the VC code.
The series can be roughly divded as:
- a few related preliminary cleanups
- ui/console refactoring to allow ui/vc split
- add a 'pixman' option, and a minimal pixman-compat.h
- make some parts depend on 'pixman'
Graphic -display still work, although with some caveats. For ex, -display sdl or cocoa don't have VCs, so starting QEMU will print the following warnings when pixman is disabled:
qemu-system-x86_64: warning: compat_monitor0: this is a dummy VC driver. Use '-nographic' or a different chardev.
qemu-system-x86_64: warning: serial0: this is a dummy VC driver. Use '-nographic' or a different chardev.
qemu-system-x86_64: warning: parallel0: this is a dummy VC driver. Use '-nographic' or a different chardev.
But -display dbus is fully functionnal, for ex, as it operates at chardev/text level.
Fixes:
https://gitlab.com/qemu-project/qemu/-/issues/1172
Marc-André Lureau (67):
ui: remove qemu_pixman_color() helper
ui: remove qemu_pixman_linebuf_copy()
ui/qmp: move screendump to ui-qmp-cmds.c
ui/vc: replace vc_chr_write() with generic qemu_chr_write() ui/vc: drop have_text
ui/console: console_select() regardless of have_gfx ui/console: call dpy_gfx_update() regardless of have_gfx ui/console: drop have_gfx
ui/console: get the DisplayState from new_console() ui/console: new_console() cannot fail
ui/vc: VC always has a DisplayState now
ui/vc: move VCChardev declaration at the top
ui/vc: replace variable with static text attributes default ui/vc: fold text_update_xy()
ui/vc: pass VCCharDev to VC-specific functions
ui/vc: move VCCharDev specific fields out of QemuConsole ui/console: use OBJECT_DEFINE_TYPE for QemuConsole ui/console: change new_console() to use object initialization ui/console: introduce different console objects ui/console: instantiate a specific console type ui/console: register the console from qemu_console_init() ui/console: remove new_console()
ui/console: specialize console_lookup_unused() ui/console: update the head from unused QemuConsole ui/console: allocate ui_timer in QemuConsole
ui/vc: move cursor_timer initialization to QemuTextConsole class ui/console: free more QemuConsole resources
ui/vc: move text fields to QemuTextConsole
ui/console: move graphic fields to QemuGraphicConsole ui/vc: fold text_console_do_init() in vc_chr_open() ui/vc: move some text console initialization to qom handlers ui/console: simplify getting active_console size ui/console: remove need for g_width/g_height
ui/vc: use common text console surface creation ui/console: declare console types in console.h ui/console: use QEMU_PIXMAN_COLOR helpers
ui/console: rename vga_ functions → qemu_console_ ui/console: assert(surface) where appropriate ui/console: fold text_console_update_cursor_timer ui/vc: skip text console resize when possible ui/console: minor stylistic changes
ui/vc: move text console invalidate in helper
ui/vc: do not parse VC-specific options in Spice and GTK ui/vc: change the argument for QemuTextConsole
ui/vc: remove kby_put_keysym() and update function calls ui/vc: rename kbd_put → qemu_text_console functions ui/console: remove redundant format field
ui/vc: preliminary QemuTextConsole changes before split ui/vc: split off the VC part from console.c
ui/console: move DisplaySurface to its own header
build-sys: add optional "pixman" feature
ui: compile out some qemu-pixman functions when !PIXMAN
ui: add pixman-compat.h
ui/vc: console-vc requires PIXMAN
qmp/hmp: disable screendump if PIXMAN is missing
virtio-gpu: replace PIXMAN for region/rect test ui/console: when PIXMAN is unavailable, don't draw placeholder msg
vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN ui/gl: opengl doesn't require PIXMAN
ui/vnc: VNC requires PIXMAN
ui/spice: SPICE/QXL requires PIXMAN
ui/gtk: -display gtk requires PIXMAN
ui/dbus: do not require PIXMAN
arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN ppc/kconfig: make SAM460EX depend on PPC & PIXMAN sh4/kconfig: make R2D depend on SH4 & PIXMAN display/kconfig: make SM501 depend on PIXMAN
configs/devices/ppc-softmmu/default.mak | 2 +- configs/devices/sh4-softmmu/default.mak | 2 +- meson.build | 11 +- qapi/char.json | 4 + qapi/ui.json | 3 +- include/chardev/char.h | 3 - include/ui/console.h | 118 +- include/ui/pixman-compat.h | 190 +++ include/ui/qemu-pixman.h | 20 +- include/ui/rect.h | 55 + include/ui/surface.h | 91 ++ ui/console-priv.h | 43 + hw/display/vhost-user-gpu.c | 2 + hw/display/virtio-gpu.c | 30 +- ui/console-gl.c | 2 +- ui/console-vc-stubs.c | 59 + ui/console-vc.c | 1079 +++++++++++++++ ui/console.c | 1603 +++-------------------- ui/curses.c | 2 +- ui/dbus-listener.c | 62 +- ui/gtk.c | 11 +- ui/qemu-pixman.c | 25 +- ui/sdl2-input.c | 5 +- ui/sdl2.c | 5 +- ui/spice-app.c | 7 +- ui/spice-display.c | 2 +- ui/ui-hmp-cmds.c | 2 + ui/ui-qmp-cmds.c | 189 +++ ui/vnc.c | 56 +- Kconfig.host | 3 + hmp-commands.hx | 2 + hw/arm/Kconfig | 2 +- hw/display/Kconfig | 3 +- hw/ppc/Kconfig | 2 + hw/sh4/Kconfig | 2 + meson_options.txt | 2 + ui/cocoa.m | 2 +- ui/meson.build | 25 +- 38 files changed, 2093 insertions(+), 1633 deletions(-) create mode 100644 include/ui/pixman-compat.h create mode 100644 include/ui/rect.h create mode 100644 include/ui/surface.h create mode 100644 ui/console-priv.h create mode 100644 ui/console-vc-stubs.c create mode 100644 ui/console-vc.c
Signature · 1 line
2.41.0
PATCH 1/67 ui: remove qemu_pixman_color() helper
From: Marc-André Lureau <[email protected]>
Usage removed in commit e27bd65a72d ("console: switch color_table_rgb to pixman_color_t")
--- include/ui/qemu-pixman.h | 1 - ui/qemu-pixman.c | 11 ----------- 2 files changed, 12 deletions(-)
include/ui/qemu-pixman.h +0 -1
@@ -78,7 +78,6 @@ pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format, pixman_image_t *image);void qemu_pixman_image_unref (pixman_image_t *image); -pixman_color_t qemu_pixman_color (PixelFormat *pf,uint32_t color);pixman_image_t *qemu_pixman_glyph_from_vgafont (int height,const uint8_t *font,unsigned int ch); void qemu_pixman_glyph_render(pixman_image_t *glyph,
ui/qemu-pixman.c +0 -11
@@ -226,17 +226,6 @@ void qemu_pixman_image_unref(pixman_image_t *image)pixman_image_unref (image); } -pixman_color_t qemu_pixman_color (PixelFormat *pf,uint32_t color) -{ -pixman_color_t c; - - c.red = ((color & pf->rmask) >> pf->rshift) << (16 - pf->rbits); - c.green = ((color & pf->gmask) >> pf->gshift) << (16 - pf->gbits); - c.blue = ((color & pf->bmask) >> pf->bshift) << (16 - pf->bbits); - c.alpha = ((color & pf->amask) >> pf->ashift) << (16 - pf->abits); -return c; -} -pixman_image_t *qemu_pixman_glyph_from_vgafont (int height,const uint8_t *font,unsigned int ch) {
Signature · 1 line
2.41.0
Re: [PATCH 01/67] ui: remove qemu_pixman_color() helper
Quoted 9 lines · On 30/8/23 11:37, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Usage removed in commit
e27bd65a72d("console: switchcolor_table_rgbtopixman_color_t")Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/qemu-pixman.h | 1 - ui/qemu-pixman.c | 11 ----------- 2 files changed, 12 deletions(-)
Re: [PATCH 01/67] ui: remove qemu_pixman_color() helper
In reply to [email protected]Quoted 9 lines · On Wed, Aug 30, 2023 at 01:37:35PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Usage removed in commit
e27bd65a72d("console: switchcolor_table_rgbtopixman_color_t")Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/qemu-pixman.h | 1 - ui/qemu-pixman.c | 11 ----------- 2 files changed, 12 deletions(-)
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 :|
PATCH 2/67 ui: remove qemu_pixman_linebuf_copy()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Since commit 43c7d8bd449 ("console: add qemu_pixman_linebuf_copy"), it seems it was never used.
--- include/ui/qemu-pixman.h | 2 -- ui/qemu-pixman.c | 8 -------- 2 files changed, 10 deletions(-)
include/ui/qemu-pixman.h +0 -2
@@ -72,8 +72,6 @@ pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format, int width);void qemu_pixman_linebuf_fill (pixman_image_t *linebuf,pixman_image_t *fb,int width,int x,int y); -void qemu_pixman_linebuf_copy (pixman_image_t *fb,int width,int x,int y, -pixman_image_t *linebuf);pixman_image_t *qemu_pixman_mirror_create (pixman_format_code_t format,pixman_image_t *image);void qemu_pixman_image_unref (pixman_image_t *image);
ui/qemu-pixman.c +0 -8
@@ -200,14 +200,6 @@ void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb, x, y, 0, 0, 0, 0, width, 1); } -/* copy linebuf to framebuffer */ -void qemu_pixman_linebuf_copy (pixman_image_t *fb,int width,int x,int y, -pixman_image_t *linebuf) -{ -pixman_image_composite (PIXMAN_OP_SRC , linebuf,NULL , fb, -0 ,0 ,0 ,0 , x, y, width,1 ); -} -pixman_image_t *qemu_pixman_mirror_create (pixman_format_code_t format,pixman_image_t *image) {
Signature · 1 line
2.41.0
Re: [PATCH 02/67] ui: remove qemu_pixman_linebuf_copy()
Quoted 10 lines · On Wed, Aug 30, 2023 at 01:37:36PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Since commit
43c7d8bd449("console: addqemu_pixman_linebuf_copy"), it seems it was never used.Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/qemu-pixman.h | 2 -- ui/qemu-pixman.c | 8 -------- 2 files changed, 10 deletions(-)
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 :|
PATCH 3/67 ui/qmp: move screendump to ui-qmp-cmds.c
In reply to [email protected]From: Marc-André Lureau <[email protected]>
console.c unit is over-crowded. This code is specific to the handling of the QMP screendump command, so move it in ui-qmp-cmds.
--- include/ui/console.h | 1 + ui/console.c | 212 ++++--------------------------------------- ui/ui-qmp-cmds.c | 187 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 195 deletions(-)
include/ui/console.h +1 -0
@@ -504,6 +504,7 @@ void qemu_console_set_window_id(QemuConsole *con, int window_id);void console_select (unsigned int index);void qemu_console_resize (QemuConsole *con,int width,int height);DisplaySurface *qemu_console_surface (QemuConsole *con); +void coroutine_fn qemu_console_co_wait_update(QemuConsole *con);/* console-gl.c */ #ifdef CONFIG_OPENGL
ui/console.c +17 -195
238 lines not on this page · raw message
ui/ui-qmp-cmds.c +187 -0
203 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH 03/67] ui/qmp: move screendump to ui-qmp-cmds.c
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:37:37PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
console.cunit is over-crowded. This code is specific to the handling of the QMP screendump command, so move it in ui-qmp-cmds.Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 1 + ui/console.c | 212 ++++--------------------------------------- ui/ui-qmp-cmds.c | 187 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 195 deletions(-)
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 :|
PATCH 4/67 ui/vc: replace vc_chr_write() with generic qemu_chr_write()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
We shouldn't call the callback directly, but use the chardev API, unless there is a clear reason.
--- ui/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
ui/console.c +3 -3
@@ -1169,13 +1169,13 @@ void kbd_put_keysym_console(QemuConsole *s, int keysym) *q++ ='[' ; *q++ = keysym &0xff ; }else if (s->echo && (keysym =='\r' || keysym =='\n' )) { -vc_chr_write (s->chr, (const uint8_t *)"\r" ,1 ); +qemu_chr_write (s->chr, (uint8_t *)"\r" ,1 , true); *q++ ='\n' ; }else { *q++ = keysym; }if (s->echo) { -vc_chr_write (s->chr, buf, q - buf); +qemu_chr_write (s->chr, buf, q - buf, true); } num_free =fifo8_num_free (&s->out_fifo);fifo8_push_all (&s->out_fifo, buf,MIN (num_free, q - buf));
@@ -2474,7 +2474,7 @@ static void text_console_do_init(Chardev *chr, DisplayState *ds) s->t_attrib.bgcol =QEMU_COLOR_BLUE ; msg =g_strdup_printf ("%s console\r\n" , chr->label); -vc_chr_write (chr, (uint8_t *)msg,strlen (msg)); +qemu_chr_write (chr, (uint8_t *)msg,strlen (msg), true);g_free (msg); s->t_attrib = s->t_attrib_default; }
Signature · 1 line
2.41.0
Re: [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write()
Quoted 9 lines · On 30/8/23 11:37, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
We shouldn't call the callback directly, but use the chardev API, unless there is a clear reason.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Re: [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write()
In reply to [email protected]Quoted 9 lines · On Wed, Aug 30, 2023 at 01:37:38PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
We shouldn't call the callback directly, but use the chardev API, unless there is a clear reason.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
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 :|
PATCH 5/67 ui/vc: drop have_text
In reply to [email protected]From: Marc-André Lureau <[email protected]>
If there are no "text" listener, the callback will simply be ignored. The rest of text handling can be done cheaply.
This allows to remove some dependency on DisplayState from VC implementation.
--- ui/console.c | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-)
ui/console.c +13 -29
@@ -133,7 +133,6 @@ struct DisplayState {uint64_t update_interval;bool refreshing;bool have_gfx; -bool have_text; QLIST_HEAD(, DisplayChangeListener) listeners; };
@@ -185,7 +184,6 @@ static void gui_setup_refresh(DisplayState *ds)DisplayChangeListener *dcl;bool need_timer = false;bool have_gfx = false; -bool have_text = false; QLIST_FOREACH(dcl, &ds->listeners, next) {if (dcl->ops->dpy_refresh !=NULL ) {
@@ -194,9 +192,6 @@ static void gui_setup_refresh(DisplayState *ds)if (dcl->ops->dpy_gfx_update !=NULL ) { have_gfx = true; } -if (dcl->ops->dpy_text_update !=NULL ) { - have_text = true; - } }if (need_timer && ds->gui_timer ==NULL ) {
@@ -209,7 +204,6 @@ static void gui_setup_refresh(DisplayState *ds) } ds->have_gfx = have_gfx; - ds->have_text = have_text; }void graphic_hw_update_done (QemuConsole *con)
@@ -456,9 +450,7 @@ static void update_xy(QemuConsole *s, int x, int y)TextCell *c;int y1, y2; -if (s->ds->have_text) { -text_update_xy (s, x, y); - } +text_update_xy (s, x, y); y1 = (s->y_base + y) % s->total_height; y2 = y1 - s->y_displayed;
@@ -482,9 +474,7 @@ static void console_show_cursor(QemuConsole *s, int show)int y, y1;int x = s->x; -if (s->ds->have_text) { - s->cursor_invalidate =1 ; - } + s->cursor_invalidate =1 ;if (x >= s->width) { x = s->width -1 ;
@@ -513,13 +503,11 @@ static void console_refresh(QemuConsole *s)TextCell *c;int x, y, y1; -if (s->ds->have_text) { - s->text_x[0 ] =0 ; - s->text_y[0 ] =0 ; - s->text_x[1 ] = s->width -1 ; - s->text_y[1 ] = s->height -1 ; - s->cursor_invalidate =1 ; - } + s->text_x[0 ] =0 ; + s->text_y[0 ] =0 ; + s->text_x[1 ] = s->width -1 ; + s->text_y[1 ] = s->height -1 ; + s->cursor_invalidate =1 ;vga_fill_rect (s,0 ,0 ,surface_width (surface),surface_height (surface), color_table_rgb[0 ][QEMU_COLOR_BLACK ]);
@@ -594,12 +582,10 @@ static void console_put_lf(QemuConsole *s) c++; }if (s->y_displayed == s->y_base) { -if (s->ds->have_text) { - s->text_x[0 ] =0 ; - s->text_y[0 ] =0 ; - s->text_x[1 ] = s->width -1 ; - s->text_y[1 ] = s->height -1 ; - } + s->text_x[0 ] =0 ; + s->text_y[0 ] =0 ; + s->text_x[1 ] = s->width -1 ; + s->text_y[1 ] = s->height -1 ; vga_bitblt(s, 0, FONT_HEIGHT, 0, 0, s->width * FONT_WIDTH,
@@ -1069,9 +1055,7 @@ void console_select(unsigned int index)displaychangelistener_display_console (dcl, s,NULL ); } } -if (ds->have_text) { -dpy_text_resize (s, s->width, s->height); - } +dpy_text_resize (s, s->width, s->height);text_console_update_cursor (NULL ); } }
@@ -1239,7 +1223,7 @@ static void text_console_invalidate(void *opaque) {QemuConsole *s = (QemuConsole *) opaque; -if (s->ds->have_text && s->console_type ==TEXT_CONSOLE ) { +if (s->console_type ==TEXT_CONSOLE ) {text_console_resize (s); }console_refresh (s);
Signature · 1 line
2.41.0
Re: [PATCH 05/67] ui/vc: drop have_text
Quoted 5 lines · On Wed, Aug 30, 2023 at 01:37:39PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
If there are no "text" listener, the callback will simply be ignored. The rest of text handling can be done cheaply.
Quoted 7 lines
This allows to remove some dependency on DisplayState from VC implementation.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-)
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 :|
PATCH 6/67 ui/console: console_select() regardless of have_gfx
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Even if we don't have a gfx listener, we should call displaychangelistener_display_console() which handle that case correctly.
--- ui/console.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
ui/console.c +4 -6
@@ -1047,13 +1047,11 @@ void console_select(unsigned int index)DisplayState *ds = s->ds; active_console = s; -if (ds->have_gfx) { - QLIST_FOREACH(dcl, &ds->listeners, next) { -if (dcl->con !=NULL ) { -continue ; - } -displaychangelistener_display_console (dcl, s,NULL ); + QLIST_FOREACH (dcl, &ds->listeners, next) { +if (dcl->con !=NULL ) { +continue ; } +displaychangelistener_display_console (dcl, s,NULL ); }dpy_text_resize (s, s->width, s->height);text_console_update_cursor (NULL );
Signature · 1 line
2.41.0
Re: [PATCH 06/67] ui/console: console_select() regardless of have_gfx
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:37:40PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Even if we don't have a gfx listener, we should call
displaychangelistener_display_console()which handle that case correctly.Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
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 :|
PATCH 7/67 ui/console: call dpy_gfx_update() regardless of have_gfx
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The function will handle the case when no listeners are gfx, without extra meaningful cost.
This allows to get rid of DisplayState dependency in VC implementation.
--- ui/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ui/console.c +1 -1
@@ -1087,7 +1087,7 @@ static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)console_putchar (s, buf[i]); }console_show_cursor (s,1 ); -if (s->ds->have_gfx && s->update_x0 < s->update_x1) { +if (s->update_x0 < s->update_x1) {dpy_gfx_update (s, s->update_x0, s->update_y0, s->update_x1 - s->update_x0, s->update_y1 - s->update_y0);
Signature · 1 line
2.41.0
Re: [PATCH 07/67] ui/console: call dpy_gfx_update() regardless of have_gfx
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:37:41PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The function will handle the case when no listeners are gfx, without extra meaningful cost.
This allows to get rid of DisplayState dependency in VC implementation.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 :|
PATCH 8/67 ui/console: drop have_gfx
In reply to [email protected]From: Marc-André Lureau <[email protected]>
All usages have been removed.
--- ui/console.c | 7 ------- 1 file changed, 7 deletions(-)
ui/console.c +0 -7
@@ -132,7 +132,6 @@ struct DisplayState {uint64_t last_update;uint64_t update_interval;bool refreshing; -bool have_gfx; QLIST_HEAD(, DisplayChangeListener) listeners; };
@@ -183,15 +182,11 @@ static void gui_setup_refresh(DisplayState *ds) {DisplayChangeListener *dcl;bool need_timer = false; -bool have_gfx = false; QLIST_FOREACH(dcl, &ds->listeners, next) {if (dcl->ops->dpy_refresh !=NULL ) { need_timer = true; } -if (dcl->ops->dpy_gfx_update !=NULL ) { - have_gfx = true; - } }if (need_timer && ds->gui_timer ==NULL ) {
@@ -202,8 +197,6 @@ static void gui_setup_refresh(DisplayState *ds)timer_free (ds->gui_timer); ds->gui_timer =NULL ; } - - ds->have_gfx = have_gfx; }void graphic_hw_update_done (QemuConsole *con)
Signature · 1 line
2.41.0
Re: [PATCH 08/67] ui/console: drop have_gfx
Quoted 8 lines · On Wed, Aug 30, 2023 at 01:37:42PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
All usages have been removed.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 7 ------- 1 file changed, 7 deletions(-)
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 :|
PATCH 9/67 ui/console: get the DisplayState from new_console()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
There is no obvious reason to defer text console initialization. We can simply take the global display state in new_console().
This simplify somewhat the code to allow moving the VC to a separate unit.
--- ui/console.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
ui/console.c +8 -18
@@ -143,7 +143,7 @@ static QTAILQ_HEAD(, QemuConsole) consoles =static bool cursor_visible_phase;static QEMUTimer *cursor_timer; -static void text_console_do_init (Chardev *chr,DisplayState *ds); +static void text_console_do_init (Chardev *chr);static void dpy_refresh (DisplayState *s);static DisplayState *get_alloc_displaystate (void );static void text_console_update_cursor_timer (void );
@@ -1249,9 +1249,10 @@ static void text_console_update(void *opaque, console_ch_t *chardata) } } -static QemuConsole *new_console (DisplayState *ds,console_type_t console_type, +static QemuConsole *new_console (console_type_t console_type,uint32_t head) { +DisplayState *ds =get_alloc_displaystate ();Object *obj;QemuConsole *s;int i;
@@ -2049,13 +2050,7 @@ DisplayState *init_displaystate(void)gchar *name;QemuConsole *con; -get_alloc_displaystate (); QTAILQ_FOREACH(con, &consoles, next) { -if (con->console_type !=GRAPHIC_CONSOLE && - con->ds ==NULL ) { -text_console_do_init (con->chr, display_state); - } -/* Hook up into the qom tree here (not in new_console()), once * all QemuConsoles are created and the order / numbering * doesn't change any more */
@@ -2085,10 +2080,8 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,int width =640 ;int height =480 ;QemuConsole *s; -DisplayState *ds;DisplaySurface *surface; - ds =get_alloc_displaystate (); s =qemu_console_lookup_unused ();if (s) {trace_console_gfx_reuse (s->index);
@@ -2096,7 +2089,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, height =qemu_console_get_height (s,0 ); }else {trace_console_gfx_new (); - s =new_console (ds,GRAPHIC_CONSOLE , head); + s =new_console (GRAPHIC_CONSOLE , head); s->ui_timer =timer_new_ms (QEMU_CLOCK_REALTIME , dpy_set_ui_info_timer, s); }
@@ -2405,7 +2398,7 @@ static const GraphicHwOps text_console_ops = { .text_update = text_console_update, }; -static void text_console_do_init (Chardev *chr,DisplayState *ds) +static void text_console_do_init (Chardev *chr) {VCChardev *drv =VC_CHARDEV (chr);QemuConsole *s = drv->console;
@@ -2413,7 +2406,6 @@ static void text_console_do_init(Chardev *chr, DisplayState *ds)int g_height =24 *FONT_HEIGHT ;fifo8_create (&s->out_fifo,16 ); - s->ds = ds; s->y_displayed =0 ; s->y_base =0 ;
@@ -2482,9 +2474,9 @@ static void vc_chr_open(Chardev *chr,trace_console_txt_new (width, height);if (width ==0 || height ==0 ) { - s =new_console (NULL ,TEXT_CONSOLE ,0 ); + s =new_console (TEXT_CONSOLE ,0 ); }else { - s =new_console (NULL ,TEXT_CONSOLE_FIXED_SIZE ,0 ); + s =new_console (TEXT_CONSOLE_FIXED_SIZE ,0 ); s->scanout.kind =SCANOUT_SURFACE ; s->surface =qemu_create_displaysurface (width, height); }
@@ -2497,9 +2489,7 @@ static void vc_chr_open(Chardev *chr, s->chr = chr; drv->console = s; -if (display_state) { -text_console_do_init (chr, display_state); - } +text_console_do_init (chr);/* console/chardev init sometimes completes elsewhere in a 2nd * stage, so defer OPENED events until they are fully initialized
Signature · 1 line
2.41.0
Re: [PATCH 09/67] ui/console: get the DisplayState from new_console()
Quoted 26 lines · On Wed, 30 Aug 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
There is no obvious reason to defer text console initialization. We can simply take the global display state in
new_console().This simplify somewhat the code to allow moving the VC to a separate unit.
Signed-off-by Marc-André Lureau <[email protected]>---
ui/console.c| 26 ++++++++------------------1 file changed, 8 insertions(+), 18 deletions(-)ui/console.c +1
-1@@ -143,7 +143,7 @@ static QTAILQ_HEAD(, QemuConsole) consoles =static bool cursor_visible_phase;static QEMUTimer *cursor_timer; -static void text_console_do_init (Chardev *chr,DisplayState *ds); +static void text_console_do_init (Chardev *chr);static void dpy_refresh (DisplayState *s);static DisplayState *get_alloc_displaystate (void );static void text_console_update_cursor_timer (void );
ui/console.c static void text_console_update(void *opaque, console_ch_t *chardata) · line 1253
Quoted 6 lines
ui/console.c +1
-1@@ -1249,9 +1249,10 @@ static void text_console_update(void *opaque, console_ch_t *chardata) } } -static QemuConsole *new_console (DisplayState *ds,console_type_t console_type, +static QemuConsole *new_console (console_type_t console_type,uint32_t head)
It should be possible to remove the new line and fit it in one line now too.
Regards,
BALATON Zoltan
Re: [PATCH 09/67] ui/console: get the DisplayState from new_console()
In reply to [email protected]Quoted 11 lines · On Wed, Aug 30, 2023 at 01:37:43PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
There is no obvious reason to defer text console initialization. We can simply take the global display state in
new_console().This simplify somewhat the code to allow moving the VC to a separate unit.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
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 :|
PATCH 10/67 ui/console: new_console() cannot fail
In reply to [email protected]From: Marc-André Lureau <[email protected]>
There is no code path that could allow a NULL return there.
--- ui/console.c | 5 ----- 1 file changed, 5 deletions(-)
ui/console.c +0 -5
@@ -2481,11 +2481,6 @@ static void vc_chr_open(Chardev *chr, s->surface =qemu_create_displaysurface (width, height); } -if (!s) { -error_setg (errp,"cannot create text console" ); -return ; - } - s->chr = chr; drv->console = s;
Signature · 1 line
2.41.0
Re: [PATCH 10/67] ui/console: new_console() cannot fail
Quoted 8 lines · On Wed, Aug 30, 2023 at 01:37:44PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
There is no code path that could allow a NULL return there.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 5 ----- 1 file changed, 5 deletions(-)
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 :|
PATCH 11/67 ui/vc: VC always has a DisplayState now
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 4 ---- 1 file changed, 4 deletions(-)
ui/console.c +0 -4
@@ -1067,10 +1067,6 @@ static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)QemuConsole *s = drv->console;int i; -if (!s->ds) { -return 0 ; - } - s->update_x0 = s->width *FONT_WIDTH ; s->update_y0 = s->height *FONT_HEIGHT ; s->update_x1 =0 ;
Signature · 1 line
2.41.0
Re: [PATCH 11/67] ui/vc: VC always has a DisplayState now
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:37:45PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 4 ---- 1 file changed, 4 deletions(-)
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 :|
PATCH 12/67 ui/vc: move VCChardev declaration at the top
In reply to [email protected]From: Marc-André Lureau <[email protected]>
To allow easier refactoring in following patches.
--- ui/console.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
ui/console.c +6 -6
@@ -127,6 +127,12 @@ struct QemuConsole {QTAILQ_ENTRY (QemuConsole) next; }; +struct VCChardev { +Chardev parent; +QemuConsole *console; +}; +typedef struct VCChardev VCChardev ; +struct DisplayState {QEMUTimer *gui_timer;uint64_t last_update;
@@ -1051,12 +1057,6 @@ void console_select(unsigned int index) } } -struct VCChardev { -Chardev parent; -QemuConsole *console; -}; -typedef struct VCChardev VCChardev ; -#define TYPE_CHARDEV_VC "chardev-vc"DECLARE_INSTANCE_CHECKER (VCChardev,VC_CHARDEV ,TYPE_CHARDEV_VC )
Signature · 1 line
2.41.0
Re: [PATCH 12/67] ui/vc: move VCChardev declaration at the top
Quoted 8 lines · On Wed, Aug 30, 2023 at 01:37:46PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
To allow easier refactoring in following patches.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
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 :|
PATCH 13/67 ui/vc: replace variable with static text attributes default
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
ui/console.c +13 -17
@@ -52,6 +52,11 @@ typedef struct TextAttributes { uint8_t unvisible:1; } TextAttributes; +#define TEXT_ATTRIBUTES_DEFAULT ((TextAttributes) { \ + .fgcol = QEMU_COLOR_WHITE, \ + .bgcol = QEMU_COLOR_BLACK \ +}) + typedef struct TextCell { uint8_t ch; TextAttributes t_attrib;
@@ -104,7 +109,6 @@ struct QemuConsole {int x_saved, y_saved;int y_displayed;int y_base; -TextAttributes t_attrib_default;/* default text attributes */ TextAttributes t_attrib;/* currently active text attributes */ TextCell *cells;int text_x[2 ], text_y[2 ], cursor_invalidate;
@@ -413,7 +417,7 @@ static void text_console_resize(QemuConsole *s) }for (x = w1; x < s->width; x++) { c->ch =' ' ; - c->t_attrib = s->t_attrib_default; + c->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; c++; } }
@@ -486,7 +490,7 @@ static void console_show_cursor(QemuConsole *s, int show)if (y < s->height) { c = &s->cells[y1 * s->width + x];if (show && cursor_visible_phase) { -TextAttributes t_attrib = s->t_attrib_default; +TextAttributes t_attrib =TEXT_ATTRIBUTES_DEFAULT ; t_attrib.invers = !(t_attrib.invers);/* invert fg and bg */ vga_putcharxy (s, x, y, c->ch, &t_attrib); }else {
@@ -577,7 +581,7 @@ static void console_put_lf(QemuConsole *s) c = &s->cells[y1 * s->width];for (x =0 ; x < s->width; x++) { c->ch =' ' ; - c->t_attrib = s->t_attrib_default; + c->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; c++; }if (s->y_displayed == s->y_base) {
@@ -591,7 +595,7 @@ static void console_put_lf(QemuConsole *s) (s->height - 1) * FONT_HEIGHT);vga_fill_rect (s,0 , (s->height -1 ) *FONT_HEIGHT , s->width *FONT_WIDTH ,FONT_HEIGHT , - color_table_rgb[0 ][s->t_attrib_default.bgcol]); + color_table_rgb[0 ][TEXT_ATTRIBUTES_DEFAULT .bgcol]); s->update_x0 =0 ; s->update_y0 =0 ; s->update_x1 = s->width *FONT_WIDTH ;
@@ -611,7 +615,7 @@ static void console_handle_escape(QemuConsole *s)for (i=0 ; i<s->nb_esc_params; i++) {switch (s->esc_params[i]) {case 0 :/* reset all console attributes to default */ - s->t_attrib = s->t_attrib_default; + s->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;break ;case 1 : s->t_attrib.bold =1 ;
@@ -705,7 +709,7 @@ static void console_clear_xy(QemuConsole *s, int x, int y) }TextCell *c = &s->cells[y1 * s->width + x]; c->ch =' ' ; - c->t_attrib = s->t_attrib_default; + c->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;update_xy (s, x, y); }
@@ -2420,16 +2424,8 @@ static void text_console_do_init(Chardev *chr) s->hw_ops = &text_console_ops; s->hw = s; -/* Set text attribute defaults */ - s->t_attrib_default.bold =0 ; - s->t_attrib_default.uline =0 ; - s->t_attrib_default.blink =0 ; - s->t_attrib_default.invers =0 ; - s->t_attrib_default.unvisible =0 ; - s->t_attrib_default.fgcol =QEMU_COLOR_WHITE ; - s->t_attrib_default.bgcol =QEMU_COLOR_BLACK ;/* set current text attributes to default */ - s->t_attrib = s->t_attrib_default; + s->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;text_console_resize (s);if (chr->label) {
@@ -2439,7 +2435,7 @@ static void text_console_do_init(Chardev *chr) msg =g_strdup_printf ("%s console\r\n" , chr->label);qemu_chr_write (chr, (uint8_t *)msg,strlen (msg), true);g_free (msg); - s->t_attrib = s->t_attrib_default; + s->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; }qemu_chr_be_event (chr,CHR_EVENT_OPENED );
Signature · 1 line
2.41.0
Re: [PATCH 13/67] ui/vc: replace variable with static text attributes default
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:37:47PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
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 :|
PATCH 14/67 ui/vc: fold text_update_xy()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
ui/console.c +4 -9
@@ -425,14 +425,6 @@ static void text_console_resize(QemuConsole *s) s->cells = cells; } -static inline void text_update_xy (QemuConsole *s,int x,int y) -{ - s->text_x[0 ] =MIN (s->text_x[0 ], x); - s->text_x[1 ] =MAX (s->text_x[1 ], x); - s->text_y[0 ] =MIN (s->text_y[0 ], y); - s->text_y[1 ] =MAX (s->text_y[1 ], y); -} -static void invalidate_xy (QemuConsole *s,int x,int y) {if (!qemu_console_is_visible (s)) {
@@ -453,7 +445,10 @@ static void update_xy(QemuConsole *s, int x, int y)TextCell *c;int y1, y2; -text_update_xy (s, x, y); + s->text_x[0 ] =MIN (s->text_x[0 ], x); + s->text_x[1 ] =MAX (s->text_x[1 ], x); + s->text_y[0 ] =MIN (s->text_y[0 ], y); + s->text_y[1 ] =MAX (s->text_y[1 ], y); y1 = (s->y_base + y) % s->total_height; y2 = y1 - s->y_displayed;
Signature · 1 line
2.41.0
Re: [PATCH 14/67] ui/vc: fold text_update_xy()
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:37:48PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
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 :|
PATCH 15/67 ui/vc: pass VCCharDev to VC-specific functions
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Even though the actually use more QemuConsole at this point, it makes it clear those functions are only used from the chardev implementation.
--- ui/console.c | 70 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 31 deletions(-)
ui/console.c +39 -31
@@ -440,8 +440,9 @@ static void invalidate_xy(QemuConsole *s, int x, int y) s->update_y1 = (y +1 ) *FONT_HEIGHT ; } -static void update_xy (QemuConsole *s,int x,int y) +static void vc_update_xy (VCChardev *vc,int x,int y) { +QemuConsole *s = vc->console;TextCell *c;int y1, y2;
@@ -555,8 +556,9 @@ static void console_scroll(QemuConsole *s, int ydelta)console_refresh (s); } -static void console_put_lf (QemuConsole *s) +static void vc_put_lf (VCChardev *vc) { +QemuConsole *s = vc->console;TextCell *c;int x, y1;
@@ -603,8 +605,9 @@ static void console_put_lf(QemuConsole *s)* NOTE: I know this code is not very efficient (checking every color for it * self) but it is more readable and better maintainable. */ -static void console_handle_escape (QemuConsole *s) +static void vc_handle_escape (VCChardev *vc) { +QemuConsole *s = vc->console;int i;for (i=0 ; i<s->nb_esc_params; i++) {
@@ -696,8 +699,9 @@ static void console_handle_escape(QemuConsole *s) } } -static void console_clear_xy (QemuConsole *s,int x,int y) +static void vc_clear_xy (VCChardev *vc,int x,int y) { +QemuConsole *s = vc->console;int y1 = (s->y_base + y) % s->total_height;if (x >= s->width) { x = s->width -1 ;
@@ -705,37 +709,40 @@ static void console_clear_xy(QemuConsole *s, int x, int y)TextCell *c = &s->cells[y1 * s->width + x]; c->ch =' ' ; c->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; -update_xy (s, x, y); +vc_update_xy (vc, x, y); } -static void console_put_one (QemuConsole *s,int ch) +static void vc_put_one (VCChardev *vc,int ch) { +QemuConsole *s = vc->console;TextCell *c;int y1;if (s->x >= s->width) {/* line wrap */ s->x =0 ; -console_put_lf (s); +vc_put_lf (vc); } y1 = (s->y_base + s->y) % s->total_height; c = &s->cells[y1 * s->width + s->x]; c->ch = ch; c->t_attrib = s->t_attrib; -update_xy (s, s->x, s->y); +vc_update_xy (vc, s->x, s->y); s->x++; } -static void console_respond_str (QemuConsole *s,const char *buf) +static void vc_respond_str (VCChardev *vc,const char *buf) {while (*buf) { -console_put_one (s, *buf); +vc_put_one (vc, *buf); buf++; } }/* set cursor, checking bounds */ -static void set_cursor (QemuConsole *s,int x,int y) +static void vc_set_cursor (VCChardev *vc,int x,int y) { +QemuConsole *s = vc->console; +if (x <0 ) { x =0 ; }
@@ -753,8 +760,9 @@ static void set_cursor(QemuConsole *s, int x, int y) s->y = y; } -static void console_putchar (QemuConsole *s,int ch) +static void vc_putchar (VCChardev *vc,int ch) { +QemuConsole *s = vc->console;int i;int x, y;char response[40 ];
@@ -766,7 +774,7 @@ static void console_putchar(QemuConsole *s, int ch) s->x =0 ;break ;case '\n' :/* newline */ -console_put_lf (s); +vc_put_lf (vc);break ;case '\b' :/* backspace */ if (s->x >0 )
@@ -775,7 +783,7 @@ static void console_putchar(QemuConsole *s, int ch)case '\t' :/* tabspace */ if (s->x + (8 - (s->x %8 )) > s->width) { s->x =0 ; -console_put_lf (s); +vc_put_lf (vc); }else { s->x = s->x + (8 - (s->x %8 )); }
@@ -793,7 +801,7 @@ static void console_putchar(QemuConsole *s, int ch) s->state =TTY_STATE_ESC ;break ;default : -console_put_one (s, ch); +vc_put_one (vc, ch);break ; }break ;
@@ -831,37 +839,37 @@ static void console_putchar(QemuConsole *s, int ch)if (s->esc_params[0 ] ==0 ) { s->esc_params[0 ] =1 ; } -set_cursor (s, s->x, s->y - s->esc_params[0 ]); +vc_set_cursor (vc, s->x, s->y - s->esc_params[0 ]);break ;case 'B' :/* move cursor down */ if (s->esc_params[0 ] ==0 ) { s->esc_params[0 ] =1 ; } -set_cursor (s, s->x, s->y + s->esc_params[0 ]); +vc_set_cursor (vc, s->x, s->y + s->esc_params[0 ]);break ;case 'C' :/* move cursor right */ if (s->esc_params[0 ] ==0 ) { s->esc_params[0 ] =1 ; } -set_cursor (s, s->x + s->esc_params[0 ], s->y); +vc_set_cursor (vc, s->x + s->esc_params[0 ], s->y);break ;case 'D' :/* move cursor left */ if (s->esc_params[0 ] ==0 ) { s->esc_params[0 ] =1 ; } -set_cursor (s, s->x - s->esc_params[0 ], s->y); +vc_set_cursor (vc, s->x - s->esc_params[0 ], s->y);break ;case 'G' :/* move cursor to column */ -set_cursor (s, s->esc_params[0 ] -1 , s->y); +vc_set_cursor (vc, s->esc_params[0 ] -1 , s->y);break ;case 'f' :case 'H' :/* move cursor to row, column */ -set_cursor (s, s->esc_params[1 ] -1 , s->esc_params[0 ] -1 ); +vc_set_cursor (vc, s->esc_params[1 ] -1 , s->esc_params[0 ] -1 );break ;case 'J' :switch (s->esc_params[0 ]) {
@@ -872,7 +880,7 @@ static void console_putchar(QemuConsole *s, int ch)if (y == s->y && x < s->x) {continue ; } -console_clear_xy (s, x, y); +vc_clear_xy (vc, x, y); } }break ;
@@ -883,7 +891,7 @@ static void console_putchar(QemuConsole *s, int ch)if (y == s->y && x > s->x) {break ; } -console_clear_xy (s, x, y); +vc_clear_xy (vc, x, y); } }break ;
@@ -891,7 +899,7 @@ static void console_putchar(QemuConsole *s, int ch)/* clear entire screen */ for (y =0 ; y <= s->height; y++) {for (x =0 ; x < s->width; x++) { -console_clear_xy (s, x, y); +vc_clear_xy (vc, x, y); } }break ;
@@ -902,38 +910,38 @@ static void console_putchar(QemuConsole *s, int ch)case 0 :/* clear to eol */ for (x = s->x; x < s->width; x++) { -console_clear_xy (s, x, s->y); +vc_clear_xy (vc, x, s->y); }break ;case 1 :/* clear from beginning of line */ for (x =0 ; x <= s->x && x < s->width; x++) { -console_clear_xy (s, x, s->y); +vc_clear_xy (vc, x, s->y); }break ;case 2 :/* clear entire line */ for (x =0 ; x < s->width; x++) { -console_clear_xy (s, x, s->y); +vc_clear_xy (vc, x, s->y); }break ; }break ;case 'm' : -console_handle_escape (s); +vc_handle_escape (vc);break ;case 'n' :switch (s->esc_params[0 ]) {case 5 :/* report console status (always succeed)*/ -console_respond_str (s,"\033[0n" ); +vc_respond_str (vc,"\033[0n" );break ;case 6 :/* report cursor position */ sprintf (response,"\033[%d;%dR" , (s->y_base + s->y) % s->total_height +1 , s->x +1 ); -console_respond_str (s, response); +vc_respond_str (vc, response);break ; }break ;
@@ -1072,7 +1080,7 @@ static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len) s->update_y1 =0 ;console_show_cursor (s,0 );for (i =0 ; i < len; i++) { -console_putchar (s, buf[i]); +vc_putchar (drv, buf[i]); }console_show_cursor (s,1 );if (s->update_x0 < s->update_x1) {
Signature · 1 line
2.41.0
Re: [PATCH 15/67] ui/vc: pass VCCharDev to VC-specific functions
Quoted 3 lines · On Wed, Aug 30, 2023 at 01:37:49PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Even though the actually use more QemuConsole at this point, it makes it
^^^^ word missing here ??
Quoted 6 lines
clear those functions are only used from the chardev implementation.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 70 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 31 deletions(-)
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 :|
PATCH 16/67 ui/vc: move VCCharDev specific fields out of QemuConsole
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 147 +++++++++++++++++++++++++-------------------------- 1 file changed, 73 insertions(+), 74 deletions(-)
ui/console.c +73 -74
@@ -106,10 +106,8 @@ struct QemuConsole {int total_height;int backscroll_height;int x, y; -int x_saved, y_saved;int y_displayed;int y_base; -TextAttributes t_attrib;/* currently active text attributes */ TextCell *cells;int text_x[2 ], text_y[2 ], cursor_invalidate;int echo;
@@ -119,10 +117,6 @@ struct QemuConsole {int update_x1;int update_y1; -enum TTYState state; -int esc_params[MAX_ESC_PARAMS ]; -int nb_esc_params; -Chardev *chr;/* fifo for key pressed */ Fifo8 out_fifo;
@@ -134,6 +128,12 @@ struct QemuConsole {struct VCChardev {Chardev parent;QemuConsole *console; + +enum TTYState state; +int esc_params[MAX_ESC_PARAMS ]; +int nb_esc_params; +TextAttributes t_attrib;/* currently active text attributes */ +int x_saved, y_saved; };typedef struct VCChardev VCChardev ;
@@ -607,93 +607,92 @@ static void vc_put_lf(VCChardev *vc)*/ static void vc_handle_escape (VCChardev *vc) { -QemuConsole *s = vc->console;int i; -for (i=0 ; i<s->nb_esc_params; i++) { -switch (s->esc_params[i]) { +for (i =0 ; i < vc->nb_esc_params; i++) { +switch (vc->esc_params[i]) {case 0 :/* reset all console attributes to default */ - s->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; + vc->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;break ;case 1 : - s->t_attrib.bold =1 ; + vc->t_attrib.bold =1 ;break ;case 4 : - s->t_attrib.uline =1 ; + vc->t_attrib.uline =1 ;break ;case 5 : - s->t_attrib.blink =1 ; + vc->t_attrib.blink =1 ;break ;case 7 : - s->t_attrib.invers =1 ; + vc->t_attrib.invers =1 ;break ;case 8 : - s->t_attrib.unvisible =1 ; + vc->t_attrib.unvisible =1 ;break ;case 22 : - s->t_attrib.bold =0 ; + vc->t_attrib.bold =0 ;break ;case 24 : - s->t_attrib.uline =0 ; + vc->t_attrib.uline =0 ;break ;case 25 : - s->t_attrib.blink =0 ; + vc->t_attrib.blink =0 ;break ;case 27 : - s->t_attrib.invers =0 ; + vc->t_attrib.invers =0 ;break ;case 28 : - s->t_attrib.unvisible =0 ; + vc->t_attrib.unvisible =0 ;break ;/* set foreground color */ case 30 : - s->t_attrib.fgcol =QEMU_COLOR_BLACK ; + vc->t_attrib.fgcol =QEMU_COLOR_BLACK ;break ;case 31 : - s->t_attrib.fgcol =QEMU_COLOR_RED ; + vc->t_attrib.fgcol =QEMU_COLOR_RED ;break ;case 32 : - s->t_attrib.fgcol =QEMU_COLOR_GREEN ; + vc->t_attrib.fgcol =QEMU_COLOR_GREEN ;break ;case 33 : - s->t_attrib.fgcol =QEMU_COLOR_YELLOW ; + vc->t_attrib.fgcol =QEMU_COLOR_YELLOW ;break ;case 34 : - s->t_attrib.fgcol =QEMU_COLOR_BLUE ; + vc->t_attrib.fgcol =QEMU_COLOR_BLUE ;break ;case 35 : - s->t_attrib.fgcol =QEMU_COLOR_MAGENTA ; + vc->t_attrib.fgcol =QEMU_COLOR_MAGENTA ;break ;case 36 : - s->t_attrib.fgcol =QEMU_COLOR_CYAN ; + vc->t_attrib.fgcol =QEMU_COLOR_CYAN ;break ;case 37 : - s->t_attrib.fgcol =QEMU_COLOR_WHITE ; + vc->t_attrib.fgcol =QEMU_COLOR_WHITE ;break ;/* set background color */ case 40 : - s->t_attrib.bgcol =QEMU_COLOR_BLACK ; + vc->t_attrib.bgcol =QEMU_COLOR_BLACK ;break ;case 41 : - s->t_attrib.bgcol =QEMU_COLOR_RED ; + vc->t_attrib.bgcol =QEMU_COLOR_RED ;break ;case 42 : - s->t_attrib.bgcol =QEMU_COLOR_GREEN ; + vc->t_attrib.bgcol =QEMU_COLOR_GREEN ;break ;case 43 : - s->t_attrib.bgcol =QEMU_COLOR_YELLOW ; + vc->t_attrib.bgcol =QEMU_COLOR_YELLOW ;break ;case 44 : - s->t_attrib.bgcol =QEMU_COLOR_BLUE ; + vc->t_attrib.bgcol =QEMU_COLOR_BLUE ;break ;case 45 : - s->t_attrib.bgcol =QEMU_COLOR_MAGENTA ; + vc->t_attrib.bgcol =QEMU_COLOR_MAGENTA ;break ;case 46 : - s->t_attrib.bgcol =QEMU_COLOR_CYAN ; + vc->t_attrib.bgcol =QEMU_COLOR_CYAN ;break ;case 47 : - s->t_attrib.bgcol =QEMU_COLOR_WHITE ; + vc->t_attrib.bgcol =QEMU_COLOR_WHITE ;break ; } }
@@ -725,7 +724,7 @@ static void vc_put_one(VCChardev *vc, int ch) y1 = (s->y_base + s->y) % s->total_height; c = &s->cells[y1 * s->width + s->x]; c->ch = ch; - c->t_attrib = s->t_attrib; + c->t_attrib = vc->t_attrib;vc_update_xy (vc, s->x, s->y); s->x++; }
@@ -767,7 +766,7 @@ static void vc_putchar(VCChardev *vc, int ch)int x, y;char response[40 ]; -switch (s->state) { +switch (vc->state) {case TTY_STATE_NORM :switch (ch) {case '\r' :/* carriage return */
@@ -798,7 +797,7 @@ static void vc_putchar(VCChardev *vc, int ch)/* SO (shift out), character set 1 (ignored) */ break ;case 27 :/* esc (introducing an escape sequence) */ - s->state =TTY_STATE_ESC ; + vc->state =TTY_STATE_ESC ;break ;default :vc_put_one (vc, ch);
@@ -808,71 +807,71 @@ static void vc_putchar(VCChardev *vc, int ch)case TTY_STATE_ESC :/* check if it is a terminal escape sequence */ if (ch =='[' ) {for (i=0 ;i<MAX_ESC_PARAMS ;i++) - s->esc_params[i] =0 ; - s->nb_esc_params =0 ; - s->state =TTY_STATE_CSI ; + vc->esc_params[i] =0 ; + vc->nb_esc_params =0 ; + vc->state =TTY_STATE_CSI ; }else { - s->state =TTY_STATE_NORM ; + vc->state =TTY_STATE_NORM ; }break ;case TTY_STATE_CSI :/* handle escape sequence parameters */ if (ch >='0' && ch <='9' ) { -if (s->nb_esc_params <MAX_ESC_PARAMS ) { -int *param = &s->esc_params[s->nb_esc_params]; +if (vc->nb_esc_params <MAX_ESC_PARAMS ) { +int *param = &vc->esc_params[vc->nb_esc_params];int digit = (ch -'0' ); *param = (*param <= (INT_MAX - digit) /10 ) ? *param *10 + digit :INT_MAX ; } }else { -if (s->nb_esc_params <MAX_ESC_PARAMS ) - s->nb_esc_params++; +if (vc->nb_esc_params <MAX_ESC_PARAMS ) + vc->nb_esc_params++;if (ch ==';' || ch =='?' ) {break ; } -trace_console_putchar_csi (s->esc_params[0 ], s->esc_params[1 ], - ch, s->nb_esc_params); - s->state =TTY_STATE_NORM ; +trace_console_putchar_csi (vc->esc_params[0 ], vc->esc_params[1 ], + ch, vc->nb_esc_params); + vc->state =TTY_STATE_NORM ;switch (ch) {case 'A' :/* move cursor up */ -if (s->esc_params[0 ] ==0 ) { - s->esc_params[0 ] =1 ; +if (vc->esc_params[0 ] ==0 ) { + vc->esc_params[0 ] =1 ; } -vc_set_cursor (vc, s->x, s->y - s->esc_params[0 ]); +vc_set_cursor (vc, s->x, s->y - vc->esc_params[0 ]);break ;case 'B' :/* move cursor down */ -if (s->esc_params[0 ] ==0 ) { - s->esc_params[0 ] =1 ; +if (vc->esc_params[0 ] ==0 ) { + vc->esc_params[0 ] =1 ; } -vc_set_cursor (vc, s->x, s->y + s->esc_params[0 ]); +vc_set_cursor (vc, s->x, s->y + vc->esc_params[0 ]);break ;case 'C' :/* move cursor right */ -if (s->esc_params[0 ] ==0 ) { - s->esc_params[0 ] =1 ; +if (vc->esc_params[0 ] ==0 ) { + vc->esc_params[0 ] =1 ; } -vc_set_cursor (vc, s->x + s->esc_params[0 ], s->y); +vc_set_cursor (vc, s->x + vc->esc_params[0 ], s->y);break ;case 'D' :/* move cursor left */ -if (s->esc_params[0 ] ==0 ) { - s->esc_params[0 ] =1 ; +if (vc->esc_params[0 ] ==0 ) { + vc->esc_params[0 ] =1 ; } -vc_set_cursor (vc, s->x - s->esc_params[0 ], s->y); +vc_set_cursor (vc, s->x - vc->esc_params[0 ], s->y);break ;case 'G' :/* move cursor to column */ -vc_set_cursor (vc, s->esc_params[0 ] -1 , s->y); +vc_set_cursor (vc, vc->esc_params[0 ] -1 , s->y);break ;case 'f' :case 'H' :/* move cursor to row, column */ -vc_set_cursor (vc, s->esc_params[1 ] -1 , s->esc_params[0 ] -1 ); +vc_set_cursor (vc, vc->esc_params[1 ] -1 , vc->esc_params[0 ] -1 );break ;case 'J' : -switch (s->esc_params[0 ]) { +switch (vc->esc_params[0 ]) {case 0 :/* clear to end of screen */ for (y = s->y; y < s->height; y++) {
@@ -906,7 +905,7 @@ static void vc_putchar(VCChardev *vc, int ch) }break ;case 'K' : -switch (s->esc_params[0 ]) { +switch (vc->esc_params[0 ]) {case 0 :/* clear to eol */ for (x = s->x; x < s->width; x++) {
@@ -931,7 +930,7 @@ static void vc_putchar(VCChardev *vc, int ch)vc_handle_escape (vc);break ;case 'n' : -switch (s->esc_params[0 ]) { +switch (vc->esc_params[0 ]) {case 5 :/* report console status (always succeed)*/ vc_respond_str (vc,"\033[0n" );
@@ -947,13 +946,13 @@ static void vc_putchar(VCChardev *vc, int ch)break ;case 's' :/* save cursor position */ - s->x_saved = s->x; - s->y_saved = s->y; + vc->x_saved = s->x; + vc->y_saved = s->y;break ;case 'u' :/* restore cursor position */ - s->x = s->x_saved; - s->y = s->y_saved; + s->x = vc->x_saved; + s->y = vc->y_saved;break ;default :trace_console_putchar_unhandled (ch);
@@ -2428,17 +2427,17 @@ static void text_console_do_init(Chardev *chr) s->hw = s;/* set current text attributes to default */ - s->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; + drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;text_console_resize (s);if (chr->label) {char *msg; - s->t_attrib.bgcol =QEMU_COLOR_BLUE ; + drv->t_attrib.bgcol =QEMU_COLOR_BLUE ; msg =g_strdup_printf ("%s console\r\n" , chr->label);qemu_chr_write (chr, (uint8_t *)msg,strlen (msg), true);g_free (msg); - s->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; + drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; }qemu_chr_be_event (chr,CHR_EVENT_OPENED );
Signature · 1 line
2.41.0
Re: [PATCH 16/67] ui/vc: move VCCharDev specific fields out of QemuConsole
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:37:50PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 147 +++++++++++++++++++++++++-------------------------- 1 file changed, 73 insertions(+), 74 deletions(-)
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 :|
PATCH 17/67 ui/console: use OBJECT_DEFINE_TYPE for QemuConsole
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The following patch will move some object initialization to the corresponding handlers.
--- ui/console.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
ui/console.c +17 -14
@@ -125,6 +125,8 @@ struct QemuConsole {QTAILQ_ENTRY (QemuConsole) next; }; +OBJECT_DEFINE_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJECT) +struct VCChardev {Chardev parent;QemuConsole *console;
@@ -1314,6 +1316,21 @@ static QemuConsole *new_console(console_type_t console_type,return s; } +static void +qemu_console_finalize (Object *obj) +{ +} + +static void +qemu_console_class_init (ObjectClass *oc,void *data) +{ +} + +static void +qemu_console_init (Object *obj) +{ +} +#ifdef WIN32 void qemu_displaysurface_win32_set_handle (DisplaySurface *surface,HANDLE h,uint32_t offset)
@@ -2647,13 +2664,6 @@ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp) } } -static const TypeInfo qemu_console_info = { - .name =TYPE_QEMU_CONSOLE , - .parent =TYPE_OBJECT , - .instance_size =sizeof (QemuConsole), - .class_size =sizeof (QemuConsoleClass), -}; -static void char_vc_class_init (ObjectClass *oc,void *data) {ChardevClass *cc =CHARDEV_CLASS (oc);
@@ -2679,10 +2689,3 @@ void qemu_console_early_init(void)type_register (&char_vc_type_info); } } - -static void register_types (void ) -{ -type_register_static (&qemu_console_info); -} - -type_init (register_types);
Signature · 1 line
2.41.0
Re: [PATCH 17/67] ui/console: use OBJECT_DEFINE_TYPE for QemuConsole
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:37:51PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The following patch will move some object initialization to the corresponding handlers.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
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 :|
PATCH 18/67 ui/console: change new_console() to use object initialization
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Object construction should be done in respective object instance and class handlers.
Introduce qemu_console_register() to split out the registration logic.
--- ui/console.c | 93 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 37 deletions(-)
ui/console.c +56 -37
@@ -27,6 +27,7 @@#include "hw/qdev-core.h" #include "qapi/error.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/visitor.h" #include "qemu/coroutine.h" #include "qemu/fifo8.h" #include "qemu/error-report.h"
@@ -1253,40 +1254,24 @@ static void text_console_update(void *opaque, console_ch_t *chardata) } } -static QemuConsole *new_console (console_type_t console_type, -uint32_t head) +static void +qemu_console_register (QemuConsole *c,console_type_t console_type) { -DisplayState *ds =get_alloc_displaystate (); -Object *obj; -QemuConsole *s;int i; - obj =object_new (TYPE_QEMU_CONSOLE ); - s =QEMU_CONSOLE (obj); -qemu_co_queue_init (&s->dump_queue); - s->head = head; -object_property_add_link (obj,"device" ,TYPE_DEVICE , - (Object **)&s->device, - object_property_allow_set_link, -OBJ_PROP_LINK_STRONG ); -object_property_add_uint32_ptr (obj,"head" , &s->head, -OBJ_PROP_FLAG_READ ); -if (!active_console || ((active_console->console_type !=GRAPHIC_CONSOLE ) && - (console_type ==GRAPHIC_CONSOLE ))) { - active_console = s; + (console_type ==GRAPHIC_CONSOLE ))) { + active_console = c; } - s->ds = ds; - s->console_type = console_type; - s->window_id =-1 ; + c->console_type = console_type;if (QTAILQ_EMPTY (&consoles)) { - s->index =0 ; -QTAILQ_INSERT_TAIL (&consoles, s, next); + c->index =0 ; +QTAILQ_INSERT_TAIL (&consoles, c, next); }else if (console_type !=GRAPHIC_CONSOLE ||phase_check (PHASE_MACHINE_READY )) {QemuConsole *last =QTAILQ_LAST (&consoles); - s->index = last->index +1 ; -QTAILQ_INSERT_TAIL (&consoles, s, next); + c->index = last->index +1 ; +QTAILQ_INSERT_TAIL (&consoles, c, next); }else {/* * HACK: Put graphical consoles before text consoles.
@@ -1294,41 +1279,75 @@ static QemuConsole *new_console(console_type_t console_type,* Only do that for coldplugged devices. After initial device * initialization we will not renumber the consoles any more. */ -QemuConsole *c =QTAILQ_FIRST (&consoles); +QemuConsole *it =QTAILQ_FIRST (&consoles); -while (QTAILQ_NEXT (c, next) !=NULL && - c->console_type ==GRAPHIC_CONSOLE ) { - c =QTAILQ_NEXT (c, next); +while (QTAILQ_NEXT (it, next) !=NULL && + it->console_type ==GRAPHIC_CONSOLE ) { + it =QTAILQ_NEXT (it, next); } -if (c->console_type ==GRAPHIC_CONSOLE ) { +if (it->console_type ==GRAPHIC_CONSOLE ) {/* have no text consoles */ - s->index = c->index +1 ; -QTAILQ_INSERT_AFTER (&consoles, c, s, next); + c->index = it->index +1 ; +QTAILQ_INSERT_AFTER (&consoles, it, c, next); }else { - s->index = c->index; -QTAILQ_INSERT_BEFORE (c, s, next); + c->index = it->index; +QTAILQ_INSERT_BEFORE (it, c, next);/* renumber text consoles */ -for (i = s->index +1 ; c !=NULL ; c =QTAILQ_NEXT (c, next), i++) { - c->index = i; +for (i = c->index +1 ; it !=NULL ; it =QTAILQ_NEXT (it, next), i++) { + it->index = i; } } } -return s; }static void qemu_console_finalize (Object *obj) { +/* TODO: should unregister from consoles and free itself */ +} + +static void +qemu_console_prop_get_head (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +QemuConsole *c =QEMU_CONSOLE (obj); + +visit_type_uint32 (v, name, &c->head, errp); }static void qemu_console_class_init (ObjectClass *oc,void *data) { +object_class_property_add_link (oc,"device" ,TYPE_DEVICE , + offsetof(QemuConsole , device), + object_property_allow_set_link, +OBJ_PROP_LINK_STRONG ); +object_class_property_add (oc,"head" ,"uint32" , + qemu_console_prop_get_head, +NULL ,NULL ,NULL ); }static void qemu_console_init (Object *obj) { +QemuConsole *c =QEMU_CONSOLE (obj); +DisplayState *ds =get_alloc_displaystate (); + +qemu_co_queue_init (&c->dump_queue); + c->ds = ds; + c->window_id =-1 ; +} + +static QemuConsole *new_console (console_type_t console_type, +uint32_t head) +{ +QemuConsole *c =QEMU_CONSOLE (object_new (TYPE_QEMU_CONSOLE )); + + c->head = head; +/* TODO: move to console_init() once there is a type hierarchy */ +qemu_console_register (c, console_type); + +return c; }#ifdef WIN32
Signature · 1 line
2.41.0
Re: [PATCH 18/67] ui/console: change new_console() to use object initialization
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:37:52PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Object construction should be done in respective object instance and class handlers.
Introduce
qemu_console_register()to split out the registration logic.Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 93 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 37 deletions(-)
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 :|
PATCH 19/67 ui/console: introduce different console objects
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Boilerplate code to introduce different object types for the different console types.
--- ui/console.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
ui/console.c +84 -0
@@ -128,6 +128,45 @@ struct QemuConsole { OBJECT_DEFINE_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJECT) +typedef struct QemuGraphicConsole { +QemuConsole parent; +}QemuGraphicConsole ; + +typedef QemuConsoleClass QemuGraphicConsoleClass ; + +#define TYPE_QEMU_GRAPHIC_CONSOLE "qemu-graphic-console" +OBJECT_DECLARE_SIMPLE_TYPE(QemuGraphicConsole, QEMU_GRAPHIC_CONSOLE) +OBJECT_DEFINE_TYPE(QemuGraphicConsole, qemu_graphic_console, QEMU_GRAPHIC_CONSOLE, QEMU_CONSOLE) + +#define QEMU_IS_GRAPHIC_CONSOLE (c) \ + object_dynamic_cast(OBJECT(c), TYPE_QEMU_GRAPHIC_CONSOLE) + +typedef struct QemuTextConsole { +QemuConsole parent; +}QemuTextConsole ; + +typedef QemuConsoleClass QemuTextConsoleClass ; + +#define TYPE_QEMU_TEXT_CONSOLE "qemu-text-console" +OBJECT_DECLARE_SIMPLE_TYPE(QemuTextConsole, QEMU_TEXT_CONSOLE) +OBJECT_DEFINE_TYPE(QemuTextConsole, qemu_text_console, QEMU_TEXT_CONSOLE, QEMU_CONSOLE) + +#define QEMU_IS_TEXT_CONSOLE (c) \ + object_dynamic_cast(OBJECT(c), TYPE_QEMU_TEXT_CONSOLE) + +typedef struct QemuFixedTextConsole { +QemuTextConsole parent; +}QemuFixedTextConsole ; + +typedef QemuTextConsoleClass QemuFixedTextConsoleClass ; + +#define TYPE_QEMU_FIXED_TEXT_CONSOLE "qemu-fixed-text-console" +OBJECT_DECLARE_SIMPLE_TYPE(QemuFixedTextConsole, QEMU_FIXED_TEXT_CONSOLE) +OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_text_console, QEMU_FIXED_TEXT_CONSOLE, QEMU_TEXT_CONSOLE) + +#define QEMU_IS_FIXED_TEXT_CONSOLE (c) \ + object_dynamic_cast(OBJECT(c), TYPE_QEMU_FIXED_TEXT_CONSOLE) +struct VCChardev {Chardev parent;QemuConsole *console;
@@ -1338,6 +1377,51 @@ qemu_console_init(Object *obj) c->window_id =-1 ; } +static void +qemu_graphic_console_finalize (Object *obj) +{ +} + +static void +qemu_graphic_console_class_init (ObjectClass *oc,void *data) +{ +} + +static void +qemu_graphic_console_init (Object *obj) +{ +} + +static void +qemu_text_console_finalize (Object *obj) +{ +} + +static void +qemu_text_console_class_init (ObjectClass *oc,void *data) +{ +} + +static void +qemu_text_console_init (Object *obj) +{ +} + +static void +qemu_fixed_text_console_finalize (Object *obj) +{ +} + +static void +qemu_fixed_text_console_class_init (ObjectClass *oc,void *data) +{ +} + +static void +qemu_fixed_text_console_init (Object *obj) +{ +} +static QemuConsole *new_console (console_type_t console_type,uint32_t head) {
Signature · 1 line
2.41.0
Re: [PATCH 19/67] ui/console: introduce different console objects
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:37:53PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Boilerplate code to introduce different object types for the different console types.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 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 :|
PATCH 20/67 ui/console: instantiate a specific console type
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This will allow to move code/data to the specific console types.
Replace console_type_t with object type check.
QemuConsole can be abstract.
--- ui/console.c | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-)
ui/console.c +19 -28
@@ -71,17 +71,10 @@ enum TTYState { TTY_STATE_CSI, }; -typedef enum { -GRAPHIC_CONSOLE , -TEXT_CONSOLE , -TEXT_CONSOLE_FIXED_SIZE -}console_type_t ; -struct QemuConsole {Object parent;int index; -console_type_t console_type;DisplayState *ds;DisplaySurface *surface;DisplayScanout scanout;
@@ -126,7 +119,7 @@ struct QemuConsole {QTAILQ_ENTRY (QemuConsole) next; }; -OBJECT_DEFINE_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJECT) +OBJECT_DEFINE_ABSTRACT_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJECT) typedef struct QemuGraphicConsole { QemuConsole parent;
@@ -1156,7 +1149,7 @@ void kbd_put_keysym_console(QemuConsole *s, int keysym)int c;uint32_t num_free; -if (!s || (s->console_type ==GRAPHIC_CONSOLE )) +if (!s ||QEMU_IS_GRAPHIC_CONSOLE (s))return ;switch (keysym) {
@@ -1258,7 +1251,7 @@ static void text_console_invalidate(void *opaque) {QemuConsole *s = (QemuConsole *) opaque; -if (s->console_type ==TEXT_CONSOLE ) { +if (QEMU_IS_TEXT_CONSOLE (s) && !QEMU_IS_FIXED_TEXT_CONSOLE (s)) {text_console_resize (s); }console_refresh (s);
@@ -1294,20 +1287,19 @@ static void text_console_update(void *opaque, console_ch_t *chardata) }static void -qemu_console_register (QemuConsole *c,console_type_t console_type) +qemu_console_register (QemuConsole *c) {int i; -if (!active_console || ((active_console->console_type !=GRAPHIC_CONSOLE ) && - (console_type ==GRAPHIC_CONSOLE ))) { +if (!active_console || (!QEMU_IS_GRAPHIC_CONSOLE (active_console) && +QEMU_IS_GRAPHIC_CONSOLE (c))) { active_console = c; } - c->console_type = console_type;if (QTAILQ_EMPTY (&consoles)) { c->index =0 ;QTAILQ_INSERT_TAIL (&consoles, c, next); - }else if (console_type !=GRAPHIC_CONSOLE ||phase_check (PHASE_MACHINE_READY )) { + }else if (!QEMU_IS_GRAPHIC_CONSOLE (c) ||phase_check (PHASE_MACHINE_READY )) {QemuConsole *last =QTAILQ_LAST (&consoles); c->index = last->index +1 ;QTAILQ_INSERT_TAIL (&consoles, c, next);
@@ -1320,11 +1312,10 @@ qemu_console_register(QemuConsole *c, console_type_t console_type)*/ QemuConsole *it =QTAILQ_FIRST (&consoles); -while (QTAILQ_NEXT (it, next) !=NULL && - it->console_type ==GRAPHIC_CONSOLE ) { +while (QTAILQ_NEXT (it, next) !=NULL &&QEMU_IS_GRAPHIC_CONSOLE (it)) { it =QTAILQ_NEXT (it, next); } -if (it->console_type ==GRAPHIC_CONSOLE ) { +if (QEMU_IS_GRAPHIC_CONSOLE (it)) {/* have no text consoles */ c->index = it->index +1 ;QTAILQ_INSERT_AFTER (&consoles, it, c, next);
@@ -1422,14 +1413,14 @@ qemu_fixed_text_console_init(Object *obj) { } -static QemuConsole *new_console (console_type_t console_type, +static QemuConsole *new_console (const char *typename,uint32_t head) { -QemuConsole *c =QEMU_CONSOLE (object_new (TYPE_QEMU_CONSOLE )); +QemuConsole *c =QEMU_CONSOLE (object_new (typename)); c->head = head;/* TODO: move to console_init() once there is a type hierarchy */ -qemu_console_register (c, console_type); +qemu_console_register (c);return c; }
@@ -2211,7 +2202,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, height =qemu_console_get_height (s,0 ); }else {trace_console_gfx_new (); - s =new_console (GRAPHIC_CONSOLE , head); + s =new_console (TYPE_QEMU_GRAPHIC_CONSOLE , head); s->ui_timer =timer_new_ms (QEMU_CLOCK_REALTIME , dpy_set_ui_info_timer, s); }
@@ -2345,7 +2336,7 @@ bool qemu_console_is_graphic(QemuConsole *con)if (con ==NULL ) { con = active_console; } -return con && (con->console_type ==GRAPHIC_CONSOLE ); +return con &&QEMU_IS_GRAPHIC_CONSOLE (con); }bool qemu_console_is_fixedsize (QemuConsole *con)
@@ -2353,7 +2344,7 @@ bool qemu_console_is_fixedsize(QemuConsole *con)if (con ==NULL ) { con = active_console; } -return con && (con->console_type !=TEXT_CONSOLE ); +return con && (QEMU_IS_GRAPHIC_CONSOLE (con) ||QEMU_IS_FIXED_TEXT_CONSOLE (con)); }bool qemu_console_is_gl_blocked (QemuConsole *con)
@@ -2389,7 +2380,7 @@ bool qemu_console_is_multihead(DeviceState *dev)char *qemu_console_get_label (QemuConsole *con) { -if (con->console_type ==GRAPHIC_CONSOLE ) { +if (QEMU_IS_GRAPHIC_CONSOLE (con)) {if (con->device) {DeviceState *dev;bool multihead;
@@ -2588,9 +2579,9 @@ static void vc_chr_open(Chardev *chr,trace_console_txt_new (width, height);if (width ==0 || height ==0 ) { - s =new_console (TEXT_CONSOLE ,0 ); + s =new_console (TYPE_QEMU_TEXT_CONSOLE ,0 ); }else { - s =new_console (TEXT_CONSOLE_FIXED_SIZE ,0 ); + s =new_console (TYPE_QEMU_FIXED_TEXT_CONSOLE ,0 ); s->scanout.kind =SCANOUT_SURFACE ; s->surface =qemu_create_displaysurface (width, height); }
@@ -2610,7 +2601,7 @@ void qemu_console_resize(QemuConsole *s, int width, int height) {DisplaySurface *surface =qemu_console_surface (s); -assert (s->console_type ==GRAPHIC_CONSOLE ); +assert (QEMU_IS_GRAPHIC_CONSOLE (s)); if ((s->scanout.kind != SCANOUT_SURFACE || (surface && surface->flags & QEMU_ALLOCATED_FLAG)) &&
Signature · 1 line
2.41.0
Re: [PATCH 20/67] ui/console: instantiate a specific console type
Quoted 4 lines · On Wed, Aug 30, 2023 at 01:37:54PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This will allow to move code/data to the specific console types.
Quoted 8 lines
Replace
console_type_twith object type check.QemuConsole can be abstract.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-)
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 :|
PATCH 21/67 ui/console: register the console from qemu_console_init()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
ui/console.c +1 -2
@@ -1366,6 +1366,7 @@ qemu_console_init(Object *obj)qemu_co_queue_init (&c->dump_queue); c->ds = ds; c->window_id =-1 ; +qemu_console_register (c); } static void
@@ -1419,8 +1420,6 @@ static QemuConsole *new_console(const char *typename,QemuConsole *c =QEMU_CONSOLE (object_new (typename)); c->head = head; -/* TODO: move to console_init() once there is a type hierarchy */ -qemu_console_register (c);return c; }
Signature · 1 line
2.41.0
Re: [PATCH 21/67] ui/console: register the console from qemu_console_init()
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:37:55PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
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 :|
PATCH 22/67 ui/console: remove new_console()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The constructor helper isn't of much used now.
"head" is only specified for graphic console (and default to 0), and we are going to move it to QemuGraphicConsole next.
--- ui/console.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
ui/console.c +5 -14
@@ -1414,16 +1414,6 @@ qemu_fixed_text_console_init(Object *obj) { } -static QemuConsole *new_console (const char *typename, -uint32_t head) -{ -QemuConsole *c =QEMU_CONSOLE (object_new (typename)); - - c->head = head; - -return c; -} -#ifdef WIN32 void qemu_displaysurface_win32_set_handle (DisplaySurface *surface,HANDLE h,uint32_t offset)
@@ -2163,7 +2153,7 @@ DisplayState *init_displaystate(void)QemuConsole *con; QTAILQ_FOREACH(con, &consoles, next) { -/* Hook up into the qom tree here (not in new_console()), once +/* Hook up into the qom tree here (not in object_new()), once * all QemuConsoles are created and the order / numbering * doesn't change any more */ name =g_strdup_printf ("console[%d]" , con->index);
@@ -2201,7 +2191,8 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, height =qemu_console_get_height (s,0 ); }else {trace_console_gfx_new (); - s =new_console (TYPE_QEMU_GRAPHIC_CONSOLE , head); + s = (QemuConsole *)object_new (TYPE_QEMU_GRAPHIC_CONSOLE ); + s->head = head; s->ui_timer =timer_new_ms (QEMU_CLOCK_REALTIME , dpy_set_ui_info_timer, s); }
@@ -2578,9 +2569,9 @@ static void vc_chr_open(Chardev *chr,trace_console_txt_new (width, height);if (width ==0 || height ==0 ) { - s =new_console (TYPE_QEMU_TEXT_CONSOLE ,0 ); + s = (QemuConsole *)object_new (TYPE_QEMU_TEXT_CONSOLE ); }else { - s =new_console (TYPE_QEMU_FIXED_TEXT_CONSOLE ,0 ); + s = (QemuConsole *)object_new (TYPE_QEMU_FIXED_TEXT_CONSOLE ); s->scanout.kind =SCANOUT_SURFACE ; s->surface =qemu_create_displaysurface (width, height); }
Signature · 1 line
2.41.0
Re: [PATCH 22/67] ui/console: remove new_console()
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:37:56PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The constructor helper isn't of much used now.
"head" is only specified for graphic console (and default to 0), and we are going to move it to QemuGraphicConsole next.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
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 :|
PATCH 23/67 ui/console: specialize console_lookup_unused()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
graphics_console_init() is expected to return a graphic console.
The function doesn't need to be exported.
We are going to specialize further QemuGraphicConsole & QemuTextConsole. The two will not be interchangeable anymore.
--- include/ui/console.h | 1 - ui/console.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-)
include/ui/console.h +0 -1
@@ -484,7 +484,6 @@ QemuConsole *qemu_console_lookup_by_index(unsigned int index);QemuConsole *qemu_console_lookup_by_device (DeviceState *dev,uint32_t head);QemuConsole *qemu_console_lookup_by_device_name (const char *device_id,uint32_t head,Error **errp); -QemuConsole *qemu_console_lookup_unused (void );QEMUCursor *qemu_console_get_cursor (QemuConsole *con);bool qemu_console_is_visible (QemuConsole *con);bool qemu_console_is_graphic (QemuConsole *con);
ui/console.c +4 -3
@@ -196,6 +196,7 @@ static void text_console_update_cursor(void *opaque);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 gui_update (void *opaque) {
@@ -2184,7 +2185,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,QemuConsole *s;DisplaySurface *surface; - s =qemu_console_lookup_unused (); + s =qemu_graphic_console_lookup_unused ();if (s) {trace_console_gfx_reuse (s->index); width =qemu_console_get_width (s,0 );
@@ -2289,13 +2290,13 @@ QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,return con; } -QemuConsole *qemu_console_lookup_unused (void ) +static QemuConsole *qemu_graphic_console_lookup_unused (void ) {QemuConsole *con;Object *obj; QTAILQ_FOREACH(con, &consoles, next) { -if (con->hw_ops != &unused_ops) { +if (!QEMU_IS_GRAPHIC_CONSOLE (con) || con->hw_ops != &unused_ops) {continue ; } obj = object_property_get_link(OBJECT(con),
Signature · 1 line
2.41.0
Re: [PATCH 23/67] ui/console: specialize console_lookup_unused()
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:37:57PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
graphics_console_init()is expected to return a graphic console.The function doesn't need to be exported.
Quoted 8 lines
We are going to specialize further QemuGraphicConsole & QemuTextConsole. The two will not be interchangeable anymore.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 1 - ui/console.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-)
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 :|
PATCH 24/67 ui/console: update the head from unused QemuConsole
In reply to [email protected]From: Marc-André Lureau <[email protected]>
When recycling unused QemuConsole, we should still set the associated head number for correct information and lookups.
--- ui/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ui/console.c +1 -1
@@ -2193,10 +2193,10 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, }else {trace_console_gfx_new (); s = (QemuConsole *)object_new (TYPE_QEMU_GRAPHIC_CONSOLE ); - s->head = head; 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);if (dev) { object_property_set_link(OBJECT(s), "device", OBJECT(dev),
Signature · 1 line
2.41.0
Re: [PATCH 24/67] ui/console: update the head from unused QemuConsole
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:37:58PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
When recycling unused QemuConsole, we should still set the associated head number for correct information and lookups.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 :|
PATCH 25/67 ui/console: allocate ui_timer in QemuConsole
In reply to [email protected]From: Marc-André Lureau <[email protected]>
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.
--- ui/console.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
ui/console.c +6 -2
@@ -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);
Signature · 1 line
2.41.0
Re: [PATCH 25/67] ui/console: allocate ui_timer in QemuConsole
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:37:59PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Although at this point only QemuGraphicConsole have
hw_opsthat implementsui_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 ifdpy_ui_info_supported()(hw_ops->ui_info!= NULL), which is false fortext_console_ops. This is a bit fragile, let simply allocate and free the timer in the base class.
Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
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 :|
PATCH 26/67 ui/vc: move cursor_timer initialization to QemuTextConsole class
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The timer is only relevant when a text console exists.
--- ui/console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ui/console.c +4 -2
@@ -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; }
Signature · 1 line
2.41.0
Re: [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
Quoted 8 lines · On Wed, Aug 30, 2023 at 01:38:00PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The timer is only relevant when a text console exists.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ui/console.c qemu_text_console_finalize(Object *obj) · line 1405
Quoted 12 lines
ui/console.c +4
-0@@ -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
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 :|
Re: [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
Hi
Quoted 13 lines · Daniel P. Berrangé
Quoted 8 lines · On Wed, Aug 30, 2023 at 01:38:00PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The timer is only relevant when a text console exists.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Quoted 16 lines
ui/console.c qemu_text_console_finalize(Object *obj) · line 1405
Quoted 12 lines
ui/console.c +4
-0@@ -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
Signature · 1 line
Marc-André Lureau
PATCH 27/67 ui/console: free more QemuConsole resources
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This code path is probably not executed at this point, since console aren't being released.
--- ui/console.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
ui/console.c +4 -1
@@ -1337,8 +1337,11 @@ qemu_console_finalize(Object *obj) {QemuConsole *c =QEMU_CONSOLE (obj); +/* TODO: check this code path, and unregister from consoles */ +g_clear_pointer (&c->device, object_unref); +g_clear_pointer (&c->surface, qemu_free_displaysurface); +g_clear_pointer (&c->gl_unblock_timer, timer_free);g_clear_pointer (&c->ui_timer, timer_free); -/* TODO: should unregister from consoles and free itself */ } static void
Signature · 1 line
2.41.0
Re: [PATCH 27/67] ui/console: free more QemuConsole resources
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:38:01PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This code path is probably not executed at this point, since console aren't being released.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
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 :|
PATCH 28/67 ui/vc: move text fields to QemuTextConsole
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Now we can instantiate the specific console with its own fields. Pass the most appropriate type to the various functions, and cast up to QEMU_CONSOLE as necessary.
--- ui/console.c | 177 ++++++++++++++++++++++++++------------------------- 1 file changed, 91 insertions(+), 86 deletions(-)
ui/console.c +91 -86
@@ -94,26 +94,6 @@ struct QemuConsole {const GraphicHwOps *hw_ops;void *hw; -/* Text console state */ -int width; -int height; -int total_height; -int backscroll_height; -int x, y; -int y_displayed; -int y_base; -TextCell *cells; -int text_x[2 ], text_y[2 ], cursor_invalidate; -int echo; - -int update_x0; -int update_y0; -int update_x1; -int update_y1; - -Chardev *chr; -/* fifo for key pressed */ -Fifo8 out_fifo;CoQueue dump_queue;QTAILQ_ENTRY (QemuConsole) next;
@@ -136,6 +116,26 @@ OBJECT_DEFINE_TYPE(QemuGraphicConsole, qemu_graphic_console, QEMU_GRAPHIC_CONSOLtypedef struct QemuTextConsole {QemuConsole parent; + +int width; +int height; +int total_height; +int backscroll_height; +int x, y; +int y_displayed; +int y_base; +TextCell *cells; +int text_x[2 ], text_y[2 ], cursor_invalidate; +int echo; + +int update_x0; +int update_y0; +int update_x1; +int update_y1; + +Chardev *chr; +/* fifo for key pressed */ +Fifo8 out_fifo; }QemuTextConsole ;typedef QemuConsoleClass QemuTextConsoleClass ;
@@ -162,7 +162,7 @@ OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_text_console, QEMU_FIXED_TEXstruct VCChardev {Chardev parent; -QemuConsole *console; +QemuTextConsole *console;enum TTYState state;int esc_params[MAX_ESC_PARAMS ];
@@ -428,43 +428,44 @@ static void vga_putcharxy(QemuConsole *s, int x, int y, int ch, &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT); } -static void text_console_resize (QemuConsole *s) +static void text_console_resize (QemuTextConsole *t) { +QemuConsole *s =QEMU_CONSOLE (t);TextCell *cells, *c, *c1;int w1, x, y, last_width;assert (s->scanout.kind ==SCANOUT_SURFACE ); - last_width = s->width; - s->width =surface_width (s->surface) /FONT_WIDTH ; - s->height =surface_height (s->surface) /FONT_HEIGHT ; + last_width = t->width; + t->width =surface_width (s->surface) /FONT_WIDTH ; + t->height =surface_height (s->surface) /FONT_HEIGHT ; w1 = last_width; -if (s->width < w1) - w1 = s->width; +if (t->width < w1) + w1 = t->width; - cells =g_new (TextCell, s->width * s->total_height +1 ); -for (y =0 ; y < s->total_height; y++) { - c = &cells[y * s->width]; + cells =g_new (TextCell, t->width * t->total_height +1 ); +for (y =0 ; y < t->total_height; y++) { + c = &cells[y * t->width];if (w1 >0 ) { - c1 = &s->cells[y * last_width]; + c1 = &t->cells[y * last_width];for (x =0 ; x < w1; x++) { *c++ = *c1++; } } -for (x = w1; x < s->width; x++) { +for (x = w1; x < t->width; x++) { c->ch =' ' ; c->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; c++; } } -g_free (s->cells); - s->cells = cells; +g_free (t->cells); + t->cells = cells; } -static void invalidate_xy (QemuConsole *s,int x,int y) +static void invalidate_xy (QemuTextConsole *s,int x,int y) { -if (!qemu_console_is_visible (s)) { +if (!qemu_console_is_visible (QEMU_CONSOLE (s))) {return ; }if (s->update_x0 > x *FONT_WIDTH )
@@ -479,7 +480,7 @@ static void invalidate_xy(QemuConsole *s, int x, int y)static void vc_update_xy (VCChardev *vc,int x,int y) { -QemuConsole *s = vc->console; +QemuTextConsole *s = vc->console;TextCell *c;int y1, y2;
@@ -498,13 +499,13 @@ static void vc_update_xy(VCChardev *vc, int x, int y) x = s->width -1 ; } c = &s->cells[y1 * s->width + x]; -vga_putcharxy (s, x, y2, c->ch, +vga_putcharxy (QEMU_CONSOLE (s), x, y2, c->ch, &(c->t_attrib));invalidate_xy (s, x, y2); } } -static void console_show_cursor (QemuConsole *s,int show) +static void console_show_cursor (QemuTextConsole *s,int show) {TextCell *c;int y, y1;
@@ -525,17 +526,17 @@ static void console_show_cursor(QemuConsole *s, int show)if (show && cursor_visible_phase) {TextAttributes t_attrib =TEXT_ATTRIBUTES_DEFAULT ; t_attrib.invers = !(t_attrib.invers);/* invert fg and bg */ -vga_putcharxy (s, x, y, c->ch, &t_attrib); +vga_putcharxy (QEMU_CONSOLE (s), x, y, c->ch, &t_attrib); }else { -vga_putcharxy (s, x, y, c->ch, &(c->t_attrib)); +vga_putcharxy (QEMU_CONSOLE (s), x, y, c->ch, &(c->t_attrib)); }invalidate_xy (s, x, y); } } -static void console_refresh (QemuConsole *s) +static void console_refresh (QemuTextConsole *s) { -DisplaySurface *surface =qemu_console_surface (s); +DisplaySurface *surface =qemu_console_surface (QEMU_CONSOLE (s));TextCell *c;int x, y, y1;
@@ -545,13 +546,13 @@ static void console_refresh(QemuConsole *s) s->text_y[1 ] = s->height -1 ; s->cursor_invalidate =1 ; -vga_fill_rect (s,0 ,0 ,surface_width (surface),surface_height (surface), +vga_fill_rect (QEMU_CONSOLE (s),0 ,0 ,surface_width (surface),surface_height (surface), color_table_rgb[0 ][QEMU_COLOR_BLACK ]); y1 = s->y_displayed;for (y =0 ; y < s->height; y++) { c = s->cells + y1 * s->width;for (x =0 ; x < s->width; x++) { -vga_putcharxy (s, x, y, c->ch, +vga_putcharxy (QEMU_CONSOLE (s), x, y, c->ch, &(c->t_attrib)); c++; }
@@ -560,11 +561,11 @@ static void console_refresh(QemuConsole *s) } }console_show_cursor (s,1 ); -dpy_gfx_update (s,0 ,0 , +dpy_gfx_update (QEMU_CONSOLE (s),0 ,0 ,surface_width (surface),surface_height (surface)); } -static void console_scroll (QemuConsole *s,int ydelta) +static void console_scroll (QemuTextConsole *s,int ydelta) {int i, y1;
@@ -595,7 +596,7 @@ static void console_scroll(QemuConsole *s, int ydelta)static void vc_put_lf (VCChardev *vc) { -QemuConsole *s = vc->console; +QemuTextConsole *s = vc->console;TextCell *c;int x, y1;
@@ -624,10 +625,10 @@ static void vc_put_lf(VCChardev *vc) s->text_x[1 ] = s->width -1 ; s->text_y[1 ] = s->height -1 ; -vga_bitblt (s,0 ,FONT_HEIGHT ,0 ,0 , +vga_bitblt (QEMU_CONSOLE (s),0 ,FONT_HEIGHT ,0 ,0 , s->width *FONT_WIDTH , (s->height -1 ) *FONT_HEIGHT ); -vga_fill_rect (s,0 , (s->height -1 ) *FONT_HEIGHT , +vga_fill_rect (QEMU_CONSOLE (s),0 , (s->height -1 ) *FONT_HEIGHT , s->width *FONT_WIDTH ,FONT_HEIGHT , color_table_rgb[0 ][TEXT_ATTRIBUTES_DEFAULT .bgcol]); s->update_x0 =0 ;
@@ -737,7 +738,7 @@ static void vc_handle_escape(VCChardev *vc)static void vc_clear_xy (VCChardev *vc,int x,int y) { -QemuConsole *s = vc->console; +QemuTextConsole *s = vc->console;int y1 = (s->y_base + y) % s->total_height;if (x >= s->width) { x = s->width -1 ;
@@ -750,7 +751,7 @@ static void vc_clear_xy(VCChardev *vc, int x, int y)static void vc_put_one (VCChardev *vc,int ch) { -QemuConsole *s = vc->console; +QemuTextConsole *s = vc->console;TextCell *c;int y1;if (s->x >= s->width) {
@@ -777,7 +778,7 @@ static void vc_respond_str(VCChardev *vc, const char *buf)/* set cursor, checking bounds */ static void vc_set_cursor (VCChardev *vc,int x,int y) { -QemuConsole *s = vc->console; +QemuTextConsole *s = vc->console;if (x <0 ) { x =0 ;
@@ -798,7 +799,7 @@ static void vc_set_cursor(VCChardev *vc, int x, int y)static void vc_putchar (VCChardev *vc,int ch) { -QemuConsole *s = vc->console; +QemuTextConsole *s = vc->console;int i;int x, y;char response[40 ];
@@ -1095,8 +1096,11 @@ void console_select(unsigned int index) }displaychangelistener_display_console (dcl, s,NULL ); } -dpy_text_resize (s, s->width, s->height); -text_console_update_cursor (NULL ); + +if (QEMU_IS_TEXT_CONSOLE (s)) { +dpy_text_resize (s,QEMU_TEXT_CONSOLE (s)->width,QEMU_TEXT_CONSOLE (s)->height); +text_console_update_cursor (NULL ); + } } }
@@ -1107,7 +1111,7 @@ DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV,static int vc_chr_write (Chardev *chr,const uint8_t *buf,int len) {VCChardev *drv =VC_CHARDEV (chr); -QemuConsole *s = drv->console; +QemuTextConsole *s = drv->console;int i; s->update_x0 = s->width *FONT_WIDTH ;
@@ -1120,14 +1124,14 @@ static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len) }console_show_cursor (s,1 );if (s->update_x0 < s->update_x1) { -dpy_gfx_update (s, s->update_x0, s->update_y0, +dpy_gfx_update (QEMU_CONSOLE (s), s->update_x0, s->update_y0, s->update_x1 - s->update_x0, s->update_y1 - s->update_y0); }return len; } -static void kbd_send_chars (QemuConsole *s) +static void kbd_send_chars (QemuTextConsole *s) {uint32_t len, avail;
@@ -1145,13 +1149,14 @@ static void kbd_send_chars(QemuConsole *s) }/* called when an ascii key is pressed */ -void kbd_put_keysym_console (QemuConsole *s,int keysym) +void kbd_put_keysym_console (QemuConsole *con,int keysym) { +QemuTextConsole *s = (QemuTextConsole *)object_dynamic_cast (OBJECT (con),TYPE_QEMU_TEXT_CONSOLE );uint8_t buf[16 ], *q;int c;uint32_t num_free; -if (!s ||QEMU_IS_GRAPHIC_CONSOLE (s)) +if (!s)return ;switch (keysym) {
@@ -1251,17 +1256,17 @@ void kbd_put_keysym(int keysym)static void text_console_invalidate (void *opaque) { -QemuConsole *s = (QemuConsole *) opaque; +QemuTextConsole *s =QEMU_TEXT_CONSOLE (opaque); -if (QEMU_IS_TEXT_CONSOLE (s) && !QEMU_IS_FIXED_TEXT_CONSOLE (s)) { -text_console_resize (s); +if (!QEMU_IS_FIXED_TEXT_CONSOLE (s)) { +text_console_resize (QEMU_TEXT_CONSOLE (s)); }console_refresh (s); }static void text_console_update (void *opaque,console_ch_t *chardata) { -QemuConsole *s = (QemuConsole *) opaque; +QemuTextConsole *s =QEMU_TEXT_CONSOLE (opaque);int i, j, src;if (s->text_x[0 ] <= s->text_x[1 ]) {
@@ -1275,7 +1280,7 @@ static void text_console_update(void *opaque, console_ch_t *chardata) s->cells[src].t_attrib.bgcol, s->cells[src].t_attrib.bold)); } -dpy_text_update (s, s->text_x[0 ], s->text_y[0 ], +dpy_text_update (QEMU_CONSOLE (s), s->text_x[0 ], s->text_y[0 ], s->text_x[1 ] - s->text_x[0 ], i - s->text_y[0 ]); s->text_x[0 ] = s->width; s->text_y[0 ] = s->height;
@@ -1283,7 +1288,7 @@ static void text_console_update(void *opaque, console_ch_t *chardata) s->text_y[1 ] =0 ; }if (s->cursor_invalidate) { -dpy_text_cursor (s, s->x, s->y); +dpy_text_cursor (QEMU_CONSOLE (s), s->x, s->y); s->cursor_invalidate =0 ; } }
@@ -2399,12 +2404,14 @@ char *qemu_console_get_label(QemuConsole *con) } }return g_strdup ("VGA" ); - }else { -if (con->chr && con->chr->label) { -return g_strdup (con->chr->label); + }else if (QEMU_IS_TEXT_CONSOLE (con)) { +QemuTextConsole *c =QEMU_TEXT_CONSOLE (con); +if (c->chr && c->chr->label) { +return g_strdup (c->chr->label); } -return g_strdup_printf ("vc%d" , con->index); } + +return g_strdup_printf ("vc%d" , con->index); }int qemu_console_get_index (QemuConsole *con)
@@ -2466,17 +2473,15 @@ int qemu_console_get_height(QemuConsole *con, int fallback)static void vc_chr_accept_input (Chardev *chr) {VCChardev *drv =VC_CHARDEV (chr); -QemuConsole *s = drv->console; -kbd_send_chars (s); +kbd_send_chars (drv->console); }static void vc_chr_set_echo (Chardev *chr,bool echo) {VCChardev *drv =VC_CHARDEV (chr); -QemuConsole *s = drv->console; - s->echo = echo; + drv->console->echo = echo; }static void text_console_update_cursor_timer (void )
@@ -2514,7 +2519,7 @@ static const GraphicHwOps text_console_ops = {static void text_console_do_init (Chardev *chr) {VCChardev *drv =VC_CHARDEV (chr); -QemuConsole *s = drv->console; +QemuTextConsole *s = drv->console;int g_width =80 *FONT_WIDTH ;int g_height =24 *FONT_HEIGHT ;
@@ -2525,17 +2530,17 @@ static void text_console_do_init(Chardev *chr) s->total_height =DEFAULT_BACKSCROLL ; s->x =0 ; s->y =0 ; -if (s->scanout.kind !=SCANOUT_SURFACE ) { +if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) {if (active_console && active_console->scanout.kind ==SCANOUT_SURFACE ) { g_width =qemu_console_get_width (active_console, g_width); g_height =qemu_console_get_height (active_console, g_height); } - s->surface =qemu_create_displaysurface (g_width, g_height); - s->scanout.kind =SCANOUT_SURFACE ; +QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (g_width, g_height); +QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; } - s->hw_ops = &text_console_ops; - s->hw = s; +QEMU_CONSOLE (s)->hw_ops = &text_console_ops; +QEMU_CONSOLE (s)->hw = s;/* set current text attributes to default */ drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;
@@ -2561,7 +2566,7 @@ static void vc_chr_open(Chardev *chr, {ChardevVC *vc = backend->u.vc.data;VCChardev *drv =VC_CHARDEV (chr); -QemuConsole *s; +QemuTextConsole *s;unsigned width =0 ;unsigned height =0 ;
@@ -2579,11 +2584,11 @@ static void vc_chr_open(Chardev *chr,trace_console_txt_new (width, height);if (width ==0 || height ==0 ) { - s = (QemuConsole *)object_new (TYPE_QEMU_TEXT_CONSOLE ); + s =QEMU_TEXT_CONSOLE (object_new (TYPE_QEMU_TEXT_CONSOLE )); }else { - s = (QemuConsole *)object_new (TYPE_QEMU_FIXED_TEXT_CONSOLE ); - s->scanout.kind =SCANOUT_SURFACE ; - s->surface =qemu_create_displaysurface (width, height); + s =QEMU_TEXT_CONSOLE (object_new (TYPE_QEMU_FIXED_TEXT_CONSOLE )); +QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; +QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (width, height); } s->chr = chr;
Signature · 1 line
2.41.0
Re: [PATCH 28/67] ui/vc: move text fields to QemuTextConsole
Quoted 10 lines · On Wed, Aug 30, 2023 at 01:38:02PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Now we can instantiate the specific console with its own fields. Pass the most appropriate type to the various functions, and cast up to
QEMU_CONSOLEas necessary.Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 177 ++++++++++++++++++++++++++------------------------- 1 file changed, 91 insertions(+), 86 deletions(-)
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 :|
PATCH 29/67 ui/console: move graphic fields to QemuGraphicConsole
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Move fields specific to graphic console to the console subclass.
qemu_console_get_head() is adapated to accomodate QemuTextConsole, and always returns 0.
--- ui/console.c | 110 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 46 deletions(-)
ui/console.c +64 -46
@@ -83,17 +83,10 @@ struct QemuConsole {int gl_block;QEMUTimer *gl_unblock_timer;int window_id; - -/* Graphic console state. */ -Object *device; -uint32_t head;QemuUIInfo ui_info;QEMUTimer *ui_timer; -QEMUCursor *cursor; -int cursor_x, cursor_y, cursor_on;const GraphicHwOps *hw_ops;void *hw; -CoQueue dump_queue;QTAILQ_ENTRY (QemuConsole) next;
@@ -103,6 +96,12 @@ OBJECT_DEFINE_ABSTRACT_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJECT)typedef struct QemuGraphicConsole {QemuConsole parent; + +Object *device; +uint32_t head; + +QEMUCursor *cursor; +int cursor_x, cursor_y, cursor_on; }QemuGraphicConsole ;typedef QemuConsoleClass QemuGraphicConsoleClass ;
@@ -1343,31 +1342,14 @@ qemu_console_finalize(Object *obj)QemuConsole *c =QEMU_CONSOLE (obj);/* TODO: check this code path, and unregister from consoles */ -g_clear_pointer (&c->device, object_unref);g_clear_pointer (&c->surface, qemu_free_displaysurface);g_clear_pointer (&c->gl_unblock_timer, timer_free);g_clear_pointer (&c->ui_timer, timer_free); } -static void -qemu_console_prop_get_head (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -QemuConsole *c =QEMU_CONSOLE (obj); - -visit_type_uint32 (v, name, &c->head, errp); -} -static void qemu_console_class_init (ObjectClass *oc,void *data) { -object_class_property_add_link (oc,"device" ,TYPE_DEVICE , - offsetof(QemuConsole , device), - object_property_allow_set_link, -OBJ_PROP_LINK_STRONG ); -object_class_property_add (oc,"head" ,"uint32" , - qemu_console_prop_get_head, -NULL ,NULL ,NULL ); } static void
@@ -1387,11 +1369,30 @@ qemu_console_init(Object *obj)static void qemu_graphic_console_finalize (Object *obj) { +QemuGraphicConsole *c =QEMU_GRAPHIC_CONSOLE (obj); + +g_clear_pointer (&c->device, object_unref); +} + +static void +qemu_graphic_console_prop_get_head (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +QemuGraphicConsole *c =QEMU_GRAPHIC_CONSOLE (obj); + +visit_type_uint32 (v, name, &c->head, errp); }static void qemu_graphic_console_class_init (ObjectClass *oc,void *data) { +object_class_property_add_link (oc,"device" ,TYPE_DEVICE , + offsetof(QemuGraphicConsole , device), + object_property_allow_set_link, +OBJ_PROP_LINK_STRONG ); +object_class_property_add (oc,"head" ,"uint32" , + qemu_graphic_console_prop_get_head, +NULL ,NULL ,NULL ); } static void
@@ -1676,6 +1677,16 @@ void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *gl) con->gl = gl; } +static void +dcl_set_graphic_cursor (DisplayChangeListener *dcl,QemuGraphicConsole *con) +{ +if (con && con->cursor && dcl->ops->dpy_cursor_define) { + dcl->ops->dpy_cursor_define (dcl, con->cursor); + } +if (con && dcl->ops->dpy_mouse_set) { + dcl->ops->dpy_mouse_set (dcl, con->cursor_x, con->cursor_y, con->cursor_on); + } +}void register_displaychangelistener (DisplayChangeListener *dcl) {QemuConsole *con;
@@ -1693,11 +1704,8 @@ void register_displaychangelistener(DisplayChangeListener *dcl) con = active_console; }displaychangelistener_display_console (dcl, con, dcl->con ? &error_fatal :NULL ); -if (con && con->cursor && dcl->ops->dpy_cursor_define) { - dcl->ops->dpy_cursor_define (dcl, con->cursor); - } -if (con && dcl->ops->dpy_mouse_set) { - dcl->ops->dpy_mouse_set (dcl, con->cursor_x, con->cursor_y, con->cursor_on); +if (QEMU_IS_GRAPHIC_CONSOLE (con)) { +dcl_set_graphic_cursor (dcl,QEMU_GRAPHIC_CONSOLE (con)); }text_console_update_cursor (NULL ); }
@@ -1728,8 +1736,9 @@ void unregister_displaychangelistener(DisplayChangeListener *dcl)static void dpy_set_ui_info_timer (void *opaque) {QemuConsole *con = opaque; +uint32_t head =qemu_console_get_head (con); - con->hw_ops->ui_info (con->hw, con->head, &con->ui_info); + con->hw_ops->ui_info (con->hw, head, &con->ui_info); }bool dpy_ui_info_supported (QemuConsole *con)
@@ -1939,19 +1948,20 @@ void dpy_text_resize(QemuConsole *con, int w, int h) } } -void dpy_mouse_set (QemuConsole *con,int x,int y,int on) +void dpy_mouse_set (QemuConsole *c,int x,int y,int on) { -DisplayState *s = con->ds; +QemuGraphicConsole *con =QEMU_GRAPHIC_CONSOLE (c); +DisplayState *s = c->ds;DisplayChangeListener *dcl; con->cursor_x = x; con->cursor_y = y; con->cursor_on = on; -if (!qemu_console_is_visible (con)) { +if (!qemu_console_is_visible (c)) {return ; } QLIST_FOREACH(dcl, &s->listeners, next) { -if (con != (dcl->con ? dcl->con : active_console)) { +if (c != (dcl->con ? dcl->con : active_console)) {continue ; }if (dcl->ops->dpy_mouse_set) {
@@ -1960,18 +1970,19 @@ void dpy_mouse_set(QemuConsole *con, int x, int y, int on) } } -void dpy_cursor_define (QemuConsole *con,QEMUCursor *cursor) +void dpy_cursor_define (QemuConsole *c,QEMUCursor *cursor) { -DisplayState *s = con->ds; +QemuGraphicConsole *con =QEMU_GRAPHIC_CONSOLE (c); +DisplayState *s = c->ds;DisplayChangeListener *dcl;cursor_unref (con->cursor); con->cursor =cursor_ref (cursor); -if (!qemu_console_is_visible (con)) { +if (!qemu_console_is_visible (c)) {return ; } QLIST_FOREACH(dcl, &s->listeners, next) { -if (con != (dcl->con ? dcl->con : active_console)) { +if (c != (dcl->con ? dcl->con : active_console)) {continue ; }if (dcl->ops->dpy_cursor_define) {
@@ -2210,7 +2221,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,trace_console_gfx_new (); s = (QemuConsole *)object_new (TYPE_QEMU_GRAPHIC_CONSOLE ); } - s->head = head; +QEMU_GRAPHIC_CONSOLE (s)->head = head;graphic_console_set_hwops (s, hw_ops, opaque);if (dev) { object_property_set_link(OBJECT(s), "device", OBJECT(dev),
@@ -2328,7 +2339,7 @@ QEMUCursor *qemu_console_get_cursor(QemuConsole *con)if (con ==NULL ) { con = active_console; } -return con ? con->cursor :NULL ; +return QEMU_IS_GRAPHIC_CONSOLE (con) ?QEMU_GRAPHIC_CONSOLE (con)->cursor :NULL ; }bool qemu_console_is_visible (QemuConsole *con)
@@ -2386,21 +2397,22 @@ bool qemu_console_is_multihead(DeviceState *dev)char *qemu_console_get_label (QemuConsole *con) {if (QEMU_IS_GRAPHIC_CONSOLE (con)) { -if (con->device) { +QemuGraphicConsole *c =QEMU_GRAPHIC_CONSOLE (con); +if (c->device) {DeviceState *dev;bool multihead; - dev =DEVICE (con->device); + dev =DEVICE (c->device); multihead =qemu_console_is_multihead (dev);if (multihead) {return g_strdup_printf ("%s.%d" , dev->id ? dev->id : -object_get_typename (con->device), - con->head); +object_get_typename (c->device), + c->head); }else {return g_strdup_printf ("%s" , dev->id ? dev->id : -object_get_typename (con->device)); +object_get_typename (c->device)); } }return g_strdup ("VGA" );
@@ -2427,7 +2439,13 @@ uint32_t qemu_console_get_head(QemuConsole *con)if (con ==NULL ) { con = active_console; } -return con ? con->head :-1 ; +if (con ==NULL ) { +return -1 ; + } +if (QEMU_IS_GRAPHIC_CONSOLE (con)) { +return QEMU_GRAPHIC_CONSOLE (con)->head; + } +return 0 ; }int qemu_console_get_width (QemuConsole *con,int fallback)
Signature · 1 line
2.41.0
Re: [PATCH 29/67] ui/console: move graphic fields to QemuGraphicConsole
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:38:03PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Move fields specific to graphic console to the console subclass.
qemu_console_get_head()is adapated to accomodate QemuTextConsole, and always returns 0.Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 110 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 46 deletions(-)
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 :|
PATCH 30/67 ui/vc: fold text_console_do_init() in vc_chr_open()
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 80 ++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 49 deletions(-)
ui/console.c +31 -49
@@ -187,7 +187,6 @@ static QTAILQ_HEAD(, QemuConsole) consoles =static bool cursor_visible_phase;static QEMUTimer *cursor_timer; -static void text_console_do_init (Chardev *chr);static void dpy_refresh (DisplayState *s);static DisplayState *get_alloc_displaystate (void );static void text_console_update_cursor_timer (void );
@@ -2534,49 +2533,6 @@ static const GraphicHwOps text_console_ops = { .text_update = text_console_update, }; -static void text_console_do_init (Chardev *chr) -{ -VCChardev *drv =VC_CHARDEV (chr); -QemuTextConsole *s = drv->console; -int g_width =80 *FONT_WIDTH ; -int g_height =24 *FONT_HEIGHT ; - -fifo8_create (&s->out_fifo,16 ); - - s->y_displayed =0 ; - s->y_base =0 ; - s->total_height =DEFAULT_BACKSCROLL ; - s->x =0 ; - s->y =0 ; -if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) { -if (active_console && active_console->scanout.kind ==SCANOUT_SURFACE ) { - g_width =qemu_console_get_width (active_console, g_width); - g_height =qemu_console_get_height (active_console, g_height); - } -QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (g_width, g_height); -QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; - } - -QEMU_CONSOLE (s)->hw_ops = &text_console_ops; -QEMU_CONSOLE (s)->hw = s; - -/* set current text attributes to default */ - drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; -text_console_resize (s); - -if (chr->label) { -char *msg; - - drv->t_attrib.bgcol =QEMU_COLOR_BLUE ; - msg =g_strdup_printf ("%s console\r\n" , chr->label); -qemu_chr_write (chr, (uint8_t *)msg,strlen (msg), true); -g_free (msg); - drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; - } - -qemu_chr_be_event (chr,CHR_EVENT_OPENED ); -} - static void vc_chr_open(Chardev *chr, ChardevBackend *backend, bool *be_opened,
@@ -2587,6 +2543,8 @@ static void vc_chr_open(Chardev *chr,QemuTextConsole *s;unsigned width =0 ;unsigned height =0 ; +int g_width =80 *FONT_WIDTH ; +int g_height =24 *FONT_HEIGHT ;if (vc->has_width) { width = vc->width;
@@ -2612,12 +2570,36 @@ static void vc_chr_open(Chardev *chr, s->chr = chr; drv->console = s; -text_console_do_init (chr); +fifo8_create (&s->out_fifo,16 ); -/* console/chardev init sometimes completes elsewhere in a 2nd -* stage, so defer OPENED events until they are fully initialized -*/ - *be_opened = false; + s->total_height =DEFAULT_BACKSCROLL ; +if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) { +if (active_console && active_console->scanout.kind ==SCANOUT_SURFACE ) { + g_width =qemu_console_get_width (active_console, g_width); + g_height =qemu_console_get_height (active_console, g_height); + } +QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (g_width, g_height); +QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; + } + +QEMU_CONSOLE (s)->hw_ops = &text_console_ops; +QEMU_CONSOLE (s)->hw = s; + +/* set current text attributes to default */ + drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; +text_console_resize (s); + +if (chr->label) { +char *msg; + + drv->t_attrib.bgcol =QEMU_COLOR_BLUE ; + msg =g_strdup_printf ("%s console\r\n" , chr->label); +qemu_chr_write (chr, (uint8_t *)msg,strlen (msg), true); +g_free (msg); + drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; + } + + *be_opened = true; }void qemu_console_resize (QemuConsole *s,int width,int height)
Signature · 1 line
2.41.0
Re: [PATCH 30/67] ui/vc: fold text_console_do_init() in vc_chr_open()
Quoted 20 lines · On Wed, Aug 30, 2023 at 01:38:04PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 80 ++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 49 deletions(-)ui/console.c +3
-5@@ -2612,12 +2570,36 @@ static void vc_chr_open(Chardev *chr, s->chr = chr; drv->console = s; -text_console_do_init (chr); +fifo8_create (&s->out_fifo,16 ); -/* console/chardev init sometimes completes elsewhere in a 2nd -* stage, so defer OPENED events until they are fully initialized -*/ - *be_opened = false; + s->total_height =DEFAULT_BACKSCROLL ; +if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) {
ui/console.c static void vc_chr_open(Chardev *chr, · line 2586
Quoted 10 lines
ui/console.c +10
-0+if (active_console && active_console->scanout.kind ==SCANOUT_SURFACE ) { + g_width =qemu_console_get_width (active_console, g_width); + g_height =qemu_console_get_height (active_console, g_height); + } +QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (g_width, g_height); +QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; + } + +QEMU_CONSOLE (s)->hw_ops = &text_console_ops; +QEMU_CONSOLE (s)->hw = s;
It feels like it would be worth having a local variable
"QemuConsole *c = QEMU_CONSOLE(s)"
to replace the many repeated casts.
Appreciate you merely moved existing code though, so either way
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 :|
PATCH 31/67 ui/vc: move some text console initialization to qom handlers
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
ui/console.c +11 -11
@@ -1413,9 +1413,20 @@ qemu_text_console_class_init(ObjectClass *oc, void *data) } } +static const GraphicHwOps text_console_ops = { + .invalidate = text_console_invalidate, + .text_update = text_console_update, +}; +static void qemu_text_console_init (Object *obj) { +QemuTextConsole *c =QEMU_TEXT_CONSOLE (obj); + +fifo8_create (&c->out_fifo,16 ); + c->total_height =DEFAULT_BACKSCROLL ; +QEMU_CONSOLE (c)->hw_ops = &text_console_ops; +QEMU_CONSOLE (c)->hw = c; } static void
@@ -2528,11 +2539,6 @@ static void text_console_update_cursor(void *opaque) } } -static const GraphicHwOps text_console_ops = { - .invalidate = text_console_invalidate, - .text_update = text_console_update, -}; - static void vc_chr_open(Chardev *chr, ChardevBackend *backend, bool *be_opened,
@@ -2570,9 +2576,6 @@ static void vc_chr_open(Chardev *chr, s->chr = chr; drv->console = s; -fifo8_create (&s->out_fifo,16 ); - - s->total_height =DEFAULT_BACKSCROLL ;if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) {if (active_console && active_console->scanout.kind ==SCANOUT_SURFACE ) { g_width =qemu_console_get_width (active_console, g_width);
@@ -2582,9 +2585,6 @@ static void vc_chr_open(Chardev *chr,QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; } -QEMU_CONSOLE (s)->hw_ops = &text_console_ops; -QEMU_CONSOLE (s)->hw = s; -/* set current text attributes to default */ drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;text_console_resize (s);
Signature · 1 line
2.41.0
Re: [PATCH 31/67] ui/vc: move some text console initialization to qom handlers
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:38:05PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
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 :|
PATCH 32/67 ui/console: simplify getting active_console size
In reply to [email protected]From: Marc-André Lureau <[email protected]>
We can get the active console dimension regardless of its kind, by simply giving NULL as argument. It will fallback with the given value when the dimensions aren't known.
This will also allow to move the code in a separate unit more easily.
--- ui/console.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
ui/console.c +2 -4
@@ -2577,10 +2577,8 @@ static void vc_chr_open(Chardev *chr, drv->console = s;if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) { -if (active_console && active_console->scanout.kind ==SCANOUT_SURFACE ) { - g_width =qemu_console_get_width (active_console, g_width); - g_height =qemu_console_get_height (active_console, g_height); - } + g_width =qemu_console_get_width (NULL , g_width); + g_height =qemu_console_get_height (NULL , g_height);QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (g_width, g_height);QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; }
Signature · 1 line
2.41.0
Re: [PATCH 32/67] ui/console: simplify getting active_console size
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:38:06PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
We can get the active console dimension regardless of its kind, by simply giving NULL as argument. It will fallback with the given value when the dimensions aren't known.
Quoted 6 lines
This will also allow to move the code in a separate unit more easily.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
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 :|
PATCH 33/67 ui/console: remove need for g_width/g_height
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
ui/console.c +3 -5
@@ -2549,8 +2549,6 @@ static void vc_chr_open(Chardev *chr,QemuTextConsole *s;unsigned width =0 ;unsigned height =0 ; -int g_width =80 *FONT_WIDTH ; -int g_height =24 *FONT_HEIGHT ;if (vc->has_width) { width = vc->width;
@@ -2567,6 +2565,8 @@ static void vc_chr_open(Chardev *chr,trace_console_txt_new (width, height);if (width ==0 || height ==0 ) { s =QEMU_TEXT_CONSOLE (object_new (TYPE_QEMU_TEXT_CONSOLE )); + width =qemu_console_get_width (NULL ,80 *FONT_WIDTH ); + height =qemu_console_get_height (NULL ,24 *FONT_HEIGHT ); }else { s =QEMU_TEXT_CONSOLE (object_new (TYPE_QEMU_FIXED_TEXT_CONSOLE ));QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ;
@@ -2577,9 +2577,7 @@ static void vc_chr_open(Chardev *chr, drv->console = s;if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) { - g_width =qemu_console_get_width (NULL , g_width); - g_height =qemu_console_get_height (NULL , g_height); -QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (g_width, g_height); +QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (width, height);QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; }
Signature · 1 line
2.41.0
Re: [PATCH 33/67] ui/console: remove need for g_width/g_height
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:38:07PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
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 :|
PATCH 34/67 ui/vc: use common text console surface creation
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
ui/console.c +2 -7
@@ -2569,18 +2569,13 @@ static void vc_chr_open(Chardev *chr, height =qemu_console_get_height (NULL ,24 *FONT_HEIGHT ); }else { s =QEMU_TEXT_CONSOLE (object_new (TYPE_QEMU_FIXED_TEXT_CONSOLE )); -QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; -QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (width, height); } +dpy_gfx_replace_surface (QEMU_CONSOLE (s),qemu_create_displaysurface (width, height)); + s->chr = chr; drv->console = s; -if (QEMU_CONSOLE (s)->scanout.kind !=SCANOUT_SURFACE ) { -QEMU_CONSOLE (s)->surface =qemu_create_displaysurface (width, height); -QEMU_CONSOLE (s)->scanout.kind =SCANOUT_SURFACE ; - } -/* set current text attributes to default */ drv->t_attrib =TEXT_ATTRIBUTES_DEFAULT ;text_console_resize (s);
Signature · 1 line
2.41.0
Re: [PATCH 34/67] ui/vc: use common text console surface creation
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:38:08PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
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 :|
PATCH 35/67 ui/console: declare console types in console.h
In reply to [email protected]From: Marc-André Lureau <[email protected]>
We are going to split the console.c unit next, and implement separately. But we need to check the underlying type in various places.
--- include/ui/console.h | 25 +++++++++++++++++++++---- ui/console.c | 15 --------------- 2 files changed, 21 insertions(+), 19 deletions(-)
include/ui/console.h +21 -4
@@ -12,6 +12,27 @@# include "ui/shader.h" #endif +#define TYPE_QEMU_CONSOLE "qemu-console" +OBJECT_DECLARE_TYPE(QemuConsole, QemuConsoleClass, QEMU_CONSOLE) + +#define TYPE_QEMU_GRAPHIC_CONSOLE "qemu-graphic-console" +OBJECT_DECLARE_SIMPLE_TYPE(QemuGraphicConsole, QEMU_GRAPHIC_CONSOLE) + +#define TYPE_QEMU_TEXT_CONSOLE "qemu-text-console" +OBJECT_DECLARE_SIMPLE_TYPE(QemuTextConsole, QEMU_TEXT_CONSOLE) + +#define TYPE_QEMU_FIXED_TEXT_CONSOLE "qemu-fixed-text-console" +OBJECT_DECLARE_SIMPLE_TYPE(QemuFixedTextConsole, QEMU_FIXED_TEXT_CONSOLE) + +#define QEMU_IS_GRAPHIC_CONSOLE (c) \ + object_dynamic_cast(OBJECT(c), TYPE_QEMU_GRAPHIC_CONSOLE) + +#define QEMU_IS_TEXT_CONSOLE (c) \ + object_dynamic_cast(OBJECT(c), TYPE_QEMU_TEXT_CONSOLE) + +#define QEMU_IS_FIXED_TEXT_CONSOLE (c) \ + object_dynamic_cast(OBJECT(c), TYPE_QEMU_FIXED_TEXT_CONSOLE) +/* keyboard/mouse support */ #define MOUSE_EVENT_LBUTTON 0x01
@@ -112,10 +133,6 @@ void console_handle_touch_event(QemuConsole *con, Error **errp);/* consoles */ -#define TYPE_QEMU_CONSOLE "qemu-console" -OBJECT_DECLARE_TYPE(QemuConsole, QemuConsoleClass, QEMU_CONSOLE) - -struct QemuConsoleClass {ObjectClass parent_class; };
ui/console.c +0 -15
@@ -106,13 +106,8 @@ typedef struct QemuGraphicConsole {typedef QemuConsoleClass QemuGraphicConsoleClass ; -#define TYPE_QEMU_GRAPHIC_CONSOLE "qemu-graphic-console" -OBJECT_DECLARE_SIMPLE_TYPE(QemuGraphicConsole, QEMU_GRAPHIC_CONSOLE) OBJECT_DEFINE_TYPE(QemuGraphicConsole, qemu_graphic_console, QEMU_GRAPHIC_CONSOLE, QEMU_CONSOLE) -#define QEMU_IS_GRAPHIC_CONSOLE (c) \ - object_dynamic_cast(OBJECT(c), TYPE_QEMU_GRAPHIC_CONSOLE) - typedef struct QemuTextConsole { QemuConsole parent;
@@ -139,26 +134,16 @@ typedef struct QemuTextConsole {typedef QemuConsoleClass QemuTextConsoleClass ; -#define TYPE_QEMU_TEXT_CONSOLE "qemu-text-console" -OBJECT_DECLARE_SIMPLE_TYPE(QemuTextConsole, QEMU_TEXT_CONSOLE) OBJECT_DEFINE_TYPE(QemuTextConsole, qemu_text_console, QEMU_TEXT_CONSOLE, QEMU_CONSOLE) -#define QEMU_IS_TEXT_CONSOLE (c) \ - object_dynamic_cast(OBJECT(c), TYPE_QEMU_TEXT_CONSOLE) -typedef struct QemuFixedTextConsole {QemuTextConsole parent; }QemuFixedTextConsole ;typedef QemuTextConsoleClass QemuFixedTextConsoleClass ; -#define TYPE_QEMU_FIXED_TEXT_CONSOLE "qemu-fixed-text-console" -OBJECT_DECLARE_SIMPLE_TYPE(QemuFixedTextConsole, QEMU_FIXED_TEXT_CONSOLE) OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_text_console, QEMU_FIXED_TEXT_CONSOLE, QEMU_TEXT_CONSOLE) -#define QEMU_IS_FIXED_TEXT_CONSOLE (c) \ - object_dynamic_cast(OBJECT(c), TYPE_QEMU_FIXED_TEXT_CONSOLE) -struct VCChardev {Chardev parent;QemuTextConsole *console;
Signature · 1 line
2.41.0
Re: [PATCH 35/67] ui/console: declare console types in console.h
Quoted 10 lines · On Wed, Aug 30, 2023 at 01:38:09PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
We are going to split the
console.cunit next, and implement separately. But we need to check the underlying type in various places.Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 25 +++++++++++++++++++++---- ui/console.c | 15 --------------- 2 files changed, 21 insertions(+), 19 deletions(-)
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 :|
PATCH 36/67 ui/console: use QEMU_PIXMAN_COLOR helpers
In reply to [email protected]From: Marc-André Lureau <[email protected]>
QEMU_RGB macro is actually defining a pixman color. Make this explicit in the macro name. Move it to qemu-pixman.h so it can be used elsewhere, as done in the following patch. Finally, define QEMU_PIXMAN_COLOR_{BLACK,GRAY}, to avoid need to look up the VGA color table from the QemuConsole placeholder surface rendering.
--- include/ui/qemu-pixman.h | 6 ++++++ ui/console.c | 39 ++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-)
include/ui/qemu-pixman.h +6 -0
@@ -47,6 +47,12 @@# define PIXMAN_LE_x8r8g8b8 PIXMAN_x8r8g8b8#endif +#define QEMU_PIXMAN_COLOR (r, g, b) \ + { .red = r << 8, .green = g << 8, .blue = b << 8, .alpha = 0xffff } + +#define QEMU_PIXMAN_COLOR_BLACK QEMU_PIXMAN_COLOR(0x00, 0x00, 0x00) +#define QEMU_PIXMAN_COLOR_GRAY QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0xaa) +/* -------------------------------------------------------------------- */ typedef struct PixelFormat {
ui/console.c +18 -21
@@ -363,29 +363,26 @@ static void vga_bitblt(QemuConsole *con,#include "vgafont.h" -#define QEMU_RGB (r, g, b) \ - { .red = r << 8, .green = g << 8, .blue = b << 8, .alpha = 0xffff } -static const pixman_color_t color_table_rgb[2 ][8 ] = { {/* dark */ - [QEMU_COLOR_BLACK ] =QEMU_RGB (0x00 ,0x00 ,0x00 ),/* black */ - [QEMU_COLOR_BLUE ] =QEMU_RGB (0x00 ,0x00 ,0xaa ),/* blue */ - [QEMU_COLOR_GREEN ] =QEMU_RGB (0x00 ,0xaa ,0x00 ),/* green */ - [QEMU_COLOR_CYAN ] =QEMU_RGB (0x00 ,0xaa ,0xaa ),/* cyan */ - [QEMU_COLOR_RED ] =QEMU_RGB (0xaa ,0x00 ,0x00 ),/* red */ - [QEMU_COLOR_MAGENTA ] =QEMU_RGB (0xaa ,0x00 ,0xaa ),/* magenta */ - [QEMU_COLOR_YELLOW ] =QEMU_RGB (0xaa ,0xaa ,0x00 ),/* yellow */ - [QEMU_COLOR_WHITE ] =QEMU_RGB (0xaa ,0xaa ,0xaa ),/* white */ + [QEMU_COLOR_BLACK ] =QEMU_PIXMAN_COLOR_BLACK , + [QEMU_COLOR_BLUE ] =QEMU_PIXMAN_COLOR (0x00 ,0x00 ,0xaa ),/* blue */ + [QEMU_COLOR_GREEN ] =QEMU_PIXMAN_COLOR (0x00 ,0xaa ,0x00 ),/* green */ + [QEMU_COLOR_CYAN ] =QEMU_PIXMAN_COLOR (0x00 ,0xaa ,0xaa ),/* cyan */ + [QEMU_COLOR_RED ] =QEMU_PIXMAN_COLOR (0xaa ,0x00 ,0x00 ),/* red */ + [QEMU_COLOR_MAGENTA ] =QEMU_PIXMAN_COLOR (0xaa ,0x00 ,0xaa ),/* magenta */ + [QEMU_COLOR_YELLOW ] =QEMU_PIXMAN_COLOR (0xaa ,0xaa ,0x00 ),/* yellow */ + [QEMU_COLOR_WHITE ] =QEMU_PIXMAN_COLOR_GRAY , }, {/* bright */ - [QEMU_COLOR_BLACK ] =QEMU_RGB (0x00 ,0x00 ,0x00 ),/* black */ - [QEMU_COLOR_BLUE ] =QEMU_RGB (0x00 ,0x00 ,0xff ),/* blue */ - [QEMU_COLOR_GREEN ] =QEMU_RGB (0x00 ,0xff ,0x00 ),/* green */ - [QEMU_COLOR_CYAN ] =QEMU_RGB (0x00 ,0xff ,0xff ),/* cyan */ - [QEMU_COLOR_RED ] =QEMU_RGB (0xff ,0x00 ,0x00 ),/* red */ - [QEMU_COLOR_MAGENTA ] =QEMU_RGB (0xff ,0x00 ,0xff ),/* magenta */ - [QEMU_COLOR_YELLOW ] =QEMU_RGB (0xff ,0xff ,0x00 ),/* yellow */ - [QEMU_COLOR_WHITE ] =QEMU_RGB (0xff ,0xff ,0xff ),/* white */ + [QEMU_COLOR_BLACK ] =QEMU_PIXMAN_COLOR_BLACK , + [QEMU_COLOR_BLUE ] =QEMU_PIXMAN_COLOR (0x00 ,0x00 ,0xff ),/* blue */ + [QEMU_COLOR_GREEN ] =QEMU_PIXMAN_COLOR (0x00 ,0xff ,0x00 ),/* green */ + [QEMU_COLOR_CYAN ] =QEMU_PIXMAN_COLOR (0x00 ,0xff ,0xff ),/* cyan */ + [QEMU_COLOR_RED ] =QEMU_PIXMAN_COLOR (0xff ,0x00 ,0x00 ),/* red */ + [QEMU_COLOR_MAGENTA ] =QEMU_PIXMAN_COLOR (0xff ,0x00 ,0xff ),/* magenta */ + [QEMU_COLOR_YELLOW ] =QEMU_PIXMAN_COLOR (0xff ,0xff ,0x00 ),/* yellow */ + [QEMU_COLOR_WHITE ] =QEMU_PIXMAN_COLOR (0xff ,0xff ,0xff ),/* white */ } };
@@ -1520,8 +1517,8 @@ DisplaySurface *qemu_create_placeholder_surface(int w, int h, const char *msg) {DisplaySurface *surface =qemu_create_displaysurface (w, h); -pixman_color_t bg = color_table_rgb[0 ][QEMU_COLOR_BLACK ]; -pixman_color_t fg = color_table_rgb[0 ][QEMU_COLOR_WHITE ]; +pixman_color_t bg =QEMU_PIXMAN_COLOR_BLACK ; +pixman_color_t fg =QEMU_PIXMAN_COLOR_GRAY ;pixman_image_t *glyph;int len, x, y, i;
Signature · 1 line
2.41.0
Re: [PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers
Quoted 8 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
QEMU_RGBmacro is actually defining a pixman color. Make this explicit in the macro name. Move it toqemu-pixman.hso it can be used elsewhere, as done in the following patch. Finally, define QEMU_PIXMAN_COLOR_{BLACK,GRAY}, to avoid need to look up the VGA color table from the QemuConsole placeholder surface rendering.
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/qemu-pixman.h | 6 ++++++ ui/console.c | 39 ++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-)
PATCH 37/67 ui/console: rename vga_ functions → qemu_console_
In reply to [email protected]From: Marc-André Lureau <[email protected]>
They are not specific to VGA. Let's use the object type name as prefix instead, to avoid confusion.
--- ui/console.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
ui/console.c +12 -13
@@ -331,9 +331,8 @@ void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata) } } -static void vga_fill_rect (QemuConsole *con, -int posx,int posy,int width,int height, -pixman_color_t color) +static void qemu_console_fill_rect (QemuConsole *con,int posx,int posy, +int width,int height,pixman_color_t color) {DisplaySurface *surface =qemu_console_surface (con);pixman_rectangle16_t rect = {
@@ -345,8 +344,8 @@ static void vga_fill_rect(QemuConsole *con, }/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */ -static void vga_bitblt (QemuConsole *con, -int xs,int ys,int xd,int yd,int w,int h) +static void qemu_console_bitblt (QemuConsole *con, +int xs,int ys,int xd,int yd,int w,int h) {DisplaySurface *surface =qemu_console_surface (con);
@@ -526,8 +525,8 @@ static void console_refresh(QemuTextConsole *s) s->text_y[1 ] = s->height -1 ; s->cursor_invalidate =1 ; -vga_fill_rect (QEMU_CONSOLE (s),0 ,0 ,surface_width (surface),surface_height (surface), - color_table_rgb[0 ][QEMU_COLOR_BLACK ]); +qemu_console_fill_rect (QEMU_CONSOLE (s),0 ,0 ,surface_width (surface),surface_height (surface), + color_table_rgb[0 ][QEMU_COLOR_BLACK ]); y1 = s->y_displayed;for (y =0 ; y < s->height; y++) { c = s->cells + y1 * s->width;
@@ -605,12 +604,12 @@ static void vc_put_lf(VCChardev *vc) s->text_x[1 ] = s->width -1 ; s->text_y[1 ] = s->height -1 ; -vga_bitblt (QEMU_CONSOLE (s),0 ,FONT_HEIGHT ,0 ,0 , - s->width *FONT_WIDTH , - (s->height -1 ) *FONT_HEIGHT ); -vga_fill_rect (QEMU_CONSOLE (s),0 , (s->height -1 ) *FONT_HEIGHT , - s->width *FONT_WIDTH ,FONT_HEIGHT , - color_table_rgb[0 ][TEXT_ATTRIBUTES_DEFAULT .bgcol]); +qemu_console_bitblt (QEMU_CONSOLE (s),0 ,FONT_HEIGHT ,0 ,0 , + s->width *FONT_WIDTH , + (s->height -1 ) *FONT_HEIGHT ); +qemu_console_fill_rect (QEMU_CONSOLE (s),0 , (s->height -1 ) *FONT_HEIGHT , + s->width *FONT_WIDTH ,FONT_HEIGHT , + color_table_rgb[0 ][TEXT_ATTRIBUTES_DEFAULT .bgcol]); s->update_x0 =0 ; s->update_y0 =0 ; s->update_x1 = s->width *FONT_WIDTH ;
Signature · 1 line
2.41.0
Re: [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:38:11PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
They are not specific to VGA. Let's use the object type name as prefix instead, to avoid confusion.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
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 :|
Re: [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_
In reply to [email protected]Quoted 1 line · On Wed, 30 Aug 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Maybe refrain from using unicode arrow in Subject: as it may show up wrongly with some fonts. Just write "replace ... with" or "rename ... to" instead which is also more normal looking sentence than with an arrow.
Regards,
BALATON Zoltan
Quoted 66 lines
They are not specific to VGA. Let's use the object type name as prefix instead, to avoid confusion.
Signed-off-by Marc-André Lureau <[email protected]>---
ui/console.c| 25 ++++++++++++-------------1 file changed, 12 insertions(+), 13 deletions(-)ui/console.c +12
-13@@ -331,9 +331,8 @@ void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata) } } -static void vga_fill_rect (QemuConsole *con, -int posx,int posy,int width,int height, -pixman_color_t color) +static void qemu_console_fill_rect (QemuConsole *con,int posx,int posy, +int width,int height,pixman_color_t color) {DisplaySurface *surface =qemu_console_surface (con);pixman_rectangle16_t rect = {@@ -345,8 +344,8 @@ static void vga_fill_rect(QemuConsole *con, }/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */ -static void vga_bitblt (QemuConsole *con, -int xs,int ys,int xd,int yd,int w,int h) +static void qemu_console_bitblt (QemuConsole *con, +int xs,int ys,int xd,int yd,int w,int h) {DisplaySurface *surface =qemu_console_surface (con);@@ -526,8 +525,8 @@ static void console_refresh(QemuTextConsole *s) s->text_y[1 ] = s->height -1 ; s->cursor_invalidate =1 ; -vga_fill_rect (QEMU_CONSOLE (s),0 ,0 ,surface_width (surface),surface_height (surface), - color_table_rgb[0 ][QEMU_COLOR_BLACK ]); +qemu_console_fill_rect (QEMU_CONSOLE (s),0 ,0 ,surface_width (surface),surface_height (surface), + color_table_rgb[0 ][QEMU_COLOR_BLACK ]); y1 = s->y_displayed;for (y =0 ; y < s->height; y++) { c = s->cells + y1 * s->width;@@ -605,12 +604,12 @@ static void vc_put_lf(VCChardev *vc) s->text_x[1 ] = s->width -1 ; s->text_y[1 ] = s->height -1 ; -vga_bitblt (QEMU_CONSOLE (s),0 ,FONT_HEIGHT ,0 ,0 , - s->width *FONT_WIDTH , - (s->height -1 ) *FONT_HEIGHT ); -vga_fill_rect (QEMU_CONSOLE (s),0 , (s->height -1 ) *FONT_HEIGHT , - s->width *FONT_WIDTH ,FONT_HEIGHT , - color_table_rgb[0 ][TEXT_ATTRIBUTES_DEFAULT .bgcol]); +qemu_console_bitblt (QEMU_CONSOLE (s),0 ,FONT_HEIGHT ,0 ,0 , + s->width *FONT_WIDTH , + (s->height -1 ) *FONT_HEIGHT ); +qemu_console_fill_rect (QEMU_CONSOLE (s),0 , (s->height -1 ) *FONT_HEIGHT , + s->width *FONT_WIDTH ,FONT_HEIGHT , + color_table_rgb[0 ][TEXT_ATTRIBUTES_DEFAULT .bgcol]); s->update_x0 =0 ; s->update_y0 =0 ; s->update_x1 = s->width *FONT_WIDTH ;
Re: [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_
In reply to [email protected]Quoted 9 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
They are not specific to VGA. Let's use the object type name as prefix instead, to avoid confusion.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
PATCH 38/67 ui/console: assert(surface) where appropriate
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The QemuTextConsole code paths assume a surface is being used as scanout, let's make this more explicit.
--- ui/console.c | 4 ++++ 1 file changed, 4 insertions(+)
ui/console.c +4 -0
@@ -339,6 +339,7 @@ static void qemu_console_fill_rect(QemuConsole *con, int posx, int posy, .x = posx, .y = posy, .width = width, .height = height }; +assert (surface);pixman_image_fill_rectangles (PIXMAN_OP_SRC , surface->image, &color,1 , &rect); }
@@ -349,6 +350,7 @@ static void qemu_console_bitblt(QemuConsole *con, {DisplaySurface *surface =qemu_console_surface (con); +assert (surface);pixman_image_composite (PIXMAN_OP_SRC , surface->image,NULL , surface->image, xs, ys,0 ,0 , xd, yd, w, h);
@@ -392,6 +394,7 @@ static void vga_putcharxy(QemuConsole *s, int x, int y, int ch,DisplaySurface *surface =qemu_console_surface (s);pixman_color_t fgcol, bgcol; +assert (surface);if (t_attrib->invers) { bgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol]; fgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol];
@@ -519,6 +522,7 @@ static void console_refresh(QemuTextConsole *s)TextCell *c;int x, y, y1; +assert (surface); s->text_x[0 ] =0 ; s->text_y[0 ] =0 ; s->text_x[1 ] = s->width -1 ;
Signature · 1 line
2.41.0
Re: [PATCH 38/67] ui/console: assert(surface) where appropriate
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:38:12PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The QemuTextConsole code paths assume a surface is being used as scanout, let's make this more explicit.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 4 ++++ 1 file changed, 4 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 :|
PATCH 39/67 ui/console: fold text_console_update_cursor_timer
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
ui/console.c +2 -8
@@ -174,7 +174,6 @@ static QEMUTimer *cursor_timer;static void dpy_refresh (DisplayState *s);static DisplayState *get_alloc_displaystate (void ); -static void text_console_update_cursor_timer (void );static void text_console_update_cursor (void *opaque);static bool displaychangelistener_has_dmabuf (DisplayChangeListener *dcl); static bool console_compatible_with(QemuConsole *con,
@@ -2497,12 +2496,6 @@ static void vc_chr_set_echo(Chardev *chr, bool echo) drv->console->echo = echo; } -static void text_console_update_cursor_timer (void ) -{ -timer_mod (cursor_timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME ) - +CONSOLE_CURSOR_PERIOD /2 ); -} -static void text_console_update_cursor (void *opaque) {QemuConsole *s;
@@ -2520,7 +2513,8 @@ static void text_console_update_cursor(void *opaque) }if (count) { -text_console_update_cursor_timer (); +timer_mod (cursor_timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME ) + +CONSOLE_CURSOR_PERIOD /2 ); } }
Signature · 1 line
2.41.0
Re: [PATCH 39/67] ui/console: fold text_console_update_cursor_timer
Quoted 12 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)static void text_console_update_cursor(void *opaque) { QemuConsole *s;
ui/console.c static void text_console_update_cursor(void *opaque) · line 2517
Quoted 6 lines
ui/console.c +2
-1@@ -2520,7 +2513,8 @@ static void text_console_update_cursor(void *opaque) }if (count) { -text_console_update_cursor_timer (); +timer_mod (cursor_timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME ) + +CONSOLE_CURSOR_PERIOD /2 );
This should be padded here ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 3 lines
(quoted diff) +0
-0} }
Re: [PATCH 39/67] ui/console: fold text_console_update_cursor_timer
In reply to [email protected]Quoted 6 lines · On Wed, Aug 30, 2023 at 01:38:13PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
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 :|
PATCH 40/67 ui/vc: skip text console resize when possible
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This function is called on invalidate, on each cursor blink.
Avoid the extra copy when the console size didn't change.
--- ui/console.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
ui/console.c +9 -3
@@ -413,13 +413,19 @@ static void text_console_resize(QemuTextConsole *t) {QemuConsole *s =QEMU_CONSOLE (t);TextCell *cells, *c, *c1; -int w1, x, y, last_width; +int w1, x, y, last_width, w, h;assert (s->scanout.kind ==SCANOUT_SURFACE ); + w =surface_width (s->surface) /FONT_WIDTH ; + h =surface_height (s->surface) /FONT_HEIGHT ; +if (w == t->width && h == t->height) { +return ; + } + last_width = t->width; - t->width =surface_width (s->surface) /FONT_WIDTH ; - t->height =surface_height (s->surface) /FONT_HEIGHT ; + t->width = w; + t->height = h; w1 = last_width;if (t->width < w1)
Signature · 1 line
2.41.0
Re: [PATCH 40/67] ui/vc: skip text console resize when possible
Quoted 10 lines · On Wed, Aug 30, 2023 at 01:38:14PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This function is called on invalidate, on each cursor blink.
Avoid the extra copy when the console size didn't change.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
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 :|
PATCH 41/67 ui/console: minor stylistic changes
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
ui/console.c +4 -6
@@ -427,20 +427,18 @@ static void text_console_resize(QemuTextConsole *t) t->width = w; t->height = h; - w1 = last_width; -if (t->width < w1) - w1 = t->width; + w1 =MIN (t->width, last_width); cells =g_new (TextCell, t->width * t->total_height +1 ); -for (y =0 ; y < t->total_height; y++) { +for (y =0 ; y < t->total_height; y++) { c = &cells[y * t->width];if (w1 >0 ) { c1 = &t->cells[y * last_width]; -for (x =0 ; x < w1; x++) { +for (x =0 ; x < w1; x++) { *c++ = *c1++; } } -for (x = w1; x < t->width; x++) { +for (x = w1; x < t->width; x++) { c->ch =' ' ; c->t_attrib =TEXT_ATTRIBUTES_DEFAULT ; c++;
Signature · 1 line
2.41.0
Re: [PATCH 41/67] ui/console: minor stylistic changes
Quoted 6 lines · On Wed, Aug 30, 2023 at 01:38:15PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
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 :|
PATCH 42/67 ui/vc: move text console invalidate in helper
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This will allow to split the VC code in a separate unit more easily.
--- include/ui/console.h | 1 + ui/console.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-)
include/ui/console.h +1 -0
@@ -521,6 +521,7 @@ void console_select(unsigned int index);void qemu_console_resize (QemuConsole *con,int width,int height);DisplaySurface *qemu_console_surface (QemuConsole *con); void coroutine_fn qemu_console_co_wait_update(QemuConsole *con); +int qemu_invalidate_text_consoles (void );/* console-gl.c */ #ifdef CONFIG_OPENGL
ui/console.c +9 -4
@@ -2500,13 +2500,11 @@ static void vc_chr_set_echo(Chardev *chr, bool echo) drv->console->echo = echo; } -static void text_console_update_cursor (void *opaque) +int qemu_invalidate_text_consoles (void ) {QemuConsole *s;int count =0 ; - cursor_visible_phase = !cursor_visible_phase; - QTAILQ_FOREACH(s, &consoles, next) {if (qemu_console_is_graphic (s) || !qemu_console_is_visible (s)) {
@@ -2516,7 +2514,14 @@ static void text_console_update_cursor(void *opaque)graphic_hw_invalidate (s); } -if (count) { +return count; +} + +static void text_console_update_cursor (void *opaque) +{ + cursor_visible_phase = !cursor_visible_phase; + +if (qemu_invalidate_text_consoles ()) {timer_mod (cursor_timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME ) +CONSOLE_CURSOR_PERIOD /2 ); }
Signature · 1 line
2.41.0
Re: [PATCH 42/67] ui/vc: move text console invalidate in helper
Quoted 9 lines · On Wed, Aug 30, 2023 at 01:38:16PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This will allow to split the VC code in a separate unit more easily.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 1 + ui/console.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-)
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 :|
PATCH 43/67 ui/vc: do not parse VC-specific options in Spice and GTK
In reply to [email protected]From: Marc-André Lureau <[email protected]>
In commit 6f974c843c ("gtk: overwrite the console.c char driver"), I shared the VC console parse handler with GTK. And later on in commit d8aec9d9 ("display: add -display spice-app launching a Spice client"), I also used it to handle spice-app VC.
This is not necessary, the VC console options (width/height/cols/rows) are specific, and unused by tty-level GTK/Spice VC.
This is not a breaking change, as those options are still being parsed by QAPI ChardevVC. Adjust the documentation about it.
--- qapi/char.json | 4 ++++ include/chardev/char.h | 3 --- ui/console.c | 4 ++-- ui/gtk.c | 1 - ui/spice-app.c | 7 ++++++- 5 files changed, 12 insertions(+), 7 deletions(-)
qapi/char.json +4 -0
@@ -390,6 +390,10 @@ # # @rows: console height, in chars # +# Note: the options are only effective when using the built-in QEMU graphical VC +# (with the SDL display). When the VC is handled by the display backend (with +# GTK/VTE, Spice or D-Bus), they are simply ignored. +# # Since: 1.5 ## { 'struct': 'ChardevVC',
include/chardev/char.h +0 -3
@@ -320,7 +320,4 @@ GSource *qemu_chr_timeout_add_ms(Chardev *chr, guint ms,void suspend_mux_open (void );void resume_mux_open (void ); -/* console.c */ -void qemu_chr_parse_vc (QemuOpts *opts,ChardevBackend *backend,Error **errp); -#endif
ui/console.c +2 -2
@@ -2708,7 +2708,7 @@ void qemu_display_help(void) } } -void qemu_chr_parse_vc (QemuOpts *opts,ChardevBackend *backend,Error **errp) +static void vc_chr_parse (QemuOpts *opts,ChardevBackend *backend,Error **errp) {int val;ChardevVC *vc;
@@ -2746,7 +2746,7 @@ static void char_vc_class_init(ObjectClass *oc, void *data) {ChardevClass *cc =CHARDEV_CLASS (oc); - cc->parse = qemu_chr_parse_vc; + cc->parse = vc_chr_parse; cc->open = vc_chr_open; cc->chr_write = vc_chr_write; cc->chr_accept_input = vc_chr_accept_input;
ui/gtk.c +0 -1
@@ -1860,7 +1860,6 @@ static void char_gd_vc_class_init(ObjectClass *oc, void *data) {ChardevClass *cc =CHARDEV_CLASS (oc); - cc->parse = qemu_chr_parse_vc; cc->open = gd_vc_open; cc->chr_write = gd_vc_chr_write; cc->chr_accept_input = gd_vc_chr_accept_input;
ui/spice-app.c +6 -1
@@ -96,6 +96,11 @@ static void vc_chr_set_echo(Chardev *chr, bool echo)/* TODO: set echo for frontends QMP and qtest */ } +static void vc_chr_parse (QemuOpts *opts,ChardevBackend *backend,Error **errp) +{ +/* fqdn is dealt with in vc_chr_open() */ +} +static void char_vc_class_init (ObjectClass *oc,void *data) {VCChardevClass *vc =CHARDEV_VC_CLASS (oc);
@@ -103,7 +108,7 @@ static void char_vc_class_init(ObjectClass *oc, void *data) vc->parent_open = cc->open; - cc->parse = qemu_chr_parse_vc; + cc->parse = vc_chr_parse; cc->open = vc_chr_open; cc->chr_set_echo = vc_chr_set_echo; }
Signature · 1 line
2.41.0
Re: [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK
Quoted 27 lines · On Wed, Aug 30, 2023 at 01:38:17PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
In commit
6f974c843c("gtk: overwrite theconsole.cchar driver"), I shared the VC console parse handler with GTK. And later on in commitd8aec9d9("display: add -display spice-app launching a Spice client"), I also used it to handle spice-app VC.This is not necessary, the VC console options (width/height/cols/rows) are specific, and unused by tty-level GTK/Spice VC.
This is not a breaking change, as those options are still being parsed by QAPI ChardevVC. Adjust the documentation about it.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi/char.json | 4 ++++ include/chardev/char.h | 3 --- ui/console.c | 4 ++-- ui/gtk.c | 1 - ui/spice-app.c | 7 ++++++- 5 files changed, 12 insertions(+), 7 deletions(-)qapi/char.json +0
-0
qapi/char.json line 395
Quoted 6 lines
qapi/char.json +3
-0@@ -390,6 +390,10 @@ # # @rows: console height, in chars # +# Note: the options are only effective when using the built-in QEMU graphical VC +# (with the SDL display). When the VC is handled by the display backend (with +# GTK/VTE, Spice or D-Bus), they are simply ignored.
I don't find this explains the situation very well, I had to look at the code to understand what's ultimately going on, as I didn't really know what it meant by "built-in QEMU graphical VC". From the end user's POV, they're just using '-chardev vc...'.
IIUC, the command line -chardev vc,..... will end up instantiating TYPE_CHARDEV_VC.
We actually then have 4 completely different implementations of TYPE_CHARDEV_VC, and depending on which display backend is enabled, a different TYPE_CHARDEV_VC will get registered.
So what your comment is saying is that the width/height/rows/cols properties will only get honoured if the TYPE_CHARDEV_VC that is registered, is the one that maps to the SDL display backend.
Wow, is this situation confusing and gross in the code :-(
So for the comment I think we can just cut out a few words to make it simpler
# Note: the options are only effective when the SDL graphical
# display backend is active. They are ignored with the GTK, # Spice, VNC and D-Bus display backends.
As a future exercise for anyone motiviated, I would say that TYPE_CHARDEV_VC ought to be abstract and we then have subclasses for each of the impls we have that are registered unconditionally with type_init(), then pick the subclass to instantiate based on the display backend. That way we can ultimately make the QAPI schema reflect that we have multiple ChardevVC impls and only expose the cols/width/etc for the SDL impl.
Anyway, if the comment is simplied/clarified then
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 :|
Re: [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK
Hi
Quoted 52 lines · Daniel P. Berrangé
Quoted 27 lines · On Wed, Aug 30, 2023 at 01:38:17PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
In commit
6f974c843c("gtk: overwrite theconsole.cchar driver"), I shared the VC console parse handler with GTK. And later on in commitd8aec9d9("display: add -display spice-app launching a Spice client"), I also used it to handle spice-app VC.This is not necessary, the VC console options (width/height/cols/rows) are specific, and unused by tty-level GTK/Spice VC.
This is not a breaking change, as those options are still being parsed by QAPI ChardevVC. Adjust the documentation about it.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi/char.json | 4 ++++ include/chardev/char.h | 3 --- ui/console.c | 4 ++-- ui/gtk.c | 1 - ui/spice-app.c | 7 ++++++- 5 files changed, 12 insertions(+), 7 deletions(-)qapi/char.json +0
-0qapi/char.json line 395
Quoted 6 lines
qapi/char.json +3
-0@@ -390,6 +390,10 @@ # # @rows: console height, in chars # +# Note: the options are only effective when using the built-in QEMU graphical VC +# (with the SDL display). When the VC is handled by the display backend (with +# GTK/VTE, Spice or D-Bus), they are simply ignored.I don't find this explains the situation very well, I had to look at the code to understand what's ultimately going on, as I didn't really know what it meant by "built-in QEMU graphical VC". From the end user's POV, they're just using '-chardev vc...'.
IIUC, the command line -chardev vc,..... will end up instantiating
TYPE_CHARDEV_VC.We actually then have 4 completely different implementations of
TYPE_CHARDEV_VC, and depending on which display backend is enabled, a differentTYPE_CHARDEV_VCwill get registered.So what your comment is saying is that the width/height/rows/cols properties will only get honoured if the
TYPE_CHARDEV_VCthat is registered, is the one that maps to the SDL display backend.
Quoted 8 lines
Wow, is this situation confusing and gross in the code :-(
So for the comment I think we can just cut out a few words to make it simpler
# Note: the options are only effective when the SDL graphical
# display backend is active. They are ignored with the GTK, # Spice, VNC and D-Bus display backends.
Actually, VNC too. I adjusted the doc.
thanks
Quoted 15 lines
As a future exercise for anyone motiviated, I would say that
TYPE_CHARDEV_VCought to be abstract and we then have subclasses for each of the impls we have that are registered unconditionally withtype_init(), then pick the subclass to instantiate based on the display backend. That way we can ultimately make the QAPI schema reflect that we have multiple ChardevVC impls and only expose the cols/width/etc for the SDL impl.Anyway, if the comment is simplied/clarified then
Reviewed-by Daniel P. Berrangé <[email protected]>
Quoted 8 lines
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 :|
--
Marc-André Lureau
PATCH 44/67 ui/vc: change the argument for QemuTextConsole
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Those functions are specifc to text/vc console, make that explicit from the argument type.
--- include/ui/console.h | 6 +++--- ui/console.c | 14 ++++++-------- ui/gtk.c | 2 +- ui/sdl2-input.c | 5 +++-- ui/sdl2.c | 5 ++--- 5 files changed, 15 insertions(+), 17 deletions(-)
include/ui/console.h +3 -3
@@ -112,9 +112,9 @@ bool qemu_mouse_set(int index, Error **errp);#define QEMU_KEY_CTRL_PAGEUP 0xe406#define QEMU_KEY_CTRL_PAGEDOWN 0xe407 -void kbd_put_keysym_console (QemuConsole *s,int keysym); -bool kbd_put_qcode_console (QemuConsole *s,int qcode,bool ctrl); -void kbd_put_string_console (QemuConsole *s,const char *str,int len); +void kbd_put_keysym_console (QemuTextConsole *s,int keysym); +bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl); +void kbd_put_string_console (QemuTextConsole *s,const char *str,int len);void kbd_put_keysym (int keysym);/* Touch devices */
ui/console.c +6 -8
@@ -1135,16 +1135,12 @@ static void kbd_send_chars(QemuTextConsole *s) }/* called when an ascii key is pressed */ -void kbd_put_keysym_console (QemuConsole *con,int keysym) +void kbd_put_keysym_console (QemuTextConsole *s,int keysym) { -QemuTextConsole *s = (QemuTextConsole *)object_dynamic_cast (OBJECT (con),TYPE_QEMU_TEXT_CONSOLE );uint8_t buf[16 ], *q;int c;uint32_t num_free; -if (!s) -return ; -switch (keysym) {case QEMU_KEY_CTRL_UP :console_scroll (s,-1 );
@@ -1214,7 +1210,7 @@ static const int ctrl_qcode_to_keysym[Q_KEY_CODE__MAX] = { [Q_KEY_CODE_PGDN] = QEMU_KEY_CTRL_PAGEDOWN, }; -bool kbd_put_qcode_console (QemuConsole *s,int qcode,bool ctrl) +bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl) {int keysym;
@@ -1226,7 +1222,7 @@ bool kbd_put_qcode_console(QemuConsole *s, int qcode, bool ctrl)return true; } -void kbd_put_string_console (QemuConsole *s,const char *str,int len) +void kbd_put_string_console (QemuTextConsole *s,const char *str,int len) {int i;
@@ -1237,7 +1233,9 @@ void kbd_put_string_console(QemuConsole *s, const char *str, int len)void kbd_put_keysym (int keysym) { -kbd_put_keysym_console (active_console, keysym); +if (QEMU_IS_TEXT_CONSOLE (active_console)) { +kbd_put_keysym_console (QEMU_TEXT_CONSOLE (active_console), keysym); + } }static void text_console_invalidate (void *opaque)
ui/gtk.c +1 -1
@@ -1187,7 +1187,7 @@ static gboolean gd_text_key_down(GtkWidget *widget, GdkEventKey *key, void *opaque) {VirtualConsole *vc = opaque; -QemuConsole *con = vc->gfx.dcl.con; +QemuTextConsole *con =QEMU_TEXT_CONSOLE (vc->gfx.dcl.con);if (key->keyval == GDK_KEY_Delete) {kbd_put_qcode_console (con,Q_KEY_CODE_DELETE , false);
ui/sdl2-input.c +3 -2
@@ -44,14 +44,15 @@ void sdl2_process_key(struct sdl2_console *scon,qkbd_state_key_event (scon->kbd, qcode, ev->type ==SDL_KEYDOWN );if (!qemu_console_is_graphic (con)) { +QemuTextConsole *s =QEMU_TEXT_CONSOLE (con);bool ctrl =qkbd_state_modifier_get (scon->kbd,QKBD_MOD_CTRL );if (ev->type ==SDL_KEYDOWN ) {switch (qcode) {case Q_KEY_CODE_RET : -kbd_put_keysym_console (con,'\n' ); +kbd_put_keysym_console (s,'\n' );break ;default : -kbd_put_qcode_console (con, qcode, ctrl); +kbd_put_qcode_console (s, qcode, ctrl);break ; } }
ui/sdl2.c +2 -3
@@ -483,10 +483,9 @@ static void handle_textinput(SDL_Event *ev)return ; } -if (qemu_console_is_graphic (con)) { -return ; +if (QEMU_IS_TEXT_CONSOLE (con)) { +kbd_put_string_console (QEMU_TEXT_CONSOLE (con), ev->text.text,strlen (ev->text.text)); } -kbd_put_string_console (con, ev->text.text,strlen (ev->text.text)); }static void handle_mousemotion (SDL_Event *ev)
Signature · 1 line
2.41.0
Re: [PATCH 44/67] ui/vc: change the argument for QemuTextConsole
Quoted 100 lines · On Wed, Aug 30, 2023 at 01:38:18PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Those functions are specifc to text/vc console, make that explicit from the argument type.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 6 +++--- ui/console.c | 14 ++++++-------- ui/gtk.c | 2 +- ui/sdl2-input.c | 5 +++-- ui/sdl2.c | 5 ++--- 5 files changed, 15 insertions(+), 17 deletions(-)include/ui/console.h +3
-3@@ -112,9 +112,9 @@ bool qemu_mouse_set(int index, Error **errp);#define QEMU_KEY_CTRL_PAGEUP 0xe406#define QEMU_KEY_CTRL_PAGEDOWN 0xe407 -void kbd_put_keysym_console (QemuConsole *s,int keysym); -bool kbd_put_qcode_console (QemuConsole *s,int qcode,bool ctrl); -void kbd_put_string_console (QemuConsole *s,const char *str,int len); +void kbd_put_keysym_console (QemuTextConsole *s,int keysym); +bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl); +void kbd_put_string_console (QemuTextConsole *s,const char *str,int len);void kbd_put_keysym (int keysym);/* Touch devices */ ui/console.c +6
-8@@ -1135,16 +1135,12 @@ static void kbd_send_chars(QemuTextConsole *s) }/* called when an ascii key is pressed */ -void kbd_put_keysym_console (QemuConsole *con,int keysym) +void kbd_put_keysym_console (QemuTextConsole *s,int keysym) { -QemuTextConsole *s = (QemuTextConsole *)object_dynamic_cast (OBJECT (con),TYPE_QEMU_TEXT_CONSOLE );uint8_t buf[16 ], *q;int c;uint32_t num_free; -if (!s) -return ; -switch (keysym) {case QEMU_KEY_CTRL_UP :console_scroll (s,-1 );@@ -1214,7 +1210,7 @@ static const int ctrl_qcode_to_keysym[Q_KEY_CODE__MAX] = { [Q_KEY_CODE_PGDN] = QEMU_KEY_CTRL_PAGEDOWN, }; -bool kbd_put_qcode_console (QemuConsole *s,int qcode,bool ctrl) +bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl) {int keysym;@@ -1226,7 +1222,7 @@ bool kbd_put_qcode_console(QemuConsole *s, int qcode, bool ctrl)return true; } -void kbd_put_string_console (QemuConsole *s,const char *str,int len) +void kbd_put_string_console (QemuTextConsole *s,const char *str,int len) {int i;@@ -1237,7 +1233,9 @@ void kbd_put_string_console(QemuConsole *s, const char *str, int len)void kbd_put_keysym (int keysym) { -kbd_put_keysym_console (active_console, keysym); +if (QEMU_IS_TEXT_CONSOLE (active_console)) { +kbd_put_keysym_console (QEMU_TEXT_CONSOLE (active_console), keysym); + } }static void text_console_invalidate (void *opaque)ui/gtk.c +1
-1@@ -1187,7 +1187,7 @@ static gboolean gd_text_key_down(GtkWidget *widget, GdkEventKey *key, void *opaque) {VirtualConsole *vc = opaque; -QemuConsole *con = vc->gfx.dcl.con; +QemuTextConsole *con =QEMU_TEXT_CONSOLE (vc->gfx.dcl.con);if (key->keyval == GDK_KEY_Delete) {kbd_put_qcode_console (con,Q_KEY_CODE_DELETE , false);ui/sdl2-input.c +0
-0
ui/sdl2-input.c void sdl2_process_key(struct sdl2_console *scon, · line 46
Quoted 3 lines
ui/sdl2-input.c +0
-0@@ -44,14 +44,15 @@ void sdl2_process_key(struct sdl2_console *scon,qkbd_state_key_event (scon->kbd, qcode, ev->type ==SDL_KEYDOWN );if (!qemu_console_is_graphic (con)) {
If i'm nit-picking I'd say change to be
"if (QEMU_IS_TEXT_CONSOLE(con)) {"
as you did in the other places in this patch
Quoted 21 lines
ui/sdl2-input.c +3
-2+QemuTextConsole *s =QEMU_TEXT_CONSOLE (con);bool ctrl =qkbd_state_modifier_get (scon->kbd,QKBD_MOD_CTRL );if (ev->type ==SDL_KEYDOWN ) {switch (qcode) {case Q_KEY_CODE_RET : -kbd_put_keysym_console (con,'\n' ); +kbd_put_keysym_console (s,'\n' );break ;default : -kbd_put_qcode_console (con, qcode, ctrl); +kbd_put_qcode_console (s, qcode, ctrl);break ; } }ui/sdl2.c +0
-0@@ -483,10 +483,9 @@ static void handle_textinput(SDL_Event *ev)return ; }
ui/sdl2.c static void handle_textinput(SDL_Event *ev) · line 491
Quoted 10 lines
ui/sdl2.c +2
-3-if (qemu_console_is_graphic (con)) { -return ; +if (QEMU_IS_TEXT_CONSOLE (con)) { +kbd_put_string_console (QEMU_TEXT_CONSOLE (con), ev->text.text,strlen (ev->text.text)); } -kbd_put_string_console (con, ev->text.text,strlen (ev->text.text)); }static void handle_mousemotion (SDL_Event *ev)
With or without my suggestion:
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 :|
PATCH 45/67 ui/vc: remove kby_put_keysym() and update function calls
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The function calls to kbd_put_keysym have been updated to now call kbd_put_keysym_console with a NULL console parameter.
Like most console functions, NULL argument is now for the active console.
This will allow to rename the text console functions in a consistent manner.
--- include/ui/console.h | 1 - ui/console.c | 14 ++++++------ ui/curses.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 5 files changed, 36 insertions(+), 37 deletions(-)
include/ui/console.h +0 -1
@@ -115,7 +115,6 @@ bool qemu_mouse_set(int index, Error **errp);void kbd_put_keysym_console (QemuTextConsole *s,int keysym);bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl);void kbd_put_string_console (QemuTextConsole *s,const char *str,int len); -void kbd_put_keysym (int keysym);/* Touch devices */ typedef struct touch_slot {
ui/console.c +7 -7
@@ -1141,6 +1141,13 @@ void kbd_put_keysym_console(QemuTextConsole *s, int keysym)int c;uint32_t num_free; +if (!s) { +if (!QEMU_IS_TEXT_CONSOLE (active_console)) { +return ; + } + s =QEMU_TEXT_CONSOLE (active_console); + } +switch (keysym) {case QEMU_KEY_CTRL_UP :console_scroll (s,-1 );
@@ -1231,13 +1238,6 @@ void kbd_put_string_console(QemuTextConsole *s, const char *str, int len) } } -void kbd_put_keysym (int keysym) -{ -if (QEMU_IS_TEXT_CONSOLE (active_console)) { -kbd_put_keysym_console (QEMU_TEXT_CONSOLE (active_console), keysym); - } -} -static void text_console_invalidate (void *opaque) {QemuTextConsole *s =QEMU_TEXT_CONSOLE (opaque);
ui/curses.c +1 -1
@@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl)if (keysym ==-1 ) keysym = chr; -kbd_put_keysym (keysym); +kbd_put_keysym_console (NULL , keysym); } } }
ui/vnc.c +27 -27
115 lines not on this page · raw message
ui/cocoa.m +1 -1
@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } if (keysym) { - kbd_put_keysym(keysym); + kbd_put_keysym_console(NULL, keysym); } }
Signature · 1 line
2.41.0
Re: [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls
Quoted 80 lines · On 2023/08/30 18:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The function calls to
kbd_put_keysymhave been updated to now callkbd_put_keysym_consolewith a NULL console parameter.Like most console functions, NULL argument is now for the active console.
This will allow to rename the text console functions in a consistent manner.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 1 - ui/console.c | 14 ++++++------ ui/curses.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 5 files changed, 36 insertions(+), 37 deletions(-)include/ui/console.h +0
-1@@ -115,7 +115,6 @@ bool qemu_mouse_set(int index, Error **errp);void kbd_put_keysym_console (QemuTextConsole *s,int keysym);bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl);void kbd_put_string_console (QemuTextConsole *s,const char *str,int len); -void kbd_put_keysym (int keysym);/* Touch devices */ typedef struct touch_slot {ui/console.c +7
-7@@ -1141,6 +1141,13 @@ void kbd_put_keysym_console(QemuTextConsole *s, int keysym)int c;uint32_t num_free; +if (!s) { +if (!QEMU_IS_TEXT_CONSOLE (active_console)) { +return ; + } + s =QEMU_TEXT_CONSOLE (active_console); + } +switch (keysym) {case QEMU_KEY_CTRL_UP :console_scroll (s,-1 );@@ -1231,13 +1238,6 @@ void kbd_put_string_console(QemuTextConsole *s, const char *str, int len) } } -void kbd_put_keysym (int keysym) -{ -if (QEMU_IS_TEXT_CONSOLE (active_console)) { -kbd_put_keysym_console (QEMU_TEXT_CONSOLE (active_console), keysym); - } -} -static void text_console_invalidate (void *opaque) {QemuTextConsole *s =QEMU_TEXT_CONSOLE (opaque);ui/curses.c +1
-1@@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl)if (keysym ==-1 ) keysym = chr; -kbd_put_keysym (keysym); +kbd_put_keysym_console (NULL , keysym); } } }ui/vnc.c +0
-0
ui/vnc.c static void do_key_event(VncState *vs, int down, int keycode, int sym) · line 1948
Quoted 5 lines
ui/vnc.c +1
-1@@ -1945,88 +1945,88 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)case 0xb8 :/* Right ALT */ break ;case 0xc8 : -kbd_put_keysym (QEMU_KEY_UP ); +kbd_put_keysym_console (NULL ,QEMU_KEY_UP );
vs->vd->dcl.con should be used instead. There may be VNC connections for consoles other than the "active console" and in such a case vs->vd->dcl.con != NULL. Unfortunately it seems that ui/vnc is very buggy in such a situation.
Quoted 123 lines
ui/vnc.c +26
-26break ;case 0xd0 : -kbd_put_keysym (QEMU_KEY_DOWN ); +kbd_put_keysym_console (NULL ,QEMU_KEY_DOWN );break ;case 0xcb : -kbd_put_keysym (QEMU_KEY_LEFT ); +kbd_put_keysym_console (NULL ,QEMU_KEY_LEFT );break ;case 0xcd : -kbd_put_keysym (QEMU_KEY_RIGHT ); +kbd_put_keysym_console (NULL ,QEMU_KEY_RIGHT );break ;case 0xd3 : -kbd_put_keysym (QEMU_KEY_DELETE ); +kbd_put_keysym_console (NULL ,QEMU_KEY_DELETE );break ;case 0xc7 : -kbd_put_keysym (QEMU_KEY_HOME ); +kbd_put_keysym_console (NULL ,QEMU_KEY_HOME );break ;case 0xcf : -kbd_put_keysym (QEMU_KEY_END ); +kbd_put_keysym_console (NULL ,QEMU_KEY_END );break ;case 0xc9 : -kbd_put_keysym (QEMU_KEY_PAGEUP ); +kbd_put_keysym_console (NULL ,QEMU_KEY_PAGEUP );break ;case 0xd1 : -kbd_put_keysym (QEMU_KEY_PAGEDOWN ); +kbd_put_keysym_console (NULL ,QEMU_KEY_PAGEDOWN );break ;case 0x47 : -kbd_put_keysym (numlock ?'7' :QEMU_KEY_HOME ); +kbd_put_keysym_console (NULL , numlock ?'7' :QEMU_KEY_HOME );break ;case 0x48 : -kbd_put_keysym (numlock ?'8' :QEMU_KEY_UP ); +kbd_put_keysym_console (NULL , numlock ?'8' :QEMU_KEY_UP );break ;case 0x49 : -kbd_put_keysym (numlock ?'9' :QEMU_KEY_PAGEUP ); +kbd_put_keysym_console (NULL , numlock ?'9' :QEMU_KEY_PAGEUP );break ;case 0x4b : -kbd_put_keysym (numlock ?'4' :QEMU_KEY_LEFT ); +kbd_put_keysym_console (NULL , numlock ?'4' :QEMU_KEY_LEFT );break ;case 0x4c : -kbd_put_keysym ('5' ); +kbd_put_keysym_console (NULL ,'5' );break ;case 0x4d : -kbd_put_keysym (numlock ?'6' :QEMU_KEY_RIGHT ); +kbd_put_keysym_console (NULL , numlock ?'6' :QEMU_KEY_RIGHT );break ;case 0x4f : -kbd_put_keysym (numlock ?'1' :QEMU_KEY_END ); +kbd_put_keysym_console (NULL , numlock ?'1' :QEMU_KEY_END );break ;case 0x50 : -kbd_put_keysym (numlock ?'2' :QEMU_KEY_DOWN ); +kbd_put_keysym_console (NULL , numlock ?'2' :QEMU_KEY_DOWN );break ;case 0x51 : -kbd_put_keysym (numlock ?'3' :QEMU_KEY_PAGEDOWN ); +kbd_put_keysym_console (NULL , numlock ?'3' :QEMU_KEY_PAGEDOWN );break ;case 0x52 : -kbd_put_keysym ('0' ); +kbd_put_keysym_console (NULL ,'0' );break ;case 0x53 : -kbd_put_keysym (numlock ?'.' :QEMU_KEY_DELETE ); +kbd_put_keysym_console (NULL , numlock ?'.' :QEMU_KEY_DELETE );break ;case 0xb5 : -kbd_put_keysym ('/' ); +kbd_put_keysym_console (NULL ,'/' );break ;case 0x37 : -kbd_put_keysym ('*' ); +kbd_put_keysym_console (NULL ,'*' );break ;case 0x4a : -kbd_put_keysym ('-' ); +kbd_put_keysym_console (NULL ,'-' );break ;case 0x4e : -kbd_put_keysym ('+' ); +kbd_put_keysym_console (NULL ,'+' );break ;case 0x9c : -kbd_put_keysym ('\n' ); +kbd_put_keysym_console (NULL ,'\n' );break ;default :if (control) { -kbd_put_keysym (sym &0x1f ); +kbd_put_keysym_console (NULL , sym &0x1f ); }else { -kbd_put_keysym (sym); +kbd_put_keysym_console (NULL , sym); }break ; }ui/cocoa.m +1
-1@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } if (keysym) { - kbd_put_keysym(keysym); + kbd_put_keysym_console(NULL, keysym); } }
Re: [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls
Hi
Quoted 84 lines · Akihiko Odaki
Quoted 82 lines · On 2023/08/30 18:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The function calls to
kbd_put_keysymhave been updated to now callkbd_put_keysym_consolewith a NULL console parameter.Like most console functions, NULL argument is now for the active console.
This will allow to rename the text console functions in a consistent manner.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 1 - ui/console.c | 14 ++++++------ ui/curses.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 5 files changed, 36 insertions(+), 37 deletions(-)include/ui/console.h +0
-1@@ -115,7 +115,6 @@ bool qemu_mouse_set(int index, Error **errp);void kbd_put_keysym_console (QemuTextConsole *s,int keysym);bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl);void kbd_put_string_console (QemuTextConsole *s,const char *str,int len); -void kbd_put_keysym (int keysym);/* Touch devices */ typedef struct touch_slot {ui/console.c +7
-7@@ -1141,6 +1141,13 @@ void kbd_put_keysym_console(QemuTextConsole *s, int keysym)int c;uint32_t num_free; +if (!s) { +if (!QEMU_IS_TEXT_CONSOLE (active_console)) { +return ; + } + s =QEMU_TEXT_CONSOLE (active_console); + } +switch (keysym) {case QEMU_KEY_CTRL_UP :console_scroll (s,-1 );@@ -1231,13 +1238,6 @@ void kbd_put_string_console(QemuTextConsole *s, const char *str, int len) } } -void kbd_put_keysym (int keysym) -{ -if (QEMU_IS_TEXT_CONSOLE (active_console)) { -kbd_put_keysym_console (QEMU_TEXT_CONSOLE (active_console), keysym); - } -} -static void text_console_invalidate (void *opaque) {QemuTextConsole *s =QEMU_TEXT_CONSOLE (opaque);ui/curses.c +1
-1@@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl)if (keysym ==-1 ) keysym = chr; -kbd_put_keysym (keysym); +kbd_put_keysym_console (NULL , keysym); } } }ui/vnc.c +0
-0@@ -1945,88 +1945,88 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)case 0xb8 :/* Right ALT */ break ;
Quoted 9 lines
ui/vnc.c static void do_key_event(VncState *vs, int down, int keycode, int sym) · line 1948
Quoted 3 lines
ui/vnc.c +1
-1case 0xc8 : -kbd_put_keysym (QEMU_KEY_UP ); +kbd_put_keysym_console (NULL ,QEMU_KEY_UP );
vs->vd->dcl.conshould be used instead. There may be VNC connections for consoles other than the "active console" and in such a casevs->vd->dcl.con!= NULL. Unfortunately it seems that ui/vnc is very buggy in such a situation.
That's not how the console & VNC server code works. VNC server will send the key event to the hw anyway. But if the active_console is text/vc, then it also sends (some) of the key events to it. There is no "per-client" console either, the console switch is global (console_select()).
Anyway, this patch is quite systematic. Further complicated changes should be done later. please ack/r-b
thanks
Signature · 1 line
Marc-André Lureau
Akihiko Odaki
Reviewed-byRe: [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls
Quoted 97 lines · Marc-André Lureau
Hi
Quoted 84 lines · Akihiko Odaki
Quoted 82 lines · On 2023/08/30 18:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The function calls to
kbd_put_keysymhave been updated to now callkbd_put_keysym_consolewith a NULL console parameter.Like most console functions, NULL argument is now for the active console.
This will allow to rename the text console functions in a consistent manner.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 1 - ui/console.c | 14 ++++++------ ui/curses.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 5 files changed, 36 insertions(+), 37 deletions(-)include/ui/console.h +0
-1@@ -115,7 +115,6 @@ bool qemu_mouse_set(int index, Error **errp);void kbd_put_keysym_console (QemuTextConsole *s,int keysym);bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl);void kbd_put_string_console (QemuTextConsole *s,const char *str,int len); -void kbd_put_keysym (int keysym);/* Touch devices */ typedef struct touch_slot {ui/console.c +7
-7@@ -1141,6 +1141,13 @@ void kbd_put_keysym_console(QemuTextConsole *s, int keysym)int c;uint32_t num_free; +if (!s) { +if (!QEMU_IS_TEXT_CONSOLE (active_console)) { +return ; + } + s =QEMU_TEXT_CONSOLE (active_console); + } +switch (keysym) {case QEMU_KEY_CTRL_UP :console_scroll (s,-1 );@@ -1231,13 +1238,6 @@ void kbd_put_string_console(QemuTextConsole *s, const char *str, int len) } } -void kbd_put_keysym (int keysym) -{ -if (QEMU_IS_TEXT_CONSOLE (active_console)) { -kbd_put_keysym_console (QEMU_TEXT_CONSOLE (active_console), keysym); - } -} -static void text_console_invalidate (void *opaque) {QemuTextConsole *s =QEMU_TEXT_CONSOLE (opaque);ui/curses.c +1
-1@@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl)if (keysym ==-1 ) keysym = chr; -kbd_put_keysym (keysym); +kbd_put_keysym_console (NULL , keysym); } } }ui/vnc.c +0
-0@@ -1945,88 +1945,88 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)case 0xb8 :/* Right ALT */ break ;Quoted 9 lines
ui/vnc.c static void do_key_event(VncState *vs, int down, int keycode, int sym) · line 1948
Quoted 3 lines
ui/vnc.c +1
-1case 0xc8 : -kbd_put_keysym (QEMU_KEY_UP ); +kbd_put_keysym_console (NULL ,QEMU_KEY_UP );
vs->vd->dcl.conshould be used instead. There may be VNC connections for consoles other than the "active console" and in such a casevs->vd->dcl.con!= NULL. Unfortunately it seems that ui/vnc is very buggy in such a situation.
Quoted 5 lines
That's not how the console & VNC server code works. VNC server will send the key event to the hw anyway. But if the
active_consoleis text/vc, then it also sends (some) of the key events to it. There is no "per-client" console either, the console switch is global (console_select()).
Actually vnc is capable of binding a VNC server instance to a particular console instead of active console controlled by global console_select() switch since commit 1d0d59fe29 ("vnc: allow binding servers to qemu consoles").
Quoted 3 lines
Anyway, this patch is quite systematic. Further complicated changes should be done later. please ack/r-b
I see.
Quoted 5 lines
thanks
PATCH 46/67 ui/vc: rename kbd_put → qemu_text_console functions
In reply to [email protected]From: Marc-André Lureau <[email protected]>
They are QemuTextConsole functions, let's make it clear.
--- include/ui/console.h | 6 ++--- ui/console.c | 10 ++++---- ui/curses.c | 2 +- ui/gtk.c | 6 ++--- ui/sdl2-input.c | 4 ++-- ui/sdl2.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 8 files changed, 43 insertions(+), 43 deletions(-)
include/ui/console.h +3 -3
@@ -112,9 +112,9 @@ bool qemu_mouse_set(int index, Error **errp);#define QEMU_KEY_CTRL_PAGEUP 0xe406#define QEMU_KEY_CTRL_PAGEDOWN 0xe407 -void kbd_put_keysym_console (QemuTextConsole *s,int keysym); -bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl); -void kbd_put_string_console (QemuTextConsole *s,const char *str,int len); +void qemu_text_console_put_keysym (QemuTextConsole *s,int keysym); +bool qemu_text_console_put_qcode (QemuTextConsole *s,int qcode,bool ctrl); +void qemu_text_console_put_string (QemuTextConsole *s,const char *str,int len);/* Touch devices */ typedef struct touch_slot {
ui/console.c +5 -5
@@ -1135,7 +1135,7 @@ static void kbd_send_chars(QemuTextConsole *s) }/* called when an ascii key is pressed */ -void kbd_put_keysym_console (QemuTextConsole *s,int keysym) +void qemu_text_console_put_keysym (QemuTextConsole *s,int keysym) {uint8_t buf[16 ], *q;int c;
@@ -1217,7 +1217,7 @@ static const int ctrl_qcode_to_keysym[Q_KEY_CODE__MAX] = { [Q_KEY_CODE_PGDN] = QEMU_KEY_CTRL_PAGEDOWN, }; -bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl) +bool qemu_text_console_put_qcode (QemuTextConsole *s,int qcode,bool ctrl) {int keysym;
@@ -1225,16 +1225,16 @@ bool kbd_put_qcode_console(QemuTextConsole *s, int qcode, bool ctrl)if (keysym ==0 ) {return false; } -kbd_put_keysym_console (s, keysym); +qemu_text_console_put_keysym (s, keysym);return true; } -void kbd_put_string_console (QemuTextConsole *s,const char *str,int len) +void qemu_text_console_put_string (QemuTextConsole *s,const char *str,int len) {int i;for (i =0 ; i < len && str[i]; i++) { -kbd_put_keysym_console (s, str[i]); +qemu_text_console_put_keysym (s, str[i]); } }
ui/curses.c +1 -1
@@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl)if (keysym ==-1 ) keysym = chr; -kbd_put_keysym_console (NULL , keysym); +qemu_text_console_put_keysym (NULL , keysym); } } }
ui/gtk.c +3 -3
@@ -1190,12 +1190,12 @@ static gboolean gd_text_key_down(GtkWidget *widget,QemuTextConsole *con =QEMU_TEXT_CONSOLE (vc->gfx.dcl.con);if (key->keyval == GDK_KEY_Delete) { -kbd_put_qcode_console (con,Q_KEY_CODE_DELETE , false); +qemu_text_console_put_qcode (con,Q_KEY_CODE_DELETE , false); }else if (key->length) { -kbd_put_string_console (con, key->string, key->length); +qemu_text_console_put_string (con, key->string, key->length); }else {int qcode =gd_map_keycode (gd_get_keycode (key)); -kbd_put_qcode_console (con, qcode, false); +qemu_text_console_put_qcode (con, qcode, false); }return TRUE; }
ui/sdl2-input.c +2 -2
@@ -49,10 +49,10 @@ void sdl2_process_key(struct sdl2_console *scon,if (ev->type ==SDL_KEYDOWN ) {switch (qcode) {case Q_KEY_CODE_RET : -kbd_put_keysym_console (s,'\n' ); +qemu_text_console_put_keysym (s,'\n' );break ;default : -kbd_put_qcode_console (s, qcode, ctrl); +qemu_text_console_put_qcode (s, qcode, ctrl);break ; } }
ui/sdl2.c +1 -1
@@ -484,7 +484,7 @@ static void handle_textinput(SDL_Event *ev) }if (QEMU_IS_TEXT_CONSOLE (con)) { -kbd_put_string_console (QEMU_TEXT_CONSOLE (con), ev->text.text,strlen (ev->text.text)); +qemu_text_console_put_string (QEMU_TEXT_CONSOLE (con), ev->text.text,strlen (ev->text.text)); } }
ui/vnc.c +27 -27
115 lines not on this page · raw message
ui/cocoa.m +1 -1
@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } if (keysym) { - kbd_put_keysym_console(NULL, keysym); + qemu_text_console_keysym(NULL, keysym); } }
Signature · 1 line
2.41.0
Re: [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions
Quoted 37 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
They are QemuTextConsole functions, let's make it clear.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 6 ++--- ui/console.c | 10 ++++---- ui/curses.c | 2 +- ui/gtk.c | 6 ++--- ui/sdl2-input.c | 4 ++-- ui/sdl2.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 8 files changed, 43 insertions(+), 43 deletions(-)include/ui/console.h +3
-3@@ -112,9 +112,9 @@ bool qemu_mouse_set(int index, Error **errp);#define QEMU_KEY_CTRL_PAGEUP 0xe406#define QEMU_KEY_CTRL_PAGEDOWN 0xe407 -void kbd_put_keysym_console (QemuTextConsole *s,int keysym); -bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl); -void kbd_put_string_console (QemuTextConsole *s,const char *str,int len); +void qemu_text_console_put_keysym (QemuTextConsole *s,int keysym); +bool qemu_text_console_put_qcode (QemuTextConsole *s,int qcode,bool ctrl); +void qemu_text_console_put_string (QemuTextConsole *s,const char *str,int len);ui/cocoa.m +0
-0
ui/cocoa.m - (void) handleMonitorInput:(NSEvent *)event · line 790
Quoted 8 lines
ui/cocoa.m +1
-1@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } if (keysym) { - kbd_put_keysym_console(NULL, keysym); + qemu_text_console_keysym(NULL, keysym); } }
../../ui/cocoa.m:787:9: error: call to undeclared function 'qemu_text_console_keysym'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
qemu_text_console_keysym(NULL, keysym);
^I can compile using:
-- >8 --
ui/cocoa.m +1 -1
@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } if (keysym) { - qemu_text_console_keysym(NULL, keysym); + qemu_text_console_put_keysym(NULL, keysym); } }
---
Daniel P. Berrangé
Reviewed-byRe: [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions
Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 36 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
They are QemuTextConsole functions, let's make it clear.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 6 ++--- ui/console.c | 10 ++++---- ui/curses.c | 2 +- ui/gtk.c | 6 ++--- ui/sdl2-input.c | 4 ++-- ui/sdl2.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 8 files changed, 43 insertions(+), 43 deletions(-)include/ui/console.h +3
-3@@ -112,9 +112,9 @@ bool qemu_mouse_set(int index, Error **errp);#define QEMU_KEY_CTRL_PAGEUP 0xe406#define QEMU_KEY_CTRL_PAGEDOWN 0xe407 -void kbd_put_keysym_console (QemuTextConsole *s,int keysym); -bool kbd_put_qcode_console (QemuTextConsole *s,int qcode,bool ctrl); -void kbd_put_string_console (QemuTextConsole *s,const char *str,int len); +void qemu_text_console_put_keysym (QemuTextConsole *s,int keysym); +bool qemu_text_console_put_qcode (QemuTextConsole *s,int qcode,bool ctrl); +void qemu_text_console_put_string (QemuTextConsole *s,const char *str,int len);ui/cocoa.m +0
-0ui/cocoa.m - (void) handleMonitorInput:(NSEvent *)event · line 788
Quoted 6 lines
ui/cocoa.m +1
-1@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } if (keysym) { - kbd_put_keysym_console(NULL, keysym); + qemu_text_console_keysym(NULL, keysym); } }../../ui/cocoa.m:787:9: error: call to undeclared function '
qemu_text_console_keysym'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]qemu_text_console_keysym(NULL, keysym); ^I can compile using:
-- >8 --
ui/cocoa.m +0
-0
ui/cocoa.m - (void) handleMonitorInput:(NSEvent *)event · line 789
Quoted 7 lines
ui/cocoa.m +1
-1@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } if (keysym) { - qemu_text_console_keysym(NULL, keysym); + qemu_text_console_put_keysym(NULL, keysym); } }
With that change added
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 :|
PATCH 47/67 ui/console: remove redundant format field
In reply to [email protected]From: Marc-André Lureau <[email protected]>
It's already part of PIXMAN image.
--- include/ui/console.h | 15 +++++++-------- ui/console-gl.c | 2 +- ui/console.c | 4 +--- ui/gtk.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.c | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-)
include/ui/console.h +7 -8
@@ -152,7 +152,6 @@ typedef struct ScanoutTexture { } ScanoutTexture; typedef struct DisplaySurface { - pixman_format_code_t format; pixman_image_t *image; uint8_t flags; #ifdef CONFIG_OPENGL
@@ -436,23 +435,23 @@ static inline int surface_height(DisplaySurface *s)return pixman_image_get_height (s->image); } +static inline pixman_format_code_t surface_format (DisplaySurface *s) +{ +return pixman_image_get_format (s->image); +} +static inline int surface_bits_per_pixel (DisplaySurface *s) { -int bits =PIXMAN_FORMAT_BPP (s->format); +int bits =PIXMAN_FORMAT_BPP (surface_format (s));return bits; }static inline int surface_bytes_per_pixel (DisplaySurface *s) { -int bits =PIXMAN_FORMAT_BPP (s->format); +int bits =PIXMAN_FORMAT_BPP (surface_format (s));return DIV_ROUND_UP (bits,8 ); } -static inline pixman_format_code_t surface_format (DisplaySurface *s) -{ -return s->format; -} -typedef uint32_t console_ch_t ;static inline void console_write_ch (console_ch_t *dest,uint32_t ch)
ui/console-gl.c +1 -1
@@ -53,7 +53,7 @@ void surface_gl_create_texture(QemuGLShader *gls,return ; } -switch (surface->format) { +switch (surface_format (surface)) {case PIXMAN_BE_b8g8r8x8:case PIXMAN_BE_b8g8r8a8: surface->glformat =GL_BGRA_EXT ;
ui/console.c +1 -3
@@ -1493,8 +1493,7 @@ DisplaySurface *qemu_create_displaysurface_from(int width, int height,DisplaySurface *surface =g_new0 (DisplaySurface,1 );trace_displaysurface_create_from (surface, width, height, format); - surface->format = format; - surface->image =pixman_image_create_bits (surface->format, + surface->image =pixman_image_create_bits (format, width, height, (void *)data, linesize);assert (surface->image !=NULL );
@@ -1511,7 +1510,6 @@ DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image)DisplaySurface *surface =g_new0 (DisplaySurface,1 );trace_displaysurface_create_pixman (surface); - surface->format =pixman_image_get_format (image); surface->image =pixman_image_ref (image);return surface;
ui/gtk.c +1 -1
@@ -514,7 +514,7 @@ static void gd_switch(DisplayChangeListener *dcl, } vc->gfx.ds = surface; -if (surface->format == PIXMAN_x8r8g8b8) { +if (surface_format (surface) == PIXMAN_x8r8g8b8) {/* * PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24 *
ui/spice-display.c +1 -1
@@ -436,7 +436,7 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, }if (ssd->ds) { ssd->surface =pixman_image_ref (ssd->ds->image); - ssd->mirror =qemu_pixman_mirror_create (ssd->ds->format, + ssd->mirror =qemu_pixman_mirror_create (surface_format (ssd->ds), ssd->ds->image);qemu_spice_create_host_primary (ssd); }
ui/vnc.c +1 -1
@@ -833,7 +833,7 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,/* guest surface */ qemu_pixman_image_unref (vd->guest.fb); vd->guest.fb =pixman_image_ref (surface->image); - vd->guest.format = surface->format; + vd->guest.format =surface_format (surface);if (pageflip) {
Signature · 1 line
2.41.0
Re: [PATCH 47/67] ui/console: remove redundant format field
Quoted 5 lines · On Wed, Aug 30, 2023 at 01:38:21PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
It's already part of PIXMAN image.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 8 lines
--- include/ui/console.h | 15 +++++++-------- ui/console-gl.c | 2 +- ui/console.c | 4 +--- ui/gtk.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.c | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-)
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 :|
PATCH 48/67 ui/vc: preliminary QemuTextConsole changes before split
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Those changes will help to split console.c unit in the following commit.
--- ui/console.c | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-)
ui/console.c +35 -17
@@ -174,7 +174,7 @@ static QEMUTimer *cursor_timer;static void dpy_refresh (DisplayState *s);static DisplayState *get_alloc_displaystate (void ); -static void text_console_update_cursor (void *opaque); +static void qemu_text_console_update_cursor (void *opaque);static bool displaychangelistener_has_dmabuf (DisplayChangeListener *dcl);static bool console_compatible_with (QemuConsole *con,DisplayChangeListener *dcl,Error **errp);
@@ -1065,6 +1065,13 @@ static void displaychangelistener_display_console(DisplayChangeListener *dcl, } } +static void +qemu_text_console_select (QemuTextConsole *c) +{ +dpy_text_resize (QEMU_CONSOLE (c), c->width, c->height); +qemu_text_console_update_cursor (NULL ); +} +void console_select (unsigned int index) {DisplayChangeListener *dcl;
@@ -1084,8 +1091,7 @@ void console_select(unsigned int index) }if (QEMU_IS_TEXT_CONSOLE (s)) { -dpy_text_resize (s,QEMU_TEXT_CONSOLE (s)->width,QEMU_TEXT_CONSOLE (s)->height); -text_console_update_cursor (NULL ); +qemu_text_console_select (QEMU_TEXT_CONSOLE (s)); } } }
@@ -1135,19 +1141,12 @@ static void kbd_send_chars(QemuTextConsole *s) }/* called when an ascii key is pressed */ -void qemu_text_console_put_keysym (QemuTextConsole *s,int keysym) +static void qemu_text_console_handle_keysym (QemuTextConsole *s,int keysym) {uint8_t buf[16 ], *q;int c;uint32_t num_free; -if (!s) { -if (!QEMU_IS_TEXT_CONSOLE (active_console)) { -return ; - } - s =QEMU_TEXT_CONSOLE (active_console); - } -switch (keysym) {case QEMU_KEY_CTRL_UP :console_scroll (s,-1 );
@@ -1192,6 +1191,18 @@ void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym) } } +void qemu_text_console_put_keysym (QemuTextConsole *s,int keysym) +{ +if (!s) { +if (!QEMU_IS_TEXT_CONSOLE (active_console)) { +return ; + } + s =QEMU_TEXT_CONSOLE (active_console); + } + +qemu_text_console_handle_keysym (s, keysym); +} +static const int qcode_to_keysym[Q_KEY_CODE__MAX ] = { [Q_KEY_CODE_UP ] =QEMU_KEY_UP , [Q_KEY_CODE_DOWN ] =QEMU_KEY_DOWN ,
@@ -1395,7 +1406,7 @@ 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 ); + qemu_text_console_update_cursor,NULL ); } }
@@ -1701,7 +1712,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)if (QEMU_IS_GRAPHIC_CONSOLE (con)) {dcl_set_graphic_cursor (dcl,QEMU_GRAPHIC_CONSOLE (con)); } -text_console_update_cursor (NULL ); +qemu_text_console_update_cursor (NULL ); } void update_displaychangelistener(DisplayChangeListener *dcl,
@@ -2388,6 +2399,13 @@ bool qemu_console_is_multihead(DeviceState *dev)return false; } + +static const char * +qemu_text_console_get_label (QemuTextConsole *c) +{ +return c->chr ? c->chr->label :NULL ; +} +char *qemu_console_get_label (QemuConsole *con) {if (QEMU_IS_GRAPHIC_CONSOLE (con)) {
@@ -2411,9 +2429,9 @@ char *qemu_console_get_label(QemuConsole *con) }return g_strdup ("VGA" ); }else if (QEMU_IS_TEXT_CONSOLE (con)) { -QemuTextConsole *c =QEMU_TEXT_CONSOLE (con); -if (c->chr && c->chr->label) { -return g_strdup (c->chr->label); +const char *label =qemu_text_console_get_label (QEMU_TEXT_CONSOLE (con)); +if (label) { +return g_strdup (label); } }
@@ -2513,7 +2531,7 @@ int qemu_invalidate_text_consoles(void)return count; } -static void text_console_update_cursor (void *opaque) +static void qemu_text_console_update_cursor (void *opaque) { cursor_visible_phase = !cursor_visible_phase;
Signature · 1 line
2.41.0
Re: [PATCH 48/67] ui/vc: preliminary QemuTextConsole changes before split
Quoted 8 lines · On Wed, Aug 30, 2023 at 01:38:22PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Those changes will help to split
console.cunit in the following commit.Signed-off-by Marc-André Lureau <[email protected]>--- ui/console.c | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-)
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 :|
PATCH 49/67 ui/vc: split off the VC part from console.c
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Move common declarations to console-priv.h, and add a new unit console-vc.c which will handle VC/chardev rendering, when pixman is available.
(if necessary, the move could be done chunk by chunks)
--- ui/console-priv.h | 43 ++ ui/console-vc.c | 1079 ++++++++++++++++++++++++++++++++++++++++++++ ui/console.c | 1096 +-------------------------------------------- ui/meson.build | 1 + 4 files changed, 1126 insertions(+), 1093 deletions(-) create mode 100644 ui/console-priv.h create mode 100644 ui/console-vc.c
ui/console-priv.h new file +43 -0
@@ -0,0 +1,43 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU UI Console +*/ +#ifndef CONSOLE_PRIV_H +#define CONSOLE_PRIV_H + +#include "ui/console.h" +#include "qemu/coroutine.h" +#include "qemu/timer.h" + +#include "vgafont.h" + +#define FONT_HEIGHT 16 +#define FONT_WIDTH 8 + +struct QemuConsole { +Object parent; + +int index; +DisplayState *ds; +DisplaySurface *surface; +DisplayScanout scanout; +int dcls; +DisplayGLCtx *gl; +int gl_block; +QEMUTimer *gl_unblock_timer; +int window_id; +QemuUIInfo ui_info; +QEMUTimer *ui_timer; +const GraphicHwOps *hw_ops; +void *hw; +CoQueue dump_queue; + +QTAILQ_ENTRY (QemuConsole) next; +}; + +void qemu_text_console_select (QemuTextConsole *c); +const char *qemu_text_console_get_label (QemuTextConsole *c); +void qemu_text_console_update_cursor (void ); +void qemu_text_console_handle_keysym (QemuTextConsole *s,int keysym); + +#endif
ui/console-vc.c new file +1079 -0
1,079 lines not on this page · raw message
ui/console.c +3 -1093
1,189 lines not on this page · raw message
ui/meson.build +1 -0
@@ -6,6 +6,7 @@ system_ss.add(png) system_ss.add(files( 'clipboard.c', 'console.c', + 'console-vc.c', 'cursor.c', 'input-keymap.c', 'input-legacy.c',
Signature · 1 line
2.41.0
Re: [PATCH 49/67] ui/vc: split off the VC part from console.c
Quoted 24 lines · On Wed, Aug 30, 2023 at 01:38:23PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Move common declarations to
console-priv.h, and add a new unitconsole-vc.cwhich will handle VC/chardev rendering, when pixman is available.(if necessary, the move could be done chunk by chunks)
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console-priv.h | 43 ++ ui/console-vc.c | 1079 ++++++++++++++++++++++++++++++++++++++++++++ ui/console.c | 1096 +-------------------------------------------- ui/meson.build | 1 + 4 files changed, 1126 insertions(+), 1093 deletions(-) create mode 100644 ui/console-priv.h create mode 100644 ui/console-vc.cui/console-vc.c new file +0
-0
ui/console-vc.c line 3
Quoted 3 lines
ui/console-vc.c new file +3
-0@@ -0,0 +1,1079 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC
This code is moved out of console.c, which (surprisingly) appears to have an MIT license header.
The include/ui/console.h header meanwhile has no license, so is valid to assume it is GPL-2.0-or-later I guess.
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 :|
Re: [PATCH 49/67] ui/vc: split off the VC part from console.c
Hi
Quoted 20 lines · Daniel P. Berrangé
Quoted 18 lines · On Wed, Aug 30, 2023 at 01:38:23PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Move common declarations to
console-priv.h, and add a new unitconsole-vc.cwhich will handle VC/chardev rendering, when pixman is available.(if necessary, the move could be done chunk by chunks)
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console-priv.h | 43 ++ ui/console-vc.c | 1079 ++++++++++++++++++++++++++++++++++++++++++++ ui/console.c | 1096 +-------------------------------------------- ui/meson.build | 1 + 4 files changed, 1126 insertions(+), 1093 deletions(-) create mode 100644 ui/console-priv.h create mode 100644 ui/console-vc.c
Quoted 13 lines
ui/console-vc.c line 3
Quoted 9 lines
ui/console-vc.c new file +3
-0@@ -0,0 +1,1079 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC This code is moved out of
console.c, which (surprisingly) appears to have an MIT license header.
updated
Quoted 4 lines
The
include/ui/console.hheader meanwhile has no license, so is valid to assume it is GPL-2.0-or-later I guess.
Do you think I should split this patch in multiple patches? or can you r-b it with the license change?
thanks
Signature · 1 line
Marc-André Lureau
Daniel P. Berrangé
Reviewed-byRe: [PATCH 49/67] ui/vc: split off the VC part from console.c
Quoted 40 lines · Marc-André Lureau
Hi
Quoted 20 lines · Daniel P. Berrangé
Quoted 18 lines · On Wed, Aug 30, 2023 at 01:38:23PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Move common declarations to
console-priv.h, and add a new unitconsole-vc.cwhich will handle VC/chardev rendering, when pixman is available.(if necessary, the move could be done chunk by chunks)
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console-priv.h | 43 ++ ui/console-vc.c | 1079 ++++++++++++++++++++++++++++++++++++++++++++ ui/console.c | 1096 +-------------------------------------------- ui/meson.build | 1 + 4 files changed, 1126 insertions(+), 1093 deletions(-) create mode 100644 ui/console-priv.h create mode 100644 ui/console-vc.cQuoted 13 lines
ui/console-vc.c line 3
Quoted 9 lines
ui/console-vc.c new file +3
-0@@ -0,0 +1,1079 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC This code is moved out of
console.c, which (surprisingly) appears to have an MIT license header.updated
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
The
include/ui/console.hheader meanwhile has no license, so is valid to assume it is GPL-2.0-or-later I guess.Do you think I should split this patch in multiple patches? or can you r-b it with the license change?
No need to split IMHO. With the MIT license for the .c file,
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 :|
PATCH 50/67 ui/console: move DisplaySurface to its own header
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Mostly for readability reasons.
--- include/ui/console.h | 84 +--------------------------------------- include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 83 deletions(-) create mode 100644 include/ui/surface.h
include/ui/console.h +1 -83
@@ -6,11 +6,7 @@#include "qemu/notify.h" #include "qapi/qapi-types-ui.h" #include "ui/input.h" - -#ifdef CONFIG_OPENGL -# include <epoxy/gl.h> -# include "ui/shader.h" -#endif +#include "ui/surface.h" #define TYPE_QEMU_CONSOLE "qemu-console"OBJECT_DECLARE_TYPE (QemuConsole, QemuConsoleClass,QEMU_CONSOLE )
@@ -136,9 +132,6 @@ struct QemuConsoleClass {ObjectClass parent_class; }; -#define QEMU_ALLOCATED_FLAG 0x01 -#define QEMU_PLACEHOLDER_FLAG 0x02 - typedef struct ScanoutTexture { uint32_t backing_id; bool backing_y_0_top;
@@ -151,20 +144,6 @@ typedef struct ScanoutTexture {void *d3d_tex2d; } ScanoutTexture; -typedef struct DisplaySurface { -pixman_image_t *image; -uint8_t flags; -#ifdef CONFIG_OPENGL -GLenum glformat; -GLenum gltype; -GLuint texture; -#endif -#ifdef WIN32 -HANDLE handle; -uint32_t handle_offset; -#endif -}DisplaySurface ; - typedef struct QemuUIInfo { /* physical dimension */ uint16_t width_mm;
@@ -344,30 +323,6 @@ struct DisplayGLCtx { };DisplayState *init_displaystate (void ); -DisplaySurface *qemu_create_displaysurface_from (int width,int height, -pixman_format_code_t format, -int linesize,uint8_t *data); -DisplaySurface *qemu_create_displaysurface_pixman (pixman_image_t *image); -DisplaySurface *qemu_create_placeholder_surface (int w,int h, -const char *msg); -#ifdef WIN32 -void qemu_displaysurface_win32_set_handle (DisplaySurface *surface, -HANDLE h,uint32_t offset); -#endif -PixelFormat qemu_default_pixelformat (int bpp); - -DisplaySurface *qemu_create_displaysurface (int width,int height); -void qemu_free_displaysurface (DisplaySurface *surface); - -static inline int is_buffer_shared (DisplaySurface *surface) -{ -return !(surface->flags &QEMU_ALLOCATED_FLAG ); -} - -static inline int is_placeholder (DisplaySurface *surface) -{ -return surface->flags &QEMU_PLACEHOLDER_FLAG ; -}void register_displaychangelistener (DisplayChangeListener *dcl); void update_displaychangelistener(DisplayChangeListener *dcl,
@@ -415,43 +370,6 @@ int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx);bool console_has_gl (QemuConsole *con); -static inline int surface_stride (DisplaySurface *s) -{ -return pixman_image_get_stride (s->image); -} - -static inline void *surface_data (DisplaySurface *s) -{ -return pixman_image_get_data (s->image); -} - -static inline int surface_width (DisplaySurface *s) -{ -return pixman_image_get_width (s->image); -} - -static inline int surface_height (DisplaySurface *s) -{ -return pixman_image_get_height (s->image); -} - -static inline pixman_format_code_t surface_format (DisplaySurface *s) -{ -return pixman_image_get_format (s->image); -} - -static inline int surface_bits_per_pixel (DisplaySurface *s) -{ -int bits =PIXMAN_FORMAT_BPP (surface_format (s)); -return bits; -} - -static inline int surface_bytes_per_pixel (DisplaySurface *s) -{ -int bits =PIXMAN_FORMAT_BPP (surface_format (s)); -return DIV_ROUND_UP (bits,8 ); -} -typedef uint32_t console_ch_t ;static inline void console_write_ch (console_ch_t *dest,uint32_t ch)
include/ui/surface.h new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH 50/67] ui/console: move DisplaySurface to its own header
include/ui/surface.h
Quoted 18 lines · On Wed, Aug 30, 2023 at 01:38:24PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Mostly for readability reasons.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 84 +--------------------------------------- include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 83 deletions(-) create mode 100644 include/ui/surface.hinclude/ui/surface.h new file +0
-0@@ -0,0 +1,91 @@
When you moved the VC bits out of console.h you added a GPL-2.0-or-later SPDX tag, so by implication this ought to gain the same.
Quoted 95 lines
include/ui/surface.h new file +91
-0+#ifndef SURFACE_H +#define SURFACE_H + +#include "ui/qemu-pixman.h" + +#ifdef CONFIG_OPENGL +# include <epoxy/gl.h> +# include "ui/shader.h" +#endif + +#define QEMU_ALLOCATED_FLAG 0x01 +#define QEMU_PLACEHOLDER_FLAG 0x02 + +typedef struct DisplaySurface { +pixman_image_t *image; +uint8_t flags; +#ifdef CONFIG_OPENGL +GLenum glformat; +GLenum gltype; +GLuint texture; +#endif +#ifdef WIN32 +HANDLE handle; +uint32_t handle_offset; +#endif +}DisplaySurface ; + +PixelFormat qemu_default_pixelformat (int bpp); + +DisplaySurface *qemu_create_displaysurface_from (int width,int height, +pixman_format_code_t format, +int linesize,uint8_t *data); +DisplaySurface *qemu_create_displaysurface_pixman (pixman_image_t *image); +DisplaySurface *qemu_create_placeholder_surface (int w,int h, +const char *msg); +#ifdef WIN32 +void qemu_displaysurface_win32_set_handle (DisplaySurface *surface, +HANDLE h,uint32_t offset); +#endif + +DisplaySurface *qemu_create_displaysurface (int width,int height); +void qemu_free_displaysurface (DisplaySurface *surface); + +static inline int is_buffer_shared (DisplaySurface *surface) +{ +return !(surface->flags &QEMU_ALLOCATED_FLAG ); +} + +static inline int is_placeholder (DisplaySurface *surface) +{ +return surface->flags &QEMU_PLACEHOLDER_FLAG ; +} + +static inline int surface_stride (DisplaySurface *s) +{ +return pixman_image_get_stride (s->image); +} + +static inline void *surface_data (DisplaySurface *s) +{ +return pixman_image_get_data (s->image); +} + +static inline int surface_width (DisplaySurface *s) +{ +return pixman_image_get_width (s->image); +} + +static inline int surface_height (DisplaySurface *s) +{ +return pixman_image_get_height (s->image); +} + +static inline pixman_format_code_t surface_format (DisplaySurface *s) +{ +return pixman_image_get_format (s->image); +} + +static inline int surface_bits_per_pixel (DisplaySurface *s) +{ +int bits =PIXMAN_FORMAT_BPP (surface_format (s)); +return bits; +} + +static inline int surface_bytes_per_pixel (DisplaySurface *s) +{ +int bits =PIXMAN_FORMAT_BPP (surface_format (s)); +return DIV_ROUND_UP (bits,8 ); +} + +#endif Signature · 1 line
2.41.0
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 :|
Re: [PATCH 50/67] ui/console: move DisplaySurface to its own header
Hi
Quoted 14 lines · Daniel P. Berrangé
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:38:24PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Mostly for readability reasons.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 84 +--------------------------------------- include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 83 deletions(-) create mode 100644 include/ui/surface.h
Quoted 10 lines
include/ui/surface.h
Quoted 6 lines
include/ui/surface.h new file +0
-0@@ -0,0 +1,91 @@When you moved the VC bits out of
console.hyou added a GPL-2.0-or-later SPDX tag, so by implication this ought to gain the same.
Done. R-B with that change?
Signature · 1 line
Marc-André Lureau
Re: [PATCH 50/67] ui/console: move DisplaySurface to its own header
Quoted 29 lines · Marc-André Lureau
Hi
Quoted 14 lines · Daniel P. Berrangé
Quoted 11 lines · On Wed, Aug 30, 2023 at 01:38:24PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Mostly for readability reasons.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/console.h | 84 +--------------------------------------- include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 83 deletions(-) create mode 100644 include/ui/surface.hQuoted 10 lines
include/ui/surface.h
Quoted 6 lines
include/ui/surface.h new file +0
-0@@ -0,0 +1,91 @@When you moved the VC bits out of
console.hyou added a GPL-2.0-or-later SPDX tag, so by implication this ought to gain the same.
Quoted 1 line
Done. R-B with that change?
Yep, Reviewed-by: Daniel P. Berrangé <[email protected]> with the GPL-2.0-or-later addition
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 :|
PATCH 51/67 build-sys: add optional "pixman" feature
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Set CONFIG_PIXMAN accordinly.
--- meson.build | 6 ++++-- Kconfig.host | 3 +++ meson_options.txt | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-)
meson.build +4 -2
@@ -836,8 +836,8 @@ if 'ust' in get_option('trace_backends') method: 'pkg-config') endif pixman = not_found -if have_system or have_tools - pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8', +if not get_option('pixman').auto() or have_system or have_tools + pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8', method: 'pkg-config') endif zlib = dependency('zlib', required: true)
@@ -2126,6 +2126,7 @@ config_host_data.set('CONFIG_SECCOMP', seccomp.found()) if seccomp.found() config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc) endif +config_host_data.set('CONFIG_PIXMAN', pixman.found()) config_host_data.set('CONFIG_SNAPPY', snappy.found()) config_host_data.set('CONFIG_TPM', have_tpm) config_host_data.set('CONFIG_TSAN', get_option('tsan'))
@@ -2833,6 +2834,7 @@ have_ivshmem = config_host_data.get('CONFIG_EVENTFD') host_kconfig = \ (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \ (have_tpm ? ['CONFIG_TPM=y'] : []) + \ + (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \ (spice.found() ? ['CONFIG_SPICE=y'] : []) + \ (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \ (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \
Kconfig.host +3 -0
@@ -11,6 +11,9 @@ config OPENGL config X11 bool +config PIXMAN + bool + config SPICE bool
meson_options.txt +2 -0
@@ -216,6 +216,8 @@ option('l2tpv3', type : 'feature', value : 'auto', description: 'l2tpv3 network backend support') option('netmap', type : 'feature', value : 'auto', description: 'netmap network backend support') +option('pixman', type : 'feature', value : 'auto', + description: 'pixman support') option('slirp', type: 'feature', value: 'auto', description: 'libslirp user mode network backend support') option('vde', type : 'feature', value : 'auto',
Signature · 1 line
2.41.0
Re: [PATCH 51/67] build-sys: add optional "pixman" feature
Quoted 61 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Set
CONFIG_PIXMANaccordinly.Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 6 ++++-- Kconfig.host | 3 +++ meson_options.txt | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-)meson.build +4
-2@@ -836,8 +836,8 @@ if 'ust' in get_option('trace_backends') method: 'pkg-config') endif pixman = not_found -if have_system or have_tools - pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8', +if not get_option('pixman').auto() or have_system or have_tools + pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8', method: 'pkg-config') endif zlib = dependency('zlib', required: true)@@ -2126,6 +2126,7 @@ config_host_data.set('CONFIG_SECCOMP', seccomp.found()) if seccomp.found() config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc) endif +config_host_data.set('CONFIG_PIXMAN', pixman.found()) config_host_data.set('CONFIG_SNAPPY', snappy.found()) config_host_data.set('CONFIG_TPM', have_tpm) config_host_data.set('CONFIG_TSAN', get_option('tsan'))@@ -2833,6 +2834,7 @@ have_ivshmem = config_host_data.get('CONFIG_EVENTFD') host_kconfig = \ (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \ (have_tpm ? ['CONFIG_TPM=y'] : []) + \ + (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \ (spice.found() ? ['CONFIG_SPICE=y'] : []) + \ (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \ (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \Kconfig.host +3
-0@@ -11,6 +11,9 @@ config OPENGL config X11 bool +config PIXMAN + bool + config SPICE boolmeson_options.txt +0
-0
meson_options.txt option('l2tpv3', type : 'feature', value : 'auto', · line 223
Quoted 8 lines
meson_options.txt +2
-0@@ -216,6 +216,8 @@ option('l2tpv3', type : 'feature', value : 'auto', description: 'l2tpv3 network backend support') option('netmap', type : 'feature', value : 'auto', description: 'netmap network backend support') +option('pixman', type : 'feature', value : 'auto', + description: 'pixman support') option('slirp', type: 'feature', value: 'auto', description: 'libslirp user mode network backend support') option('vde', type : 'feature', value : 'auto',
Apparently missing:
-- >8 --
scripts/meson-buildoptions.sh +3 -0
@@ -146,6 +146,7 @@ meson_options_help() { printf "%s\n" ' pa PulseAudio sound support' printf "%s\n" ' parallels parallels image format support' printf "%s\n" ' pipewire PipeWire sound support' + printf "%s\n" ' pixman pixman support' printf "%s\n" ' png PNG support with libpng' printf "%s\n" ' pvrdma Enable PVRDMA support' printf "%s\n" ' qcow1 qcow1 image format support'
@@ -397,6 +398,8 @@ _meson_option_parse() { --disable-parallels) printf "%s" -Dparallels=disabled ;; --enable-pipewire) printf "%s" -Dpipewire=enabled ;; --disable-pipewire) printf "%s" -Dpipewire=disabled ;; + --enable-pixman) printf "%s" -Dpixman=enabled ;; + --disable-pixman) printf "%s" -Dpixman=disabled ;; --with-pkgversion=*) quote_sh "-Dpkgversion=$2" ;; --enable-png) printf "%s" -Dpng=enabled ;; --disable-png) printf "%s" -Dpng=disabled ;;
---
Re: [PATCH 51/67] build-sys: add optional "pixman" feature
Quoted 59 lines · Philippe Mathieu-Daudé
Quoted 33 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Set
CONFIG_PIXMANaccordinly.Signed-off-by Marc-André Lureau <[email protected]>---
meson.build | 6 ++++--
Kconfig.host| 3 +++
meson_options.txt | 2 ++3 files changed, 9 insertions(+), 2 deletions(-)meson.build +0
-0@@ -836,8 +836,8 @@ if 'ust' in get_option('trace_backends') method: 'pkg-config')endif
pixman =not_found
-ifhave_systemorhave_tools
- pixman = dependency('pixman-1', required:have_system, version:'>=0.21.8',
+if not get_option('pixman').auto() orhave_systemorhave_tools+ pixman = dependency('pixman-1', required:get_option('pixman'), version:'>=0.21.8',
method: 'pkg-config')meson_options.txt +0
-0meson_options.txt option('l2tpv3', type : 'feature', value : 'auto', · line 223
Quoted 8 lines
meson_options.txt +2
-0@@ -216,6 +216,8 @@ option('l2tpv3', type : 'feature', value : 'auto', description: 'l2tpv3 network backend support') option('netmap', type : 'feature', value : 'auto', description: 'netmap network backend support') +option('pixman', type : 'feature', value : 'auto', + description: 'pixman support') option('slirp', type: 'feature', value: 'auto', description: 'libslirp user mode network backend support') option('vde', type : 'feature', value : 'auto',Apparently missing:
-- >8 --
scripts/meson-buildoptions.sh +1
-0@@ -146,6 +146,7 @@ meson_options_help() { printf "%s\n" ' pa PulseAudio sound support' printf "%s\n" ' parallels parallels image format support' printf "%s\n" ' pipewire PipeWire sound support' + printf "%s\n" ' pixman pixman support' printf "%s\n" ' png PNG support with libpng' printf "%s\n" ' pvrdma Enable PVRDMA support' printf "%s\n" ' qcow1 qcow1 image format support'
scripts/meson-buildoptions.sh _meson_option_parse() {
Quoted 9 lines
scripts/meson-buildoptions.sh +2
-1@@ -397,6 +398,8 @@ _meson_option_parse() { --disable-parallels) printf "%s" -Dparallels=disabled ;; --enable-pipewire) printf "%s" -Dpipewire=enabled ;; --disable-pipewire) printf "%s" -Dpipewire=disabled ;; + --enable-pixman) printf "%s" -Dpixman=enabled ;; + --disable-pixman) printf "%s" -Dpixman=disabled ;; --with-pkgversion=*) quote_sh "-Dpkgversion=$2" ;; --enable-png) printf "%s" -Dpng=enabled ;; --disable-png) printf "%s" -Dpng=disabled ;; ---
Many files fail to build when using --disable-pixman here:
[39/51] Compiling C object libcommon.fa.p/ui_curses.c.o
FAILED: libcommon.fa.p/ui_curses.c.o
In file included from ../../ui/curses.c:37:
In file included from include/ui/console.h:4:include/ui/qemu-pixman.h:12:10: fatal error: 'pixman.h' file not found
#include <pixman.h>
^~~~~~~~~~Full list:
$ ninja libcommon.fa -k 0 2>&1 | grep -F FAILED FAILED: libcommon.fa.p/ui_input-legacy.c.o FAILED: libcommon.fa.p/ui_cursor.c.o FAILED: libcommon.fa.p/ui_qemu-pixman.c.o FAILED: libcommon.fa.p/ui_kbd-state.c.o FAILED: libcommon.fa.p/ui_input.c.o FAILED: libcommon.fa.p/ui_ui-qmp-cmds.c.o FAILED: libcommon.fa.p/ui_console.c.o FAILED: libcommon.fa.p/ui_vdagent.c.o FAILED: libcommon.fa.p/ui_console-vc.c.o FAILED: libcommon.fa.p/ui_ui-hmp-cmds.c.o FAILED: libcommon.fa.p/ui_util.c.o FAILED: libcommon.fa.p/ui_vnc-enc-zlib.c.o FAILED: libcommon.fa.p/ui_vnc-enc-hextile.c.o FAILED: libcommon.fa.p/ui_vnc-auth-vencrypt.c.o FAILED: libcommon.fa.p/ui_vnc.c.o FAILED: libcommon.fa.p/ui_vnc-enc-tight.c.o FAILED: libcommon.fa.p/ui_vnc-ws.c.o FAILED: libcommon.fa.p/ui_vnc-jobs.c.o FAILED: libcommon.fa.p/ui_vnc-clipboard.c.o FAILED: libcommon.fa.p/ui_vnc-enc-zrle.c.o FAILED: libcommon.fa.p/ui_vnc-auth-sasl.c.o FAILED: libcommon.fa.p/ui_cocoa.m.o FAILED: libcommon.fa.p/hw_char_escc.c.o FAILED: libcommon.fa.p/hw_core_sysbus-fdt.c.o FAILED: libcommon.fa.p/hw_display_ramfb.c.o FAILED: libcommon.fa.p/hw_display_g364fb.c.o FAILED: libcommon.fa.p/hw_display_ramfb-standalone.c.o FAILED: libcommon.fa.p/hw_display_jazz_led.c.o FAILED: libcommon.fa.p/hw_display_cirrus_vga_isa.c.o FAILED: libcommon.fa.p/hw_display_cirrus_vga.c.o FAILED: libcommon.fa.p/hw_display_pl110.c.o FAILED: libcommon.fa.p/hw_display_ssd0303.c.o FAILED: libcommon.fa.p/hw_display_ssd0323.c.o FAILED: libcommon.fa.p/hw_display_blizzard.c.o FAILED: libcommon.fa.p/hw_display_framebuffer.c.o FAILED: libcommon.fa.p/hw_display_vga-mmio.c.o FAILED: libcommon.fa.p/hw_display_exynos4210_fimd.c.o FAILED: libcommon.fa.p/hw_display_bochs-display.c.o FAILED: libcommon.fa.p/hw_display_vga-pci.c.o FAILED: libcommon.fa.p/hw_display_vga-isa.c.o FAILED: libcommon.fa.p/hw_display_vmware_vga.c.o FAILED: libcommon.fa.p/hw_display_omap_dss.c.o FAILED: libcommon.fa.p/hw_display_bcm2835_fb.c.o FAILED: libcommon.fa.p/hw_display_tc6393xb.c.o FAILED: libcommon.fa.p/hw_display_pxa2xx_lcd.c.o FAILED: libcommon.fa.p/hw_display_cg3.c.o FAILED: libcommon.fa.p/hw_display_tcx.c.o FAILED: libcommon.fa.p/hw_display_sm501.c.o FAILED: libcommon.fa.p/hw_display_macfb.c.o FAILED: libcommon.fa.p/hw_display_next-fb.c.o FAILED: libcommon.fa.p/hw_display_vga.c.o FAILED: libcommon.fa.p/hw_display_xlnx_dp.c.o FAILED: libcommon.fa.p/hw_display_omap_lcdc.c.o FAILED: libcommon.fa.p/hw_display_artist.c.o FAILED: libcommon.fa.p/hw_dma_xlnx_dpdma.c.o FAILED: libcommon.fa.p/hw_input_hid.c.o FAILED: libcommon.fa.p/hw_input_ads7846.c.o FAILED: libcommon.fa.p/hw_input_adb-mouse.c.o FAILED: libcommon.fa.p/hw_input_lm832x.c.o FAILED: libcommon.fa.p/hw_input_ps2.c.o FAILED: libcommon.fa.p/hw_input_stellaris_input.c.o FAILED: libcommon.fa.p/hw_input_tsc2005.c.o FAILED: libcommon.fa.p/hw_input_pxa2xx_keypad.c.o FAILED: libcommon.fa.p/hw_input_virtio-input-hid.c.o FAILED: libcommon.fa.p/hw_input_tsc210x.c.o FAILED: libcommon.fa.p/hw_misc_applesmc.c.o FAILED: libcommon.fa.p/hw_misc_bcm2835_property.c.o FAILED: libcommon.fa.p/hw_usb_dev-hid.c.o FAILED: libcommon.fa.p/hw_usb_dev-wacom.c.o FAILED: libcommon.fa.p/hw_arm_bcm2835_peripherals.c.o FAILED: libcommon.fa.p/chardev_msmouse.c.o FAILED: libcommon.fa.p/chardev_wctablet.c.o FAILED: libcommon.fa.p/softmmu_vl.c.o FAILED: libcommon.fa.p/ui_curses.c.o FAILED: libcommon.fa.p/ui_sdl2-2d.c.o FAILED: libcommon.fa.p/ui_sdl2-input.c.o FAILED: libcommon.fa.p/ui_sdl2.c.o FAILED: libcommon.fa.p/hw_display_virtio-gpu-base.c.o FAILED: libcommon.fa.p/hw_display_virtio-gpu.c.o FAILED: libcommon.fa.p/hw_display_virtio-gpu-udmabuf-stubs.c.o FAILED: libcommon.fa.p/hw_display_virtio-gpu-pci.c.o FAILED: libcommon.fa.p/hw_display_virtio-vga.c.o FAILED: libcommon.fa.p/hw_s390x_virtio-ccw-gpu.c.o
Re: [PATCH 51/67] build-sys: add optional "pixman" feature
Quoted 63 lines · Philippe Mathieu-Daudé
Quoted 62 lines · Philippe Mathieu-Daudé
Quoted 33 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Set
CONFIG_PIXMANaccordinly.Signed-off-by Marc-André Lureau <[email protected]>---
meson.build | 6 ++++--
Kconfig.host| 3 +++
meson_options.txt | 2 ++3 files changed, 9 insertions(+), 2 deletions(-)meson.build +0
-0@@ -836,8 +836,8 @@ if 'ust' in get_option('trace_backends') method: 'pkg-config')endif
pixman =not_found
-ifhave_systemorhave_tools
- pixman = dependency('pixman-1', required:have_system, version:'>=0.21.8',
+if not get_option('pixman').auto() orhave_systemorhave_tools+ pixman = dependency('pixman-1', required:get_option('pixman'), version:'>=0.21.8',
method: 'pkg-config')meson_options.txt +0
-0meson_options.txt option('l2tpv3', type : 'feature', value : 'auto', · line 223
Quoted 8 lines
meson_options.txt +2
-0@@ -216,6 +216,8 @@ option('l2tpv3', type : 'feature', value : 'auto', description: 'l2tpv3 network backend support') option('netmap', type : 'feature', value : 'auto', description: 'netmap network backend support') +option('pixman', type : 'feature', value : 'auto', + description: 'pixman support') option('slirp', type: 'feature', value: 'auto', description: 'libslirp user mode network backend support') option('vde', type : 'feature', value : 'auto',Apparently missing:
-- >8 --
scripts/meson-buildoptions.sh +1
-0@@ -146,6 +146,7 @@ meson_options_help() { printf "%s\n" ' pa PulseAudio sound support' printf "%s\n" ' parallels parallels image format support' printf "%s\n" ' pipewire PipeWire sound support' + printf "%s\n" ' pixman pixman support' printf "%s\n" ' png PNG support with libpng' printf "%s\n" ' pvrdma Enable PVRDMA support' printf "%s\n" ' qcow1 qcow1 image format support'@@ -397,6 +398,8 @@ _meson_option_parse() { --disable-parallels) printf "%s" -Dparallels=disabled ;; --enable-pipewire) printf "%s" -Dpipewire=enabled ;; --disable-pipewire) printf "%s" -Dpipewire=disabled ;;
Quoted 8 lines
scripts/meson-buildoptions.sh _meson_option_parse() {
Quoted 6 lines
scripts/meson-buildoptions.sh +2
-1+ --enable-pixman) printf "%s" -Dpixman=enabled ;; + --disable-pixman) printf "%s" -Dpixman=disabled ;; --with-pkgversion=*) quote_sh "-Dpkgversion=$2" ;; --enable-png) printf "%s" -Dpng=enabled ;; --disable-png) printf "%s" -Dpng=disabled ;; ---Many files fail to build when using --disable-pixman here:
I guess meson.build ought to (temporarily) report an eror if pixman is missing and/or explicitly disabled, which is then removed in the next patch that actually makes it work.
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 :|
PATCH 52/67 ui: compile out some qemu-pixman functions when !PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Those functions require the PIXMAN library.
--- include/ui/qemu-pixman.h | 7 +++++-- ui/qemu-pixman.c | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
include/ui/qemu-pixman.h +5 -2
@@ -70,17 +70,17 @@ pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian);pixman_format_code_t qemu_drm_format_to_pixman (uint32_t drm_format);uint32_t qemu_pixman_to_drm_format (pixman_format_code_t pixman);int qemu_pixman_get_type (int rshift,int gshift,int bshift); -pixman_format_code_t qemu_pixman_get_format (PixelFormat *pf);bool qemu_pixman_check_format (DisplayChangeListener *dcl,pixman_format_code_t format); +#ifdef CONFIG_PIXMAN +pixman_format_code_t qemu_pixman_get_format (PixelFormat *pf);pixman_image_t *qemu_pixman_linebuf_create (pixman_format_code_t format,int width);void qemu_pixman_linebuf_fill (pixman_image_t *linebuf,pixman_image_t *fb,int width,int x,int y);pixman_image_t *qemu_pixman_mirror_create (pixman_format_code_t format,pixman_image_t *image); -void qemu_pixman_image_unref (pixman_image_t *image);pixman_image_t *qemu_pixman_glyph_from_vgafont (int height,const uint8_t *font,unsigned int ch);
@@ -89,6 +89,9 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph, pixman_color_t *fgcol, pixman_color_t *bgcol, int x, int y, int cw, int ch); +#endif + +void qemu_pixman_image_unref (pixman_image_t *image);G_DEFINE_AUTOPTR_CLEANUP_FUNC (pixman_image_t, qemu_pixman_image_unref)
ui/qemu-pixman.c +6 -0
@@ -143,6 +143,7 @@ int qemu_pixman_get_type(int rshift, int gshift, int bshift)return type; } +#ifdef CONFIG_PIXMAN pixman_format_code_t qemu_pixman_get_format (PixelFormat *pf) {pixman_format_code_t format;
@@ -156,6 +157,7 @@ pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf) }return format; } +#endif /* * Return true for known-good pixman conversions.
@@ -184,6 +186,7 @@ bool qemu_pixman_check_format(DisplayChangeListener *dcl, } } +#ifdef CONFIG_PIXMAN pixman_image_t *qemu_pixman_linebuf_create (pixman_format_code_t format,int width) {
@@ -209,6 +212,7 @@ pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,NULL , pixman_image_get_stride(image)); } +#endif void qemu_pixman_image_unref (pixman_image_t *image) {
@@ -218,6 +222,7 @@ void qemu_pixman_image_unref(pixman_image_t *image)pixman_image_unref (image); } +#ifdef CONFIG_PIXMAN pixman_image_t *qemu_pixman_glyph_from_vgafont (int height,const uint8_t *font,unsigned int ch) {
@@ -260,3 +265,4 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph,pixman_image_unref (ifg); pixman_image_unref(ibg); } +#endif /* CONFIG_PIXMAN */
Signature · 1 line
2.41.0
PATCH 53/67 ui: add pixman-compat.h
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This is a tiny subset of PIXMAN API that is used pervasively in QEMU codebase to manage images and identify the underlying format.
It doesn't seems worth to wrap this in a QEMU-specific API.
--- include/ui/pixman-compat.h | 190 +++++++++++++++++++++++++++++++++++++ include/ui/qemu-pixman.h | 4 + 2 files changed, 194 insertions(+) create mode 100644 include/ui/pixman-compat.h
include/ui/pixman-compat.h new file +190 -0
@@ -0,0 +1,190 @@ +/* +* SPDX-License-Identifier: MIT +* +* Tiny subset of PIXMAN API commonly used by QEMU. +* +* Copyright 1987, 1988, 1989, 1998 The Open Group +* Copyright 1987, 1988, 1989 Digital Equipment Corporation +* Copyright 1999, 2004, 2008 Keith Packard +* Copyright 2000 SuSE, Inc. +* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc. +* Copyright 2004, 2005, 2007, 2008, 2009, 2010 Red Hat, Inc. +* Copyright 2004 Nicholas Miell +* Copyright 2005 Lars Knoll & Zack Rusin, Trolltech +* Copyright 2005 Trolltech AS +* Copyright 2007 Luca Barbato +* Copyright 2008 Aaron Plattner, NVIDIA Corporation +* Copyright 2008 Rodrigo Kumpera +* Copyright 2008 André Tupinambá +* Copyright 2008 Mozilla Corporation +* Copyright 2008 Frederic Plourde +* Copyright 2009, Oracle and/or its affiliates. All rights reserved. +* Copyright 2009, 2010 Nokia Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef PIXMAN_COMPAT_H +#define PIXMAN_COMPAT_H + +#define PIXMAN_TYPE_OTHER 0 +#define PIXMAN_TYPE_ARGB 2 +#define PIXMAN_TYPE_ABGR 3 +#define PIXMAN_TYPE_BGRA 8 +#define PIXMAN_TYPE_RGBA 9 + +#define PIXMAN_FORMAT (bpp,type,a,r,g,b) (((bpp) << 24) | \ + ((type) << 16) | \ + ((a) << 12) | \ + ((r) << 8) | \ + ((g) << 4) | \ + ((b))) + +#define PIXMAN_FORMAT_RESHIFT (val, ofs, num) \ + (((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3)) + +#define PIXMAN_FORMAT_BPP (f) PIXMAN_FORMAT_RESHIFT(f, 24, 8) +#define PIXMAN_FORMAT_TYPE (f) (((f) >> 16) & 0x3f) +#define PIXMAN_FORMAT_A (f) PIXMAN_FORMAT_RESHIFT(f, 12, 4) +#define PIXMAN_FORMAT_R (f) PIXMAN_FORMAT_RESHIFT(f, 8, 4) +#define PIXMAN_FORMAT_G (f) PIXMAN_FORMAT_RESHIFT(f, 4, 4) +#define PIXMAN_FORMAT_B (f) PIXMAN_FORMAT_RESHIFT(f, 0, 4) +#define PIXMAN_FORMAT_DEPTH (f) (PIXMAN_FORMAT_A(f) + \ + PIXMAN_FORMAT_R(f) + \ + PIXMAN_FORMAT_G(f) + \ + PIXMAN_FORMAT_B(f)) + +typedef enum { +/* 32bpp formats */ + PIXMAN_a8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,8 ,8 ,8 ,8 ), + PIXMAN_x8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_a8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,8 ,8 ,8 ,8 ), + PIXMAN_x8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,8 ,8 ,8 ,8 ), + PIXMAN_b8g8r8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,0 ,8 ,8 ,8 ), + PIXMAN_r8g8b8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,8 ,8 ,8 ,8 ), + PIXMAN_r8g8b8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,0 ,8 ,8 ,8 ), +/* 24bpp formats */ + PIXMAN_r8g8b8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), +/* 16bpp formats */ + PIXMAN_r5g6b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,6 ,5 ), + PIXMAN_a1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,1 ,5 ,5 ,5 ), + PIXMAN_x1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,5 ,5 ), +}pixman_format_code_t ; + +typedef struct pixman_image pixman_image_t ; + +typedef void (*pixman_image_destroy_func_t )(pixman_image_t *image,void *data); + +struct pixman_image { +int ref_count; +pixman_format_code_t format; +int width; +int height; +int stride; +uint8_t *data; +pixman_image_destroy_func_t destroy_func; +void *destroy_data; +}; + +typedef struct pixman_color { +uint16_t red; +uint16_t green; +uint16_t blue; +uint16_t alpha; +}pixman_color_t ; + +static inline pixman_image_t *pixman_image_create_bits (pixman_format_code_t format, +int width, +int height, +uint32_t *bits, +int rowstride_bytes) +{ +pixman_image_t *i =g_new0 (pixman_image_t,1 ); + + i->width = width; + i->height = height; + i->stride = rowstride_bytes ?: width *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (format),8 ); + i->format = format; + i->data = bits ?:g_malloc0 (rowstride_bytes * height); + i->ref_count =1 ; + +return i; +} + +static inline pixman_image_t *pixman_image_ref (pixman_image_t *i) +{ + i->ref_count++; +return i; +} + +static inline bool pixman_image_unref (pixman_image_t *i) +{ + i->ref_count--; + +if (i->ref_count ==0 ) { +if (i->destroy_func) { + i->destroy_func (i, i->destroy_data); +g_free (i->data); +g_free (i); + } + +return true; + } + +return false; +} + +static inline void pixman_image_set_destroy_function (pixman_image_t *i, +pixman_image_destroy_func_t func, +void *data) + +{ + i->destroy_func = func; + i->destroy_data = data; +} + +static inline uint8_t *pixman_image_get_data (pixman_image_t *i) +{ +return i->data; +} + +static inline int pixman_image_get_height (pixman_image_t *i) +{ +return i->height; +} + +static inline int pixman_image_get_width (pixman_image_t *i) +{ +return i->width; +} + +static inline int pixman_image_get_stride (pixman_image_t *i) +{ +return i->stride; +} + +static inline pixman_format_code_t pixman_image_get_format (pixman_image_t *i) +{ +return i->format; +} + +#endif /* PIXMAN_COMPAT_H */
include/ui/qemu-pixman.h +4 -0
@@ -6,11 +6,15 @@#ifndef QEMU_PIXMAN_H #define QEMU_PIXMAN_H +#ifdef CONFIG_PIXMAN /* pixman-0.16.0 headers have a redundant declaration */ #pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wredundant-decls"#include <pixman.h> #pragma GCC diagnostic pop +#else +#include "pixman-compat.h" +#endif /* * pixman image formats are defined to be native endian,
Signature · 1 line
2.41.0
Re: [PATCH 53/67] ui: add pixman-compat.h
Quoted 5 lines · On Wed, Aug 30, 2023 at 01:38:27PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This is a tiny subset of PIXMAN API that is used pervasively in QEMU codebase to manage images and identify the underlying format.
Quoted 8 lines
It doesn't seems worth to wrap this in a QEMU-specific API.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/pixman-compat.h | 190 +++++++++++++++++++++++++++++++++++++ include/ui/qemu-pixman.h | 4 + 2 files changed, 194 insertions(+) create mode 100644 include/ui/pixman-compat.h
This patch is what makes me feel the end state of this series is somewhat dubious. This pixman-compat.h shows we clearly still need the pixman APIs, and trying to make pixman optional is causing us to re-invent a part of pixman via copy+paste. I don't find this very appealing.
If it is possible to disable the build of parts of QEMU such that what remains compiled does not require pixman at all, that is reasonable.
Keeping building stuff that actually wants pixman, via a compat API is imposing a burden on QEMU without a compelling gain IMHO.
Quoted 221 lines
include/ui/pixman-compat.h new file +190
-0@@ -0,0 +1,190 @@ +/* +* SPDX-License-Identifier: MIT +* +* Tiny subset of PIXMAN API commonly used by QEMU. +* +* Copyright 1987, 1988, 1989, 1998 The Open Group +* Copyright 1987, 1988, 1989 Digital Equipment Corporation +* Copyright 1999, 2004, 2008 Keith Packard +* Copyright 2000 SuSE, Inc. +* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc. +* Copyright 2004, 2005, 2007, 2008, 2009, 2010 Red Hat, Inc. +* Copyright 2004 Nicholas Miell +* Copyright 2005 Lars Knoll & Zack Rusin, Trolltech +* Copyright 2005 Trolltech AS +* Copyright 2007 Luca Barbato +* Copyright 2008 Aaron Plattner, NVIDIA Corporation +* Copyright 2008 Rodrigo Kumpera +* Copyright 2008 André Tupinambá +* Copyright 2008 Mozilla Corporation +* Copyright 2008 Frederic Plourde +* Copyright 2009, Oracle and/or its affiliates. All rights reserved. +* Copyright 2009, 2010 Nokia Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef PIXMAN_COMPAT_H +#define PIXMAN_COMPAT_H + +#define PIXMAN_TYPE_OTHER 0 +#define PIXMAN_TYPE_ARGB 2 +#define PIXMAN_TYPE_ABGR 3 +#define PIXMAN_TYPE_BGRA 8 +#define PIXMAN_TYPE_RGBA 9 + +#define PIXMAN_FORMAT (bpp,type,a,r,g,b) (((bpp) << 24) | \ + ((type) << 16) | \ + ((a) << 12) | \ + ((r) << 8) | \ + ((g) << 4) | \ + ((b))) + +#define PIXMAN_FORMAT_RESHIFT (val, ofs, num) \ + (((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3)) + +#define PIXMAN_FORMAT_BPP (f) PIXMAN_FORMAT_RESHIFT(f, 24, 8) +#define PIXMAN_FORMAT_TYPE (f) (((f) >> 16) & 0x3f) +#define PIXMAN_FORMAT_A (f) PIXMAN_FORMAT_RESHIFT(f, 12, 4) +#define PIXMAN_FORMAT_R (f) PIXMAN_FORMAT_RESHIFT(f, 8, 4) +#define PIXMAN_FORMAT_G (f) PIXMAN_FORMAT_RESHIFT(f, 4, 4) +#define PIXMAN_FORMAT_B (f) PIXMAN_FORMAT_RESHIFT(f, 0, 4) +#define PIXMAN_FORMAT_DEPTH (f) (PIXMAN_FORMAT_A(f) + \ + PIXMAN_FORMAT_R(f) + \ + PIXMAN_FORMAT_G(f) + \ + PIXMAN_FORMAT_B(f)) + +typedef enum { +/* 32bpp formats */ + PIXMAN_a8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,8 ,8 ,8 ,8 ), + PIXMAN_x8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_a8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,8 ,8 ,8 ,8 ), + PIXMAN_x8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,8 ,8 ,8 ,8 ), + PIXMAN_b8g8r8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,0 ,8 ,8 ,8 ), + PIXMAN_r8g8b8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,8 ,8 ,8 ,8 ), + PIXMAN_r8g8b8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,0 ,8 ,8 ,8 ), +/* 24bpp formats */ + PIXMAN_r8g8b8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), +/* 16bpp formats */ + PIXMAN_r5g6b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,6 ,5 ), + PIXMAN_a1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,1 ,5 ,5 ,5 ), + PIXMAN_x1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,5 ,5 ), +}pixman_format_code_t ; + +typedef struct pixman_image pixman_image_t ; + +typedef void (*pixman_image_destroy_func_t )(pixman_image_t *image,void *data); + +struct pixman_image { +int ref_count; +pixman_format_code_t format; +int width; +int height; +int stride; +uint8_t *data; +pixman_image_destroy_func_t destroy_func; +void *destroy_data; +}; + +typedef struct pixman_color { +uint16_t red; +uint16_t green; +uint16_t blue; +uint16_t alpha; +}pixman_color_t ; + +static inline pixman_image_t *pixman_image_create_bits (pixman_format_code_t format, +int width, +int height, +uint32_t *bits, +int rowstride_bytes) +{ +pixman_image_t *i =g_new0 (pixman_image_t,1 ); + + i->width = width; + i->height = height; + i->stride = rowstride_bytes ?: width *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (format),8 ); + i->format = format; + i->data = bits ?:g_malloc0 (rowstride_bytes * height); + i->ref_count =1 ; + +return i; +} + +static inline pixman_image_t *pixman_image_ref (pixman_image_t *i) +{ + i->ref_count++; +return i; +} + +static inline bool pixman_image_unref (pixman_image_t *i) +{ + i->ref_count--; + +if (i->ref_count ==0 ) { +if (i->destroy_func) { + i->destroy_func (i, i->destroy_data); +g_free (i->data); +g_free (i); + } + +return true; + } + +return false; +} + +static inline void pixman_image_set_destroy_function (pixman_image_t *i, +pixman_image_destroy_func_t func, +void *data) + +{ + i->destroy_func = func; + i->destroy_data = data; +} + +static inline uint8_t *pixman_image_get_data (pixman_image_t *i) +{ +return i->data; +} + +static inline int pixman_image_get_height (pixman_image_t *i) +{ +return i->height; +} + +static inline int pixman_image_get_width (pixman_image_t *i) +{ +return i->width; +} + +static inline int pixman_image_get_stride (pixman_image_t *i) +{ +return i->stride; +} + +static inline pixman_format_code_t pixman_image_get_format (pixman_image_t *i) +{ +return i->format; +} + +#endif /* PIXMAN_COMPAT_H */ include/ui/qemu-pixman.h +4
-0@@ -6,11 +6,15 @@#ifndef QEMU_PIXMAN_H #define QEMU_PIXMAN_H +#ifdef CONFIG_PIXMAN /* pixman-0.16.0 headers have a redundant declaration */ #pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wredundant-decls"#include <pixman.h> #pragma GCC diagnostic pop +#else +#include "pixman-compat.h" +#endif /* * pixman image formats are defined to be native endian, Signature · 1 line
2.41.0
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 :|
Re: [PATCH 53/67] ui: add pixman-compat.h
Hi
Quoted 16 lines · Daniel P. Berrangé
Quoted 5 lines · On Wed, Aug 30, 2023 at 01:38:27PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This is a tiny subset of PIXMAN API that is used pervasively in QEMU codebase to manage images and identify the underlying format.
Quoted 8 lines
It doesn't seems worth to wrap this in a QEMU-specific API.
Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/pixman-compat.h | 190 +++++++++++++++++++++++++++++++++++++ include/ui/qemu-pixman.h | 4 + 2 files changed, 194 insertions(+) create mode 100644 include/ui/pixman-compat.h
Quoted 5 lines
This patch is what makes me feel the end state of this series is somewhat dubious. This
pixman-compat.hshows we clearly still need the pixman APIs, and trying to make pixman optional is causing us to re-invent a part of pixman via copy+paste. I don't find this very appealing.
It's very limited though, as that compat doesn't offer any pixel manipulation.
Quoted 4 lines
If it is possible to disable the build of parts of QEMU such that what remains compiled does not require pixman at all, that is reasonable.
I am afraid this leads to x10 of #ifdef if we follow that path. I was personally disgusted: not only it was getting horrible to deal with, but it makes you wonder what can be kept or not with embarrassing questions and behaviours. This compat approach is way saner and simpler. As can be seen, this is a fraction of the API, just to wrap the bits and define the formats. It's ridiculously small imho to keep most of QEMU code still work.
Quoted 235 lines
Keeping building stuff that actually wants pixman, via a compat API is imposing a burden on QEMU without a compelling gain IMHO.
Quoted 218 lines
include/ui/pixman-compat.h new file +190
-0@@ -0,0 +1,190 @@ +/* +* SPDX-License-Identifier: MIT +* +* Tiny subset of PIXMAN API commonly used by QEMU. +* +* Copyright 1987, 1988, 1989, 1998 The Open Group +* Copyright 1987, 1988, 1989 Digital Equipment Corporation +* Copyright 1999, 2004, 2008 Keith Packard +* Copyright 2000 SuSE, Inc. +* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc. +* Copyright 2004, 2005, 2007, 2008, 2009, 2010 Red Hat, Inc. +* Copyright 2004 Nicholas Miell +* Copyright 2005 Lars Knoll & Zack Rusin, Trolltech +* Copyright 2005 Trolltech AS +* Copyright 2007 Luca Barbato +* Copyright 2008 Aaron Plattner, NVIDIA Corporation +* Copyright 2008 Rodrigo Kumpera +* Copyright 2008 André Tupinambá +* Copyright 2008 Mozilla Corporation +* Copyright 2008 Frederic Plourde +* Copyright 2009, Oracle and/or its affiliates. All rights reserved. +* Copyright 2009, 2010 Nokia Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef PIXMAN_COMPAT_H +#define PIXMAN_COMPAT_H + +#define PIXMAN_TYPE_OTHER 0 +#define PIXMAN_TYPE_ARGB 2 +#define PIXMAN_TYPE_ABGR 3 +#define PIXMAN_TYPE_BGRA 8 +#define PIXMAN_TYPE_RGBA 9 + +#define PIXMAN_FORMAT (bpp,type,a,r,g,b) (((bpp) << 24) | \ + ((type) << 16) | \ + ((a) << 12) | \ + ((r) << 8) | \ + ((g) << 4) | \ + ((b))) + +#define PIXMAN_FORMAT_RESHIFT (val, ofs, num) \ + (((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3)) + +#define PIXMAN_FORMAT_BPP (f) PIXMAN_FORMAT_RESHIFT(f, 24, 8) +#define PIXMAN_FORMAT_TYPE (f) (((f) >> 16) & 0x3f) +#define PIXMAN_FORMAT_A (f) PIXMAN_FORMAT_RESHIFT(f, 12, 4) +#define PIXMAN_FORMAT_R (f) PIXMAN_FORMAT_RESHIFT(f, 8, 4) +#define PIXMAN_FORMAT_G (f) PIXMAN_FORMAT_RESHIFT(f, 4, 4) +#define PIXMAN_FORMAT_B (f) PIXMAN_FORMAT_RESHIFT(f, 0, 4) +#define PIXMAN_FORMAT_DEPTH (f) (PIXMAN_FORMAT_A(f) + \ + PIXMAN_FORMAT_R(f) + \ + PIXMAN_FORMAT_G(f) + \ + PIXMAN_FORMAT_B(f)) + +typedef enum { +/* 32bpp formats */ + PIXMAN_a8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,8 ,8 ,8 ,8 ), + PIXMAN_x8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_a8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,8 ,8 ,8 ,8 ), + PIXMAN_x8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,8 ,8 ,8 ,8 ), + PIXMAN_b8g8r8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,0 ,8 ,8 ,8 ), + PIXMAN_r8g8b8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,8 ,8 ,8 ,8 ), + PIXMAN_r8g8b8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,0 ,8 ,8 ,8 ), +/* 24bpp formats */ + PIXMAN_r8g8b8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), +/* 16bpp formats */ + PIXMAN_r5g6b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,6 ,5 ), + PIXMAN_a1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,1 ,5 ,5 ,5 ), + PIXMAN_x1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,5 ,5 ), +}pixman_format_code_t ; + +typedef struct pixman_image pixman_image_t ; + +typedef void (*pixman_image_destroy_func_t )(pixman_image_t *image,void *data); + +struct pixman_image { +int ref_count; +pixman_format_code_t format; +int width; +int height; +int stride; +uint8_t *data; +pixman_image_destroy_func_t destroy_func; +void *destroy_data; +}; + +typedef struct pixman_color { +uint16_t red; +uint16_t green; +uint16_t blue; +uint16_t alpha; +}pixman_color_t ; + +static inline pixman_image_t *pixman_image_create_bits (pixman_format_code_t format, +int width, +int height, +uint32_t *bits, +int rowstride_bytes) +{ +pixman_image_t *i =g_new0 (pixman_image_t,1 ); + + i->width = width; + i->height = height; + i->stride = rowstride_bytes ?: width *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (format),8 ); + i->format = format; + i->data = bits ?:g_malloc0 (rowstride_bytes * height); + i->ref_count =1 ; + +return i; +} + +static inline pixman_image_t *pixman_image_ref (pixman_image_t *i) +{ + i->ref_count++; +return i; +} + +static inline bool pixman_image_unref (pixman_image_t *i) +{ + i->ref_count--; + +if (i->ref_count ==0 ) { +if (i->destroy_func) { + i->destroy_func (i, i->destroy_data); +g_free (i->data); +g_free (i); + } + +return true; + } + +return false; +} + +static inline void pixman_image_set_destroy_function (pixman_image_t *i, +pixman_image_destroy_func_t func, +void *data) + +{ + i->destroy_func = func; + i->destroy_data = data; +} + +static inline uint8_t *pixman_image_get_data (pixman_image_t *i) +{ +return i->data; +} + +static inline int pixman_image_get_height (pixman_image_t *i) +{ +return i->height; +} + +static inline int pixman_image_get_width (pixman_image_t *i) +{ +return i->width; +} + +static inline int pixman_image_get_stride (pixman_image_t *i) +{ +return i->stride; +} + +static inline pixman_format_code_t pixman_image_get_format (pixman_image_t *i) +{ +return i->format; +} + +#endif /* PIXMAN_COMPAT_H */ include/ui/qemu-pixman.h +4
-1@@ -6,11 +6,15 @@#ifndef QEMU_PIXMAN_H #define QEMU_PIXMAN_H +#ifdef CONFIG_PIXMAN /* pixman-0.16.0 headers have a redundant declaration */ #pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wredundant-decls"#include <pixman.h> #pragma GCC diagnostic pop +#else +#include "pixman-compat.h" +#endif /* * pixman image formats are defined to be native endian, -- Quoted 3 lines
2.41.0
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 :|
Signature · 1 line
Marc-André Lureau
PATCH 54/67 ui/vc: console-vc requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Add stubs for the fallback paths.
--- ui/console-vc-stubs.c | 59 +++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 ui/console-vc-stubs.c
ui/console-vc-stubs.c new file +59 -0
@@ -0,0 +1,59 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC stubs +*/ +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "chardev/char.h" +#include "ui/console-priv.h" + +void qemu_text_console_select (QemuTextConsole *c) +{ +} + +const char *qemu_text_console_get_label (QemuTextConsole *c) +{ +return NULL ; +} + +void qemu_text_console_update_cursor (void ) +{ +} + +void qemu_text_console_handle_keysym (QemuTextConsole *s,int keysym) +{ +} + +#define TYPE_CHARDEV_VC "chardev-vc" + +static void vc_chr_parse (QemuOpts *opts,ChardevBackend *backend,Error **errp) +{ +const char *id =qemu_opts_id (opts); + +warn_report ("%s: this is a dummy VC driver. " +"Use '-nographic' or a different chardev." , id); +} + +static void char_vc_class_init (ObjectClass *oc,void *data) +{ +ChardevClass *cc =CHARDEV_CLASS (oc); + + cc->parse = vc_chr_parse; +} + +static const TypeInfo char_vc_type_info = { + .name =TYPE_CHARDEV_VC , + .parent =TYPE_CHARDEV , + .class_init = char_vc_class_init, +}; + +void qemu_console_early_init (void ) +{ +/* set the default vc driver */ +if (!object_class_by_name (TYPE_CHARDEV_VC )) { +type_register (&char_vc_type_info); + } +}
ui/meson.build +1 -1
@@ -6,7 +6,6 @@ system_ss.add(png) system_ss.add(files( 'clipboard.c', 'console.c', - 'console-vc.c', 'cursor.c', 'input-keymap.c', 'input-legacy.c',
@@ -19,6 +18,7 @@ system_ss.add(files( 'ui-qmp-cmds.c', 'util.c', )) +system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: files('console-vc-stubs.c')) if dbus_display system_ss.add(files('dbus-module.c')) endif
Signature · 1 line
2.41.0
Re: [PATCH 54/67] ui/vc: console-vc requires PIXMAN
Quoted 45 lines · On Wed, Aug 30, 2023 at 01:38:28PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Add stubs for the fallback paths.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console-vc-stubs.c | 59 +++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 ui/console-vc-stubs.cui/console-vc-stubs.c new file +28
-0@@ -0,0 +1,59 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC stubs +*/ +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "chardev/char.h" +#include "ui/console-priv.h" + +void qemu_text_console_select (QemuTextConsole *c) +{ +} + +const char *qemu_text_console_get_label (QemuTextConsole *c) +{ +return NULL ; +} + +void qemu_text_console_update_cursor (void ) +{ +} + +void qemu_text_console_handle_keysym (QemuTextConsole *s,int keysym) +{ +}
ui/console-vc-stubs.c line 38
Quoted 10 lines
ui/console-vc-stubs.c new file +10
-0+ +#define TYPE_CHARDEV_VC "chardev-vc" + +static void vc_chr_parse (QemuOpts *opts,ChardevBackend *backend,Error **errp) +{ +const char *id =qemu_opts_id (opts); + +warn_report ("%s: this is a dummy VC driver. " +"Use '-nographic' or a different chardev." , id); +}
Why should this be an error_setg() call given we have a errp parameter, so make this unsupportable config into an error ? Ignoring invalid user configs is not desirable in general.
Quoted 45 lines
ui/console-vc-stubs.c new file +21
-0+ +static void char_vc_class_init (ObjectClass *oc,void *data) +{ +ChardevClass *cc =CHARDEV_CLASS (oc); + + cc->parse = vc_chr_parse; +} + +static const TypeInfo char_vc_type_info = { + .name =TYPE_CHARDEV_VC , + .parent =TYPE_CHARDEV , + .class_init = char_vc_class_init, +}; + +void qemu_console_early_init (void ) +{ +/* set the default vc driver */ +if (!object_class_by_name (TYPE_CHARDEV_VC )) { +type_register (&char_vc_type_info); + } +}ui/meson.build +1
-1@@ -6,7 +6,6 @@ system_ss.add(png) system_ss.add(files( 'clipboard.c', 'console.c', - 'console-vc.c', 'cursor.c', 'input-keymap.c', 'input-legacy.c',@@ -19,6 +18,7 @@ system_ss.add(files( 'ui-qmp-cmds.c', 'util.c', )) +system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: files('console-vc-stubs.c')) if dbus_display system_ss.add(files('dbus-module.c')) endifSignature · 1 line
2.41.0
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 :|
Re: [PATCH 54/67] ui/vc: console-vc requires PIXMAN
Hi
Quoted 53 lines · Daniel P. Berrangé
Quoted 51 lines · On Wed, Aug 30, 2023 at 01:38:28PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Add stubs for the fallback paths.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console-vc-stubs.c | 59 +++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 ui/console-vc-stubs.cui/console-vc-stubs.c new file +34
-0@@ -0,0 +1,59 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC stubs +*/ +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "chardev/char.h" +#include "ui/console-priv.h" + +void qemu_text_console_select (QemuTextConsole *c) +{ +} + +const char *qemu_text_console_get_label (QemuTextConsole *c) +{ +return NULL ; +} + +void qemu_text_console_update_cursor (void ) +{ +} + +void qemu_text_console_handle_keysym (QemuTextConsole *s,int keysym) +{ +} + +#define TYPE_CHARDEV_VC "chardev-vc" + +static void vc_chr_parse (QemuOpts *opts,ChardevBackend *backend,Error **errp) +{ +const char *id =qemu_opts_id (opts);
Quoted 8 lines
ui/console-vc-stubs.c line 38
Quoted 4 lines
ui/console-vc-stubs.c new file +4
-0+ +warn_report ("%s: this is a dummy VC driver. " +"Use '-nographic' or a different chardev." , id); +}Why should this be an
error_setg()call given we have a errp parameter, so make this unsupportable config into an error ? Ignoring invalid user configs is not desirable in general.
This was to keep starting as default, regardless of pixman support.
Since, by default, QEMU will create the following VCs (vl.c):
add_device_config(DEV_SERIAL, "vc:80Cx24C");
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
monitor_parse("vc:80Cx24C", "readline", false);With SDL or VNC, this will associate the QemuTextConsole(s), which is disabled without pixman. Maybe we shouldn't create those VC by default when the backend doesn't support it (but to null instead).
Yes, if the user supplied -chardev vc manually, we should error out instead. I'll try to update the patch.
(btw, I agree with you it would have been nice to make VC an abstract base chardev, and only allow final types)
Quoted 55 lines
Quoted 43 lines
ui/console-vc-stubs.c new file +21
-0+ +static void char_vc_class_init (ObjectClass *oc,void *data) +{ +ChardevClass *cc =CHARDEV_CLASS (oc); + + cc->parse = vc_chr_parse; +} + +static const TypeInfo char_vc_type_info = { + .name =TYPE_CHARDEV_VC , + .parent =TYPE_CHARDEV , + .class_init = char_vc_class_init, +}; + +void qemu_console_early_init (void ) +{ +/* set the default vc driver */ +if (!object_class_by_name (TYPE_CHARDEV_VC )) { +type_register (&char_vc_type_info); + } +}ui/meson.build +1
-2@@ -6,7 +6,6 @@ system_ss.add(png) system_ss.add(files( 'clipboard.c', 'console.c', - 'console-vc.c', 'cursor.c', 'input-keymap.c', 'input-legacy.c',@@ -19,6 +18,7 @@ system_ss.add(files( 'ui-qmp-cmds.c', 'util.c', )) +system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: files('console-vc-stubs.c')) if dbus_display system_ss.add(files('dbus-module.c')) endif --Quoted 3 lines
2.41.0
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 :|
Signature · 1 line
Marc-André Lureau
Re: [PATCH 54/67] ui/vc: console-vc requires PIXMAN
Quoted 69 lines · Marc-André Lureau
Hi
Quoted 53 lines · Daniel P. Berrangé
Quoted 51 lines · On Wed, Aug 30, 2023 at 01:38:28PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Add stubs for the fallback paths.
Signed-off-by Marc-André Lureau <[email protected]>--- ui/console-vc-stubs.c | 59 +++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 ui/console-vc-stubs.cui/console-vc-stubs.c new file +34
-0@@ -0,0 +1,59 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC stubs +*/ +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "chardev/char.h" +#include "ui/console-priv.h" + +void qemu_text_console_select (QemuTextConsole *c) +{ +} + +const char *qemu_text_console_get_label (QemuTextConsole *c) +{ +return NULL ; +} + +void qemu_text_console_update_cursor (void ) +{ +} + +void qemu_text_console_handle_keysym (QemuTextConsole *s,int keysym) +{ +} + +#define TYPE_CHARDEV_VC "chardev-vc" + +static void vc_chr_parse (QemuOpts *opts,ChardevBackend *backend,Error **errp) +{ +const char *id =qemu_opts_id (opts);Quoted 8 lines
ui/console-vc-stubs.c line 38
Quoted 4 lines
ui/console-vc-stubs.c new file +4
-0+ +warn_report ("%s: this is a dummy VC driver. " +"Use '-nographic' or a different chardev." , id); +}Why should this be an
error_setg()call given we have a errp parameter, so make this unsupportable config into an error ? Ignoring invalid user configs is not desirable in general.This was to keep starting as default, regardless of pixman support.
Since, by default, QEMU will create the following VCs (
vl.c):
Quoted 7 lines
add_device_config(DEV_SERIAL, "vc:80Cx24C"); add_device_config(DEV_PARALLEL, "vc:80Cx24C"); monitor_parse("vc:80Cx24C", "readline", false);With SDL or VNC, this will associate the QemuTextConsole(s), which is disabled without pixman. Maybe we shouldn't create those VC by default when the backend doesn't support it (but to null instead).
Yeah, probably best to just use 'null' of 'vc' for that scenario, since the stub is effectively 'null' anyway.
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 :|
PATCH 55/67 qmp/hmp: disable screendump if PIXMAN is missing
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The command requires color conversion and line-by-line feeding. We could have a simple fallback for simple formats though.
--- qapi/ui.json | 3 ++- ui/ui-hmp-cmds.c | 2 ++ ui/ui-qmp-cmds.c | 2 ++ hmp-commands.hx | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-)
qapi/ui.json +2 -1
@@ -200,7 +200,8 @@ { 'command': 'screendump', 'data': {'filename': 'str', '*device': 'str', '*head': 'int', '*format': 'ImageFormat'}, - 'coroutine': true } + 'coroutine': true, + 'if': 'CONFIG_PIXMAN' } ## # == Spice
ui/ui-hmp-cmds.c +2 -0
@@ -437,6 +437,7 @@ void sendkey_completion(ReadLineState *rs, int nb_args, const char *str) } } +#ifdef CONFIG_PIXMAN void coroutine_fnhmp_screendump (Monitor *mon,const QDict *qdict) {
@@ -458,6 +459,7 @@ hmp_screendump(Monitor *mon, const QDict *qdict) end: hmp_handle_error(mon, err); } +#endif void hmp_client_migrate_info (Monitor *mon,const QDict *qdict) {
ui/ui-qmp-cmds.c +2 -0
@@ -212,6 +212,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"protocol" ,"'spice'" ); } +#ifdef CONFIG_PIXMAN #ifdef CONFIG_PNG /** * png_save: Take a screenshot as PNG
@@ -391,3 +392,4 @@ qmp_screendump(const char *filename, const char *device, } } } +#endif /* CONFIG_PIXMAN */
hmp-commands.hx +2 -0
@@ -252,6 +252,7 @@ SRST ERST +#ifdef CONFIG_PIXMAN { .name = "screendump", .args_type = "filename:F,format:-fs,device:s?,head:i?",
@@ -267,6 +268,7 @@ SRST ``screendump`` *filename* Save screen into PPM image *filename*. ERST +#endif { .name = "logfile",
Signature · 1 line
2.41.0
Re: [PATCH 55/67] qmp/hmp: disable screendump if PIXMAN is missing
Quoted 5 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The command requires color conversion and line-by-line feeding. We could have a simple fallback for simple formats though.
Quoted 7 lines
Signed-off-by Marc-André Lureau <[email protected]>--- qapi/ui.json | 3 ++- ui/ui-hmp-cmds.c | 2 ++ ui/ui-qmp-cmds.c | 2 ++ hmp-commands.hx | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-)
PATCH 56/67 virtio-gpu: replace PIXMAN for region/rect test
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Use a simpler implementation for rectangle geometry & intersect, drop the need for (more complex) PIXMAN functions.
--- include/ui/rect.h | 55 +++++++++++++++++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 30 +++++++++------------- 2 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 include/ui/rect.h
include/ui/rect.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_RECT_H +#define QEMU_RECT_H + +#include <stdint.h> +#include <stdbool.h> + +typedef struct QemuRect { +int16_t x; +int16_t y; +uint16_t width; +uint16_t height; +}QemuRect ; + +static inline void qemu_rect_init (QemuRect * rect,int16_t x,int16_t y,uint16_t width,uint16_t height) +{ + rect->x = x; + rect->y = x; + rect->width = width; + rect->height = height; +} + +static inline void qemu_rect_translate (QemuRect * rect,int16_t dx,int16_t dy) +{ + rect->x += dx; + rect->y += dy; +} + +static inline bool qemu_rect_intersect (const QemuRect * a,const QemuRect * b,QemuRect *res) +{ +int16_t x1, x2, y1, y2; + + x1 =MAX (a->x, b->x); + y1 =MAX (a->y, b->y); + x2 =MIN (a->x + a->width, b->x + b->width); + y2 =MIN (a->y + a->height, b->y + b->height); + +if (x1 >= x2 || y1 >= y2) { +if (res) { +qemu_rect_init (res,0 ,0 ,0 ,0 ); + } + +return false; + } + +if (res) { +qemu_rect_init (res, x1, y1, x2 - x1, y2 - y1); + } + +return true; +} + +#endif
hw/display/virtio-gpu.c +11 -19
@@ -16,6 +16,7 @@#include "qemu/iov.h" #include "sysemu/cpus.h" #include "ui/console.h" +#include "ui/rect.h" #include "trace.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h"
@@ -507,7 +508,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,struct virtio_gpu_simple_resource *res;struct virtio_gpu_resource_flush rf;struct virtio_gpu_scanout *scanout; -pixman_region16_t flush_region; +QemuRect flush_rect;bool within_bounds = false;bool update_submitted = false;int i;
@@ -569,34 +570,25 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,return ; } -pixman_region_init_rect (&flush_region, - rf.r.x, rf.r.y, rf.r.width, rf.r.height); +qemu_rect_init (&flush_rect, rf.r.x, rf.r.y, rf.r.width, rf.r.height);for (i =0 ; i < g->parent_obj.conf.max_outputs; i++) { -pixman_region16_t region, finalregion; -pixman_box16_t *extents; +QemuRect rect;if (!(res->scanout_bitmask & (1 << i))) {continue ; } scanout = &g->parent_obj.scanout[i]; -pixman_region_init (&finalregion); -pixman_region_init_rect (®ion, scanout->x, scanout->y, - scanout->width, scanout->height); +qemu_rect_init (&rect, scanout->x, scanout->y, + scanout->width, scanout->height); -pixman_region_intersect (&finalregion, &flush_region, ®ion); -pixman_region_translate (&finalregion, -scanout->x, -scanout->y); - extents =pixman_region_extents (&finalregion);/* work out the area we need to update for each console */ -dpy_gfx_update (g->parent_obj.scanout[i].con, - extents->x1, extents->y1, - extents->x2 - extents->x1, - extents->y2 - extents->y1); - -pixman_region_fini (®ion); -pixman_region_fini (&finalregion); +if (qemu_rect_intersect (&flush_rect, &rect, &rect)) { +qemu_rect_translate (&rect, -scanout->x, -scanout->y); +dpy_gfx_update (g->parent_obj.scanout[i].con, + rect.x, rect.y, rect.width, rect.height); + } } -pixman_region_fini (&flush_region); }static void virtio_unref_resource (pixman_image_t *image,void *data)
Signature · 1 line
2.41.0
PATCH 57/67 ui/console: when PIXMAN is unavailable, don't draw placeholder msg
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/console.c | 2 ++ 1 file changed, 2 insertions(+)
ui/console.c +2 -0
@@ -584,6 +584,7 @@ DisplaySurface *qemu_create_placeholder_surface(int w, int h, const char *msg) {DisplaySurface *surface =qemu_create_displaysurface (w, h); +#ifdef CONFIG_PIXMAN pixman_color_t bg =QEMU_PIXMAN_COLOR_BLACK ;pixman_color_t fg =QEMU_PIXMAN_COLOR_GRAY ;pixman_image_t *glyph;
@@ -598,6 +599,7 @@ DisplaySurface *qemu_create_placeholder_surface(int w, int h, x+i, y, FONT_WIDTH, FONT_HEIGHT); qemu_pixman_image_unref(glyph); } +#endif surface->flags |=QEMU_PLACEHOLDER_FLAG ;return surface; }
Signature · 1 line
2.41.0
PATCH 58/67 vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This simply means that 2d drawing updates won't be handled, but 3d should work.
--- hw/display/vhost-user-gpu.c | 2 ++ 1 file changed, 2 insertions(+)
hw/display/vhost-user-gpu.c +2 -0
@@ -292,6 +292,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)dpy_gl_update (con, m->x, m->y, m->width, m->height);break ; } +#ifdef CONFIG_PIXMAN case VHOST_USER_GPU_UPDATE : {VhostUserGpuUpdate *m = &msg->payload.update;
@@ -319,6 +320,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) }break ; } +#endif default :g_warning ("unhandled message %d %d" , msg->request, msg->size); }
Signature · 1 line
2.41.0
PATCH 59/67 ui/gl: opengl doesn't require PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The QEMU fallback covers the requirements. We still need the flags of header inclusion with CONFIG_PIXMAN.
--- ui/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ui/meson.build +2 -2
@@ -60,8 +60,8 @@ endif system_ss.add(opengl) if opengl.found() opengl_ss = ss.source_set() - opengl_ss.add(gbm) - opengl_ss.add(when: [opengl, pixman], + opengl_ss.add(gbm, pixman) + opengl_ss.add(when: [opengl], if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c')) ui_modules += {'opengl' : opengl_ss} endif
Signature · 1 line
2.41.0
PATCH 60/67 ui/vnc: VNC requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- meson.build | 5 ++++- ui/meson.build | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)
meson.build +4 -1
@@ -1549,7 +1549,10 @@ endif vnc = not_found jpeg = not_found sasl = not_found -if get_option('vnc').allowed() and have_system +if get_option('vnc') \ + .disable_auto_if(not pixman.found()) \ + .require(pixman.found()) \ + .allowed() and have_system vnc = declare_dependency() # dummy dependency jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'), method: 'pkg-config')
ui/meson.build +2 -2
@@ -46,8 +46,8 @@ vnc_ss.add(files( )) vnc_ss.add(zlib, jpeg, gnutls) vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c')) -system_ss.add_all(when: vnc, if_true: vnc_ss) -system_ss.add(when: vnc, if_false: files('vnc-stubs.c')) +system_ss.add_all(when: [vnc, pixman], if_true: vnc_ss) +system_ss.add(when: [vnc, pixman], if_false: files('vnc-stubs.c')) ui_modules = {}
Signature · 1 line
2.41.0
Re: [PATCH 60/67] ui/vnc: VNC requires PIXMAN
meson.build endif · line 1555
Quoted 5 lines · On 8/30/23 11:38, [email protected] wrote:
meson.build +4
-1-if get_option('vnc').allowed() and have_system +if get_option('vnc') \ + .disable_auto_if(not pixman.found()) \ + .require(pixman.found()) \ + .allowed() and have_system
".disable_auto_if()" is not needed, because ".require()" handles it.
However, please add an error message for ".require()" and make it a seprate variable:
have_vnc = get_option('vnc') \
.disable_auto_if(not have_system) \
.require(pixman.found(),
error_message: 'cannot enable VNC if pixman is not available') \
.allowed()
Thanks,
Paolo
PATCH 61/67 ui/spice: SPICE/QXL requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- hw/display/Kconfig | 2 +- ui/meson.build | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
hw/display/Kconfig +1 -1
@@ -93,7 +93,7 @@ config VGA config QXL bool - depends on SPICE && PCI + depends on SPICE && PCI && PIXMAN select VGA config VIRTIO_GPU
ui/meson.build +6 -6
@@ -133,7 +133,7 @@ if sdl.found() ui_modules += {'sdl' : sdl_ss} endif -if spice.found() +if spice.found() and pixman.found() spice_core_ss = ss.source_set() spice_core_ss.add(spice, pixman, files( 'spice-core.c',
@@ -141,12 +141,12 @@ if spice.found() 'spice-display.c' )) ui_modules += {'spice-core' : spice_core_ss} -endif -if spice.found() and gio.found() - spice_ss = ss.source_set() - spice_ss.add(spice, gio, pixman, files('spice-app.c')) - ui_modules += {'spice-app': spice_ss} + if gio.found() + spice_ss = ss.source_set() + spice_ss.add(spice, gio, pixman, files('spice-app.c')) + ui_modules += {'spice-app': spice_ss} + endif endif keymaps = [
Signature · 1 line
2.41.0
Re: [PATCH 61/67] ui/spice: SPICE/QXL requires PIXMAN
Quoted 13 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- hw/display/Kconfig | 2 +- ui/meson.build | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)hw/display/Kconfig +0
-0
hw/display/Kconfig config VGA · line 96
Quoted 5 lines
hw/display/Kconfig +1
-1@@ -93,7 +93,7 @@ config VGA config QXL bool - depends on SPICE && PCI + depends on SPICE && PCI && PIXMAN
Shouldn't this be:
Kconfig.host +1 -1
@@ -14,4 +14,5 @@ config X11 config SPICE bool + depends on PIXMAN ---
?
Quoted 33 lines
hw/display/Kconfig +0
-0config VIRTIO_GPUui/meson.build +6
-6@@ -133,7 +133,7 @@ if sdl.found() ui_modules += {'sdl' : sdl_ss} endif -if spice.found() +if spice.found() and pixman.found() spice_core_ss = ss.source_set() spice_core_ss.add(spice, pixman, files( 'spice-core.c',@@ -141,12 +141,12 @@ if spice.found() 'spice-display.c' )) ui_modules += {'spice-core' : spice_core_ss} -endif -if spice.found() and gio.found() - spice_ss = ss.source_set() - spice_ss.add(spice, gio, pixman, files('spice-app.c')) - ui_modules += {'spice-app': spice_ss} + if gio.found() + spice_ss = ss.source_set() + spice_ss.add(spice, gio, pixman, files('spice-app.c')) + ui_modules += {'spice-app': spice_ss} + endif endif keymaps = [
Re: [PATCH 61/67] ui/spice: SPICE/QXL requires PIXMAN
Il mer 30 ago 2023, 17:21 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 25 lines · On 30/8/23 11:38, [email protected] wrote:
Quoted 13 lines
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- hw/display/Kconfig | 2 +- ui/meson.build | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)hw/display/Kconfig +0
-0hw/display/Kconfig config VGA · line 96
Quoted 5 lines
hw/display/Kconfig +1
-1@@ -93,7 +93,7 @@ config VGA config QXL bool - depends on SPICE && PCI + depends on SPICE && PCI && PIXMANShouldn't this be:
Kconfig.host config X11 · line 17
Quoted 4 lines
Kconfig.host +1
-0@@ -14,4 +14,5 @@ config X11 config SPICE bool + depends on PIXMAN
No, all that would do is fail the build if SPICE=y and PIXMAN=n, but right now chardev/ has code that needs Spice but not pixman.
Paolo
Quoted 39 lines
Kconfig.host +0
-1---?
Quoted 33 lines
hw/display/Kconfig +0
-0config VIRTIO_GPUui/meson.build +6
-6@@ -133,7 +133,7 @@ if sdl.found() ui_modules += {'sdl' : sdl_ss} endif -if spice.found() +if spice.found() and pixman.found() spice_core_ss = ss.source_set() spice_core_ss.add(spice, pixman, files( 'spice-core.c',@@ -141,12 +141,12 @@ if spice.found() 'spice-display.c' )) ui_modules += {'spice-core' : spice_core_ss} -endif -if spice.found() and gio.found() - spice_ss = ss.source_set() - spice_ss.add(spice, gio, pixman, files('spice-app.c')) - ui_modules += {'spice-app': spice_ss} + if gio.found() + spice_ss = ss.source_set() + spice_ss.add(spice, gio, pixman, files('spice-app.c')) + ui_modules += {'spice-app': spice_ss} + endif endif keymaps = [
Re: [PATCH 61/67] ui/spice: SPICE/QXL requires PIXMAN
In reply to [email protected]ui/meson.build if sdl.found() · line 136
Quoted 10 lines · On 8/30/23 11:38, [email protected] wrote:
ui/meson.build +1
-1@@ -133,7 +133,7 @@ if sdl.found() ui_modules += {'sdl' : sdl_ss} endif -if spice.found() +if spice.found() and pixman.found()
Does the spice chardev make sense without pixman? If not, please use the same .disable_auto_if and .require logic as VNC.
Paolo
PATCH 62/67 ui/gtk: -display gtk requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- ui/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ui/meson.build +1 -1
@@ -105,7 +105,7 @@ if dbus_display ui_modules += {'dbus' : dbus_ss} endif -if gtk.found() +if gtk.found() and pixman.found() system_ss.add(when: 'CONFIG_WIN32', if_true: files('win32-kbd-hook.c')) gtk_ss = ss.source_set()
Signature · 1 line
2.41.0
PATCH 63/67 ui/dbus: do not require PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Implement a fallback path for region 2D update.
--- ui/dbus-listener.c | 62 ++++++++++++++++++++++++++++++---------------- ui/meson.build | 2 +- 2 files changed, 42 insertions(+), 22 deletions(-)
ui/dbus-listener.c +41 -21
@@ -562,13 +562,51 @@ static void dbus_gl_gfx_update(DisplayChangeListener *dcl, }#endif +static void dbus_gfx_update_sub (DBusDisplayListener *ddl, +int x,int y,int w,int h) +{ +pixman_image_t *img; +size_t stride; +GVariant *v_data; + +/* make a copy, since gvariant only handles linear data */ + stride = w *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (surface_format (ddl->ds)),8 ); + img =pixman_image_create_bits (surface_format (ddl->ds), + w, h,NULL , stride); +#ifdef CONFIG_PIXMAN +pixman_image_composite (PIXMAN_OP_SRC , ddl->ds->image,NULL , img, + x, y,0 ,0 ,0 ,0 , w, h); +#else + { +uint8_t *src =pixman_image_get_data (ddl->ds->image); +uint8_t *dst =pixman_image_get_data (img); +int bp =PIXMAN_FORMAT_BPP (surface_format (ddl->ds)) /8 ; +int hh; + +for (hh =0 ; hh < h; hh++) { +memcpy (&dst[stride * hh], &src[surface_stride (ddl->ds) * (hh + y) + x * bp], stride); + } + } +#endif + v_data =g_variant_new_from_data ( +G_VARIANT_TYPE ("ay" ), +pixman_image_get_data (img), +pixman_image_get_stride (img) * h, + TRUE, + (GDestroyNotify )pixman_image_unref, + img); +qemu_dbus_display1_listener_call_update (ddl->proxy, + x, y, w, h,pixman_image_get_stride (img),pixman_image_get_format (img), + v_data, +G_DBUS_CALL_FLAGS_NONE , +DBUS_DEFAULT_TIMEOUT ,NULL ,NULL ,NULL ); +} +static void dbus_gfx_update (DisplayChangeListener *dcl,int x,int y,int w,int h) {DBusDisplayListener *ddl =container_of (dcl, DBusDisplayListener, dcl); -pixman_image_t *img;GVariant *v_data; -size_t stride;assert (ddl->ds);
@@ -605,25 +643,7 @@ static void dbus_gfx_update(DisplayChangeListener *dcl,return ; } -/* make a copy, since gvariant only handles linear data */ - stride = w *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (surface_format (ddl->ds)),8 ); - img =pixman_image_create_bits (surface_format (ddl->ds), - w, h,NULL , stride); -pixman_image_composite (PIXMAN_OP_SRC , ddl->ds->image,NULL , img, - x, y,0 ,0 ,0 ,0 , w, h); - - v_data =g_variant_new_from_data ( -G_VARIANT_TYPE ("ay" ), -pixman_image_get_data (img), -pixman_image_get_stride (img) * h, - TRUE, - (GDestroyNotify )pixman_image_unref, - img); -qemu_dbus_display1_listener_call_update (ddl->proxy, - x, y, w, h,pixman_image_get_stride (img),pixman_image_get_format (img), - v_data, -G_DBUS_CALL_FLAGS_NONE , -DBUS_DEFAULT_TIMEOUT ,NULL ,NULL ,NULL ); +dbus_gfx_update_sub (ddl, x, y, w, h); }#ifdef CONFIG_OPENGL
ui/meson.build +1 -1
@@ -93,7 +93,7 @@ if dbus_display '--generate-c-code', '@BASENAME@']) dbus_display1_lib = static_library('dbus-display1', dbus_display1, dependencies: gio) dbus_display1_dep = declare_dependency(link_with: dbus_display1_lib, include_directories: include_directories('.')) - dbus_ss.add(when: [gio, pixman, dbus_display1_dep], + dbus_ss.add(when: [gio, dbus_display1_dep], if_true: [files( 'dbus-chardev.c', 'dbus-clipboard.c',
Signature · 1 line
2.41.0
PATCH 64/67 arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The Display Port has some strong PIXMAN dependency.
--- hw/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/Kconfig +1 -1
@@ -451,7 +451,7 @@ config STM32F405_SOC config XLNX_ZYNQMP_ARM bool default y - depends on TCG && AARCH64 + depends on TCG && AARCH64 && PIXMAN select AHCI select ARM_GIC select CADENCE
Signature · 1 line
2.41.0
Re: [PATCH 64/67] arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN
Quoted 14 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The Display Port has some strong PIXMAN dependency.
Signed-off-by Marc-André Lureau <[email protected]>--- hw/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/Kconfig +0
-0
hw/arm/Kconfig config STM32F405_SOC · line 454
Quoted 5 lines
hw/arm/Kconfig +1
-1@@ -451,7 +451,7 @@ config STM32F405_SOC config XLNX_ZYNQMP_ARM bool default y - depends on TCG && AARCH64 + depends on TCG && AARCH64 && PIXMAN
Better would be to add a proper Kconfig XLNX_DISPLAYPORT.
Quoted 3 lines
hw/arm/Kconfig +0
-0select AHCI select ARM_GIC select CADENCE
PATCH 65/67 ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
SM501 is going to depend on PIXMAN next.
--- configs/devices/ppc-softmmu/default.mak | 2 +- hw/ppc/Kconfig | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
configs/devices/ppc-softmmu/default.mak +1 -1
@@ -8,7 +8,7 @@ CONFIG_PPC440=y CONFIG_VIRTEX=y # For Sam460ex -CONFIG_SAM460EX=y +#CONFIG_SAM460EX=n # For Macs CONFIG_MAC_OLDWORLD=y
hw/ppc/Kconfig +2 -0
@@ -58,6 +58,8 @@ config PPC4XX config SAM460EX bool + default y + depends on PPC && PIXMAN select PFLASH_CFI01 select IDE_SII3112 select M41T80
Signature · 1 line
2.41.0
Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
Quoted 3 lines · On Wed, 30 Aug 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
SM501 is going to depend on PIXMAN next.
Why is this patch needed when SM501 is the one that depends on PIXMAN and should pull in the dependency? Also what's the change in default.mak? ati-vga also uses pixman and currently has no fall back. The sm501 already has fallback when pixman fails so could work without pixman too, see x-pixman property in sm501.c.
Regards,
BALATON Zoltan
Quoted 33 lines
Signed-off-by Marc-André Lureau <[email protected]>---
configs/devices/ppc-softmmu/default.mak | 2 +-
hw/ppc/Kconfig | 2 ++2 files changed, 3 insertions(+), 1 deletion(-)configs/devices/ppc-softmmu/default.mak +0
-0@@ -8,7 +8,7 @@ CONFIG_PPC440=y
CONFIG_VIRTEX=y# For Sam460ex
configs/devices/ppc-softmmu/default.mak +1
-1-CONFIG_SAM460EX=y +#CONFIG_SAM460EX=n# For Macs
CONFIG_MAC_OLDWORLD=yhw/ppc/Kconfig +0
-0@@ -58,6 +58,8 @@ config PPC4XXconfig SAM460EX
boolhw/ppc/Kconfig +2
-0+ default y + depends on PPC && PIXMAN select PFLASH_CFI01 select IDE_SII3112 select M41T80
Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
Quoted 6 lines · BALATON Zoltan
Quoted 4 lines
From: Marc-André Lureau <[email protected]>
SM501 is going to depend on PIXMAN next.
Why is this patch needed when SM501 is the one that depends on PIXMAN and should pull in the dependency? Also what's the change in default.mak?
The change in default.mak is needed because the default is moved from there to hw/ppc/Kconfig. Without it,
# configs/devices/ppc-softmmu/default.mak
CONFIG_SAM460EX=y # hw/ppc/Kconfig
config SAM460EX
depends on PPC && PIXMANfails to compile without pixman, due to a contradiction (default.mak requires enabling SAM460EX, hw/ppc/Kconfig requires disabling it because CONFIG_PIXMAN=n).
Quoted 1 line
ati-vga also uses pixman and currently has no fall back. The sm501 already has fallback when pixman fails so could work without pixman too, see x-pixman property in
sm501.c.
Yeah, this means there are changes needed in both this patch and ATI.
Paolo
Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
In reply to BALATON ZoltanHi
Quoted 8 lines · BALATON Zoltan
Quoted 3 lines · On Wed, 30 Aug 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
SM501 is going to depend on PIXMAN next.
Why is this patch needed when SM501 is the one that depends on PIXMAN and should pull in the dependency? Also what's the change in default.mak?
(see Paolo answer)
Quoted 1 line
ati-vga also uses pixman and currently has no fall back.
Indeed, and it is disabled not by Kconfig but by meson:
system_ss.add(when: [pixman, 'CONFIG_ATI_VGA'], if_true:files('ati.c', 'ati_2d.c', 'ati_dbg.c'))
Quoted 3 lines
The sm501 already
has fallback when pixman fails so could work without pixman too, see x-pixman property insm501.c.
Correct, I have changed it to conditionally compile x-pixman related code.
thanks
Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
Quoted 3 lines · Marc-André Lureau
Indeed, and it is disabled not by
Kconfigbut by meson:
system_ss.add(when: [pixman, 'CONFIG_ATI_VGA'],if_true:files('ati.c', 'ati_2d.c', 'ati_dbg.c'))
It's better to add a "depends on", so that it fails to compile with --disable-pixman. Without it, you're left with possible runtime failures where boards expect ATI_VGA to be there.
Paolo
Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
In reply to [email protected]Quoted 15 lines · On 8/30/23 11:38, [email protected] wrote:
From: Marc-André Lureau<[email protected]>
SM501 is going to depend on PIXMAN next.
Signed-off-by Marc-André Lureau<[email protected]>--- configs/devices/ppc-softmmu/default.mak | 2 +- hw/ppc/Kconfig | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)configs/devices/ppc-softmmu/default.mak +0
-0
configs/devices/ppc-softmmu/default.mak CONFIG_PPC440=y · line 11
Quoted 5 lines
configs/devices/ppc-softmmu/default.mak +1
-1@@ -8,7 +8,7 @@ CONFIG_PPC440=y CONFIG_VIRTEX=y # For Sam460ex -CONFIG_SAM460EX=y +#CONFIG_SAM460EX=n
This reminds me that we were planning to move all boards from "default n" to "default y", similar to ARM boards. But for now this is okay.
Paolo
PATCH 66/67 sh4/kconfig: make R2D depend on SH4 & PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
SM501 is going to depend on PIXMAN next.
--- configs/devices/sh4-softmmu/default.mak | 2 +- hw/sh4/Kconfig | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
configs/devices/sh4-softmmu/default.mak +1 -1
@@ -7,5 +7,5 @@ # Boards: # -CONFIG_R2D=y +#CONFIG_R2D=n CONFIG_SHIX=y
hw/sh4/Kconfig +2 -0
@@ -1,5 +1,7 @@ config R2D bool + default y + depends on SH4 && PIXMAN imply PCI_DEVICES imply TEST_DEVICES imply RTL8139_PCI
Signature · 1 line
2.41.0
PATCH 67/67 display/kconfig: make SM501 depend on PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- hw/display/Kconfig | 1 + 1 file changed, 1 insertion(+)
hw/display/Kconfig +1 -0
@@ -74,6 +74,7 @@ config FRAMEBUFFER config SM501 bool + depends on PIXMAN select I2C select DDC select SERIAL
Signature · 1 line
2.41.0
Re: [PATCH 67/67] display/kconfig: make SM501 depend on PIXMAN
Quoted 12 lines · On 30/8/23 11:38, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- hw/display/Kconfig | 1 + 1 file changed, 1 insertion(+)hw/display/Kconfig +0
-0
hw/display/Kconfig config FRAMEBUFFER · line 80
Quoted 7 lines
hw/display/Kconfig +1
-0@@ -74,6 +74,7 @@ config FRAMEBUFFER config SM501 bool + depends on PIXMAN select I2C select DDC select SERIAL
SM501 optionally use pixman, so by adding some CONFIG_PIXMAN #ifdefry in hw/display/sm501.c we can compile it without pixman.
Quoted 21 lines · On 30/08/2023 11.37, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Hi,
QEMU system emulators can be made to compile and work without pixman.
Given how pervasively pixman types and API is used in all the code base, it was a bit difficult to figure out how to cut the dependency.
I decided that it was important to keep VGA and graphics device working for compatibility reasons, although some devices, such as xlnx Display Port, have stronger dependency and have to be disabled. The ui/console code also has a lot of pixman usage and a bit of a mess to deal with. I made large refactoring to allow to compile out the VC code.
The series can be roughly divded as:
- a few related preliminary cleanups
- ui/console refactoring to allow ui/vc split
- add a 'pixman' option, and a minimalpixman-compat.h
- make some parts depend on 'pixman'
Quoted 3 lines
Graphic -display still work, although with some caveats. For ex, -display sdl or cocoa don't have VCs, so starting QEMU will print the following warnings when pixman is disabled:
I just had a quick look at the series, but for me it looks like this is adding a lot of additional complexity to the code (adds lots of #ifdefs, and adds a subset of the pixman library to the code base), which seems somewhat unfortunate for such a marginal feature request. What's really so bad about requiring pixman for building QEMU?
IMHO, if we really want to go down this path, I think we should rather disable all graphic related stuff in QEMU instead, i.e. disable VGA cards, Spice, SDL, etc. completely. I think this is also what has been requested in the original gitlab issue ticket where the reporter wanted to compile a text-mode only QEMU binary...?
... just my 0.02 € anyway.
Thomas
Hi
Quoted 23 lines · Thomas Huth
Quoted 21 lines · On 30/08/2023 11.37, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Hi,
QEMU system emulators can be made to compile and work without pixman.
Given how pervasively pixman types and API is used in all the code base, it was a bit difficult to figure out how to cut the dependency.
I decided that it was important to keep VGA and graphics device working for compatibility reasons, although some devices, such as xlnx Display Port, have stronger dependency and have to be disabled. The ui/console code also has a lot of pixman usage and a bit of a mess to deal with. I made large refactoring to allow to compile out the VC code.
The series can be roughly divded as:
- a few related preliminary cleanups
- ui/console refactoring to allow ui/vc split
- add a 'pixman' option, and a minimalpixman-compat.h
- make some parts depend on 'pixman'
Quoted 7 lines
Quoted 3 lines
Graphic -display still work, although with some caveats. For ex, -display sdl or cocoa don't have VCs, so starting QEMU will print the following warnings when pixman is disabled:
I just had a quick look at the series, but for me it looks like this is adding a lot of additional complexity to the code (adds lots of #ifdefs, and adds a subset of the pixman library to the code base), which seems somewhat
The #ifdef aren't so bad (at least I can bare it). Just a quick stat:
$ git diff origin/master | grep "+#ifdef CONFIG_PIXMAN" | wc -l 11
Quoted 2 lines
unfortunate for such a marginal feature request. What's really so bad about requiring pixman for building QEMU?
Not that a good part of the series is cleaning up ui/console.c code that really deserved it. It makes it use QOM, and split VC code. It's still worth it regardless of the outcome for pixman.
Quoted 4 lines
IMHO, if we really want to go down this path, I think we should rather disable all graphic related stuff in QEMU instead, i.e. disable VGA cards, Spice, SDL, etc. completely. I think this is also what has been requested in
The various features and devices can be disabled by other means. I think we should aim at making the different configure options orthogonal, so QEMU without pixman can still provide most gfx/vga/UI experience too, by default.
Quoted 2 lines
the original gitlab issue ticket where the reporter wanted to compile a text-mode only QEMU binary...?
So that is not an incompatible goal, further tuning of configure options can help.
Quoted 39 lines · Marc-André Lureau
Hi
Quoted 23 lines · Thomas Huth
Quoted 21 lines · On 30/08/2023 11.37, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Hi,
QEMU system emulators can be made to compile and work without pixman.
Given how pervasively pixman types and API is used in all the code base, it was a bit difficult to figure out how to cut the dependency.
I decided that it was important to keep VGA and graphics device working for compatibility reasons, although some devices, such as xlnx Display Port, have stronger dependency and have to be disabled. The ui/console code also has a lot of pixman usage and a bit of a mess to deal with. I made large refactoring to allow to compile out the VC code.
The series can be roughly divded as:
- a few related preliminary cleanups
- ui/console refactoring to allow ui/vc split
- add a 'pixman' option, and a minimalpixman-compat.h
- make some parts depend on 'pixman'Quoted 7 lines
Quoted 3 lines
Graphic -display still work, although with some caveats. For ex, -display sdl or cocoa don't have VCs, so starting QEMU will print the following warnings when pixman is disabled:
I just had a quick look at the series, but for me it looks like this is adding a lot of additional complexity to the code (adds lots of #ifdefs, and adds a subset of the pixman library to the code base), which seems somewhat
The #ifdef aren't so bad (at least I can bare it). Just a quick stat:
$ git diff origin/master | grep "+#ifdef CONFIG_PIXMAN" | wc -l 11
Quoted 6 lines
Quoted 2 lines
unfortunate for such a marginal feature request. What's really so bad about requiring pixman for building QEMU?
Not that a good part of the series is cleaning up
ui/console.ccode that really deserved it. It makes it use QOM, and split VC code. It's still worth it regardless of the outcome for pixman.
I've done a review of the start and like the cleanup patches, and the adaption to make sane use of inheritance in QOM rather than the poor man's inheritance via the console type field. I agree that's worthwhile regardless of what we think about pixman optionality.
Quoted 9 lines
Quoted 4 lines
IMHO, if we really want to go down this path, I think we should rather disable all graphic related stuff in QEMU instead, i.e. disable VGA cards, Spice, SDL, etc. completely. I think this is also what has been requested in
The various features and devices can be disabled by other means. I think we should aim at making the different configure options orthogonal, so QEMU without pixman can still provide most gfx/vga/UI experience too, by default.
To me where this series becomes dubious is roughly around the patch that adds pixman-compat.h providing a bunch of pixman API as stubs.
If we can use Kconfig and/or meson options to simply drop the build of files in QEMU that require pixman that's reasonable. If we're adding compat APIs the provide local impls of pixman APIs it feels wrong to me.
Quoted 5 lines
Quoted 2 lines
the original gitlab issue ticket where the reporter wanted to compile a text-mode only QEMU binary...?
So that is not an incompatible goal, further tuning of configure options can help.
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 :|
Hi
Quoted 58 lines · Daniel P. Berrangé
Quoted 39 lines · Marc-André Lureau
Hi
Quoted 23 lines · Thomas Huth
Quoted 21 lines · On 30/08/2023 11.37, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Hi,
QEMU system emulators can be made to compile and work without pixman.
Given how pervasively pixman types and API is used in all the code base, it was a bit difficult to figure out how to cut the dependency.
I decided that it was important to keep VGA and graphics device working for compatibility reasons, although some devices, such as xlnx Display Port, have stronger dependency and have to be disabled. The ui/console code also has a lot of pixman usage and a bit of a mess to deal with. I made large refactoring to allow to compile out the VC code.
The series can be roughly divded as:
- a few related preliminary cleanups
- ui/console refactoring to allow ui/vc split
- add a 'pixman' option, and a minimalpixman-compat.h
- make some parts depend on 'pixman'Quoted 7 lines
Quoted 3 lines
Graphic -display still work, although with some caveats. For ex, -display sdl or cocoa don't have VCs, so starting QEMU will print the following warnings when pixman is disabled:
I just had a quick look at the series, but for me it looks like this is adding a lot of additional complexity to the code (adds lots of #ifdefs, and adds a subset of the pixman library to the code base), which seems somewhat
The #ifdef aren't so bad (at least I can bare it). Just a quick stat:
$ git diff origin/master | grep "+#ifdef CONFIG_PIXMAN" | wc -l 11Quoted 6 lines
Quoted 2 lines
unfortunate for such a marginal feature request. What's really so bad about requiring pixman for building QEMU?
Not that a good part of the series is cleaning up
ui/console.ccode that really deserved it. It makes it use QOM, and split VC code. It's still worth it regardless of the outcome for pixman.I've done a review of the start and like the cleanup patches, and the adaption to make sane use of inheritance in QOM rather than the poor man's inheritance via the console type field. I agree that's worthwhile regardless of what we think about pixman optionality.
Quoted 5 lines
Quoted 4 lines
IMHO, if we really want to go down this path, I think we should rather disable all graphic related stuff in QEMU instead, i.e. disable VGA cards, Spice, SDL, etc. completely. I think this is also what has been requested in
Quoted 7 lines
Quoted 4 lines
The various features and devices can be disabled by other means. I think we should aim at making the different configure options orthogonal, so QEMU without pixman can still provide most gfx/vga/UI experience too, by default.
To me where this series becomes dubious is roughly around the patch that adds
pixman-compat.hproviding a bunch of pixman API as stubs.
Not stubs actually... this shows that you haven't looked at it enough :)
It's really stupid, nothing like pixman! it just provides a few types.
See my reply on the patch.
Completely removing those few pixman types from QEMU will lead to a very unpleasant and complicated result.
I can give it another try, or you may also play with it and prove me wrong. At least, I can come up with a better list of arguments.