* [PATCH 01/67] ui: remove qemu_pixman_color() helper
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 10:03 ` Philippe Mathieu-Daudé
2023-08-30 10:59 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 02/67] ui: remove qemu_pixman_linebuf_copy() marcandre.lureau
` (66 subsequent siblings)
67 siblings, 2 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Usage removed in commit e27bd65a72d ("console: switch color_table_rgb to pixman_color_t")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/qemu-pixman.h | 1 -
ui/qemu-pixman.c | 11 -----------
2 files changed, 12 deletions(-)
diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index 0c775604d1..fd78d17124 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -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,
diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index e4f024a85e..c5053cd326 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -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)
{
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 01/67] ui: remove qemu_pixman_color() helper
2023-08-30 9:37 ` [PATCH 01/67] ui: remove qemu_pixman_color() helper marcandre.lureau
@ 2023-08-30 10:03 ` Philippe Mathieu-Daudé
2023-08-30 10:59 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 10:03 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann
On 30/8/23 11:37, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Usage removed in commit e27bd65a72d ("console: switch color_table_rgb to pixman_color_t")
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/ui/qemu-pixman.h | 1 -
> ui/qemu-pixman.c | 11 -----------
> 2 files changed, 12 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 01/67] ui: remove qemu_pixman_color() helper
2023-08-30 9:37 ` [PATCH 01/67] ui: remove qemu_pixman_color() helper marcandre.lureau
2023-08-30 10:03 ` Philippe Mathieu-Daudé
@ 2023-08-30 10:59 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-08-30 10:59 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:37:35PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Usage removed in commit e27bd65a72d ("console: switch color_table_rgb to pixman_color_t")
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/ui/qemu-pixman.h | 1 -
> ui/qemu-pixman.c | 11 -----------
> 2 files changed, 12 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 02/67] ui: remove qemu_pixman_linebuf_copy()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
2023-08-30 9:37 ` [PATCH 01/67] ui: remove qemu_pixman_color() helper marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 10:59 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 03/67] ui/qmp: move screendump to ui-qmp-cmds.c marcandre.lureau
` (65 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Since commit 43c7d8bd449 ("console: add qemu_pixman_linebuf_copy"), it
seems it was never used.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/qemu-pixman.h | 2 --
ui/qemu-pixman.c | 8 --------
2 files changed, 10 deletions(-)
diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index fd78d17124..ce4518e4de 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -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);
diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index c5053cd326..be00a96340 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -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)
{
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 03/67] ui/qmp: move screendump to ui-qmp-cmds.c
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
2023-08-30 9:37 ` [PATCH 01/67] ui: remove qemu_pixman_color() helper marcandre.lureau
2023-08-30 9:37 ` [PATCH 02/67] ui: remove qemu_pixman_linebuf_copy() marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:00 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write() marcandre.lureau
` (64 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/console.h | 1 +
ui/console.c | 212 ++++---------------------------------------
ui/ui-qmp-cmds.c | 187 ++++++++++++++++++++++++++++++++++++++
3 files changed, 205 insertions(+), 195 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 3e8b22d6c6..1b08b0f8ad 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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
diff --git a/ui/console.c b/ui/console.c
index 8da2170a7e..9c17024dbc 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -28,8 +28,8 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-ui.h"
#include "qemu/coroutine.h"
-#include "qemu/error-report.h"
#include "qemu/fifo8.h"
+#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qemu/option.h"
@@ -37,11 +37,7 @@
#include "chardev/char.h"
#include "trace.h"
#include "exec/memory.h"
-#include "io/channel-file.h"
#include "qom/object.h"
-#ifdef CONFIG_PNG
-#include <png.h>
-#endif
#define DEFAULT_BACKSCROLL 512
#define CONSOLE_CURSOR_PERIOD 500
@@ -239,6 +235,22 @@ void graphic_hw_update(QemuConsole *con)
}
}
+static void graphic_hw_update_bh(void *con)
+{
+ graphic_hw_update(con);
+}
+
+void qemu_console_co_wait_update(QemuConsole *con)
+{
+ if (qemu_co_queue_empty(&con->dump_queue)) {
+ /* Defer the update, it will restart the pending coroutines */
+ aio_bh_schedule_oneshot(qemu_get_aio_context(),
+ graphic_hw_update_bh, con);
+ }
+ qemu_co_queue_wait(&con->dump_queue, NULL);
+
+}
+
static void graphic_hw_gl_unblock_timer(void *opaque)
{
warn_report("console: no gl-unblock within one second");
@@ -292,196 +304,6 @@ void graphic_hw_invalidate(QemuConsole *con)
}
}
-#ifdef CONFIG_PNG
-/**
- * png_save: Take a screenshot as PNG
- *
- * Saves screendump as a PNG file
- *
- * Returns true for success or false for error.
- *
- * @fd: File descriptor for PNG file.
- * @image: Image data in pixman format.
- * @errp: Pointer to an error.
- */
-static bool png_save(int fd, pixman_image_t *image, Error **errp)
-{
- int width = pixman_image_get_width(image);
- int height = pixman_image_get_height(image);
- png_struct *png_ptr;
- png_info *info_ptr;
- g_autoptr(pixman_image_t) linebuf =
- qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width);
- uint8_t *buf = (uint8_t *)pixman_image_get_data(linebuf);
- FILE *f = fdopen(fd, "wb");
- int y;
- if (!f) {
- error_setg_errno(errp, errno,
- "Failed to create file from file descriptor");
- return false;
- }
-
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
- NULL, NULL);
- if (!png_ptr) {
- error_setg(errp, "PNG creation failed. Unable to write struct");
- fclose(f);
- return false;
- }
-
- info_ptr = png_create_info_struct(png_ptr);
-
- if (!info_ptr) {
- error_setg(errp, "PNG creation failed. Unable to write info");
- fclose(f);
- png_destroy_write_struct(&png_ptr, &info_ptr);
- return false;
- }
-
- png_init_io(png_ptr, f);
-
- png_set_IHDR(png_ptr, info_ptr, width, height, 8,
- PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- png_write_info(png_ptr, info_ptr);
-
- for (y = 0; y < height; ++y) {
- qemu_pixman_linebuf_fill(linebuf, image, width, 0, y);
- png_write_row(png_ptr, buf);
- }
-
- png_write_end(png_ptr, NULL);
-
- png_destroy_write_struct(&png_ptr, &info_ptr);
-
- if (fclose(f) != 0) {
- error_setg_errno(errp, errno,
- "PNG creation failed. Unable to close file");
- return false;
- }
-
- return true;
-}
-
-#else /* no png support */
-
-static bool png_save(int fd, pixman_image_t *image, Error **errp)
-{
- error_setg(errp, "Enable PNG support with libpng for screendump");
- return false;
-}
-
-#endif /* CONFIG_PNG */
-
-static bool ppm_save(int fd, pixman_image_t *image, Error **errp)
-{
- int width = pixman_image_get_width(image);
- int height = pixman_image_get_height(image);
- g_autoptr(Object) ioc = OBJECT(qio_channel_file_new_fd(fd));
- g_autofree char *header = NULL;
- g_autoptr(pixman_image_t) linebuf = NULL;
- int y;
-
- trace_ppm_save(fd, image);
-
- header = g_strdup_printf("P6\n%d %d\n%d\n", width, height, 255);
- if (qio_channel_write_all(QIO_CHANNEL(ioc),
- header, strlen(header), errp) < 0) {
- return false;
- }
-
- linebuf = qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width);
- for (y = 0; y < height; y++) {
- qemu_pixman_linebuf_fill(linebuf, image, width, 0, y);
- if (qio_channel_write_all(QIO_CHANNEL(ioc),
- (char *)pixman_image_get_data(linebuf),
- pixman_image_get_stride(linebuf), errp) < 0) {
- return false;
- }
- }
-
- return true;
-}
-
-static void graphic_hw_update_bh(void *con)
-{
- graphic_hw_update(con);
-}
-
-/* Safety: coroutine-only, concurrent-coroutine safe, main thread only */
-void coroutine_fn
-qmp_screendump(const char *filename, const char *device,
- bool has_head, int64_t head,
- bool has_format, ImageFormat format, Error **errp)
-{
- g_autoptr(pixman_image_t) image = NULL;
- QemuConsole *con;
- DisplaySurface *surface;
- int fd;
-
- if (device) {
- con = qemu_console_lookup_by_device_name(device, has_head ? head : 0,
- errp);
- if (!con) {
- return;
- }
- } else {
- if (has_head) {
- error_setg(errp, "'head' must be specified together with 'device'");
- return;
- }
- con = qemu_console_lookup_by_index(0);
- if (!con) {
- error_setg(errp, "There is no console to take a screendump from");
- return;
- }
- }
-
- if (qemu_co_queue_empty(&con->dump_queue)) {
- /* Defer the update, it will restart the pending coroutines */
- aio_bh_schedule_oneshot(qemu_get_aio_context(),
- graphic_hw_update_bh, con);
- }
- qemu_co_queue_wait(&con->dump_queue, NULL);
-
- /*
- * All pending coroutines are woken up, while the BQL is held. No
- * further graphic update are possible until it is released. Take
- * an image ref before that.
- */
- surface = qemu_console_surface(con);
- if (!surface) {
- error_setg(errp, "no surface");
- return;
- }
- image = pixman_image_ref(surface->image);
-
- fd = qemu_open_old(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- if (fd == -1) {
- error_setg(errp, "failed to open file '%s': %s", filename,
- strerror(errno));
- return;
- }
-
- /*
- * The image content could potentially be updated as the coroutine
- * yields and releases the BQL. It could produce corrupted dump, but
- * it should be otherwise safe.
- */
- if (has_format && format == IMAGE_FORMAT_PNG) {
- /* PNG format specified for screendump */
- if (!png_save(fd, image, errp)) {
- qemu_unlink(filename);
- }
- } else {
- /* PPM format specified/default for screendump */
- if (!ppm_save(fd, image, errp)) {
- qemu_unlink(filename);
- }
- }
-}
-
void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
{
if (!con) {
diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
index a37a7024f3..debc07d678 100644
--- a/ui/ui-qmp-cmds.c
+++ b/ui/ui-qmp-cmds.c
@@ -14,13 +14,20 @@
*/
#include "qemu/osdep.h"
+
+#include "io/channel-file.h"
#include "monitor/qmp-helpers.h"
#include "qapi/qapi-commands-ui.h"
#include "qapi/qmp/qerror.h"
+#include "qemu/coroutine.h"
#include "qemu/cutils.h"
+#include "trace.h"
#include "ui/console.h"
#include "ui/dbus-display.h"
#include "ui/qemu-spice.h"
+#ifdef CONFIG_PNG
+#include <png.h>
+#endif
void qmp_set_password(SetPasswordOptions *opts, Error **errp)
{
@@ -204,3 +211,183 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "'spice'");
}
+
+#ifdef CONFIG_PNG
+/**
+ * png_save: Take a screenshot as PNG
+ *
+ * Saves screendump as a PNG file
+ *
+ * Returns true for success or false for error.
+ *
+ * @fd: File descriptor for PNG file.
+ * @image: Image data in pixman format.
+ * @errp: Pointer to an error.
+ */
+static bool png_save(int fd, pixman_image_t *image, Error **errp)
+{
+ int width = pixman_image_get_width(image);
+ int height = pixman_image_get_height(image);
+ png_struct *png_ptr;
+ png_info *info_ptr;
+ g_autoptr(pixman_image_t) linebuf =
+ qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width);
+ uint8_t *buf = (uint8_t *)pixman_image_get_data(linebuf);
+ FILE *f = fdopen(fd, "wb");
+ int y;
+ if (!f) {
+ error_setg_errno(errp, errno,
+ "Failed to create file from file descriptor");
+ return false;
+ }
+
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
+ NULL, NULL);
+ if (!png_ptr) {
+ error_setg(errp, "PNG creation failed. Unable to write struct");
+ fclose(f);
+ return false;
+ }
+
+ info_ptr = png_create_info_struct(png_ptr);
+
+ if (!info_ptr) {
+ error_setg(errp, "PNG creation failed. Unable to write info");
+ fclose(f);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+ return false;
+ }
+
+ png_init_io(png_ptr, f);
+
+ png_set_IHDR(png_ptr, info_ptr, width, height, 8,
+ PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+
+ png_write_info(png_ptr, info_ptr);
+
+ for (y = 0; y < height; ++y) {
+ qemu_pixman_linebuf_fill(linebuf, image, width, 0, y);
+ png_write_row(png_ptr, buf);
+ }
+
+ png_write_end(png_ptr, NULL);
+
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+
+ if (fclose(f) != 0) {
+ error_setg_errno(errp, errno,
+ "PNG creation failed. Unable to close file");
+ return false;
+ }
+
+ return true;
+}
+
+#else /* no png support */
+
+static bool png_save(int fd, pixman_image_t *image, Error **errp)
+{
+ error_setg(errp, "Enable PNG support with libpng for screendump");
+ return false;
+}
+
+#endif /* CONFIG_PNG */
+
+static bool ppm_save(int fd, pixman_image_t *image, Error **errp)
+{
+ int width = pixman_image_get_width(image);
+ int height = pixman_image_get_height(image);
+ g_autoptr(Object) ioc = OBJECT(qio_channel_file_new_fd(fd));
+ g_autofree char *header = NULL;
+ g_autoptr(pixman_image_t) linebuf = NULL;
+ int y;
+
+ trace_ppm_save(fd, image);
+
+ header = g_strdup_printf("P6\n%d %d\n%d\n", width, height, 255);
+ if (qio_channel_write_all(QIO_CHANNEL(ioc),
+ header, strlen(header), errp) < 0) {
+ return false;
+ }
+
+ linebuf = qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width);
+ for (y = 0; y < height; y++) {
+ qemu_pixman_linebuf_fill(linebuf, image, width, 0, y);
+ if (qio_channel_write_all(QIO_CHANNEL(ioc),
+ (char *)pixman_image_get_data(linebuf),
+ pixman_image_get_stride(linebuf), errp) < 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/* Safety: coroutine-only, concurrent-coroutine safe, main thread only */
+void coroutine_fn
+qmp_screendump(const char *filename, const char *device,
+ bool has_head, int64_t head,
+ bool has_format, ImageFormat format, Error **errp)
+{
+ g_autoptr(pixman_image_t) image = NULL;
+ QemuConsole *con;
+ DisplaySurface *surface;
+ int fd;
+
+ if (device) {
+ con = qemu_console_lookup_by_device_name(device, has_head ? head : 0,
+ errp);
+ if (!con) {
+ return;
+ }
+ } else {
+ if (has_head) {
+ error_setg(errp, "'head' must be specified together with 'device'");
+ return;
+ }
+ con = qemu_console_lookup_by_index(0);
+ if (!con) {
+ error_setg(errp, "There is no console to take a screendump from");
+ return;
+ }
+ }
+
+ qemu_console_co_wait_update(con);
+
+ /*
+ * All pending coroutines are woken up, while the BQL is held. No
+ * further graphic update are possible until it is released. Take
+ * an image ref before that.
+ */
+ surface = qemu_console_surface(con);
+ if (!surface) {
+ error_setg(errp, "no surface");
+ return;
+ }
+ image = pixman_image_ref(surface->image);
+
+ fd = qemu_open_old(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ if (fd == -1) {
+ error_setg(errp, "failed to open file '%s': %s", filename,
+ strerror(errno));
+ return;
+ }
+
+ /*
+ * The image content could potentially be updated as the coroutine
+ * yields and releases the BQL. It could produce corrupted dump, but
+ * it should be otherwise safe.
+ */
+ if (has_format && format == IMAGE_FORMAT_PNG) {
+ /* PNG format specified for screendump */
+ if (!png_save(fd, image, errp)) {
+ qemu_unlink(filename);
+ }
+ } else {
+ /* PPM format specified/default for screendump */
+ if (!ppm_save(fd, image, errp)) {
+ qemu_unlink(filename);
+ }
+ }
+}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (2 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 03/67] ui/qmp: move screendump to ui-qmp-cmds.c marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 10:04 ` Philippe Mathieu-Daudé
2023-08-30 11:01 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 05/67] ui/vc: drop have_text marcandre.lureau
` (63 subsequent siblings)
67 siblings, 2 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
We shouldn't call the callback directly, but use the chardev API, unless
there is a clear reason.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 9c17024dbc..a448e4d283 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write()
2023-08-30 9:37 ` [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write() marcandre.lureau
@ 2023-08-30 10:04 ` Philippe Mathieu-Daudé
2023-08-30 11:01 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 10:04 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann
On 30/8/23 11:37, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> We shouldn't call the callback directly, but use the chardev API, unless
> there is a clear reason.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write()
2023-08-30 9:37 ` [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write() marcandre.lureau
2023-08-30 10:04 ` Philippe Mathieu-Daudé
@ 2023-08-30 11:01 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-08-30 11:01 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:37:38PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> We shouldn't call the callback directly, but use the chardev API, unless
> there is a clear reason.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 05/67] ui/vc: drop have_text
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (3 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 04/67] ui/vc: replace vc_chr_write() with generic qemu_chr_write() marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:03 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 06/67] ui/console: console_select() regardless of have_gfx marcandre.lureau
` (62 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 42 +++++++++++++-----------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index a448e4d283..bec2d1a40a 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 06/67] ui/console: console_select() regardless of have_gfx
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (4 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 05/67] ui/vc: drop have_text marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:05 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 07/67] ui/console: call dpy_gfx_update() " marcandre.lureau
` (61 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index bec2d1a40a..14717a6f4d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 07/67] ui/console: call dpy_gfx_update() regardless of have_gfx
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (5 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 06/67] ui/console: console_select() regardless of have_gfx marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:06 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 08/67] ui/console: drop have_gfx marcandre.lureau
` (60 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/console.c b/ui/console.c
index 14717a6f4d..2bc4c153de 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 08/67] ui/console: drop have_gfx
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (6 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 07/67] ui/console: call dpy_gfx_update() " marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:06 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 09/67] ui/console: get the DisplayState from new_console() marcandre.lureau
` (59 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
All usages have been removed.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 2bc4c153de..fc1836782d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 09/67] ui/console: get the DisplayState from new_console()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (7 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 08/67] ui/console: drop have_gfx marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 12:39 ` BALATON Zoltan
2023-09-01 14:10 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 10/67] ui/console: new_console() cannot fail marcandre.lureau
` (58 subsequent siblings)
67 siblings, 2 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index fc1836782d..ba79c735b7 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 09/67] ui/console: get the DisplayState from new_console()
2023-08-30 9:37 ` [PATCH 09/67] ui/console: get the DisplayState from new_console() marcandre.lureau
@ 2023-08-30 12:39 ` BALATON Zoltan
2023-09-01 14:10 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: BALATON Zoltan @ 2023-08-30 12:39 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Gerd Hoffmann
[-- Attachment #1: Type: text/plain, Size: 1439 bytes --]
On Wed, 30 Aug 2023, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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 <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 26 ++++++++------------------
> 1 file changed, 8 insertions(+), 18 deletions(-)
>
> diff --git a/ui/console.c b/ui/console.c
> index fc1836782d..ba79c735b7 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -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)
It should be possible to remove the new line and fit it in one line now
too.
Regards,
BALATON Zoltan
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 09/67] ui/console: get the DisplayState from new_console()
2023-08-30 9:37 ` [PATCH 09/67] ui/console: get the DisplayState from new_console() marcandre.lureau
2023-08-30 12:39 ` BALATON Zoltan
@ 2023-09-01 14:10 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 14:10 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:37:43PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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 <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 26 ++++++++------------------
> 1 file changed, 8 insertions(+), 18 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 10/67] ui/console: new_console() cannot fail
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (8 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 09/67] ui/console: get the DisplayState from new_console() marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:07 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 11/67] ui/vc: VC always has a DisplayState now marcandre.lureau
` (57 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
There is no code path that could allow a NULL return there.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index ba79c735b7..8c4626f255 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 11/67] ui/vc: VC always has a DisplayState now
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (9 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 10/67] ui/console: new_console() cannot fail marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 13:44 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 12/67] ui/vc: move VCChardev declaration at the top marcandre.lureau
` (56 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 8c4626f255..2b8022dfbe 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 12/67] ui/vc: move VCChardev declaration at the top
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (10 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 11/67] ui/vc: VC always has a DisplayState now marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:07 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 13/67] ui/vc: replace variable with static text attributes default marcandre.lureau
` (55 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
To allow easier refactoring in following patches.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 2b8022dfbe..ad6fbb1d0f 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 13/67] ui/vc: replace variable with static text attributes default
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (11 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 12/67] ui/vc: move VCChardev declaration at the top marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 13:45 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 14/67] ui/vc: fold text_update_xy() marcandre.lureau
` (54 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index ad6fbb1d0f..9d8406f2a2 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 14/67] ui/vc: fold text_update_xy()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (12 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 13/67] ui/vc: replace variable with static text attributes default marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:08 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 15/67] ui/vc: pass VCCharDev to VC-specific functions marcandre.lureau
` (53 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 9d8406f2a2..e96f154cc0 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 15/67] ui/vc: pass VCCharDev to VC-specific functions
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (13 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 14/67] ui/vc: fold text_update_xy() marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:15 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 16/67] ui/vc: move VCCharDev specific fields out of QemuConsole marcandre.lureau
` (52 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Even though the actually use more QemuConsole at this point, it makes it
clear those functions are only used from the chardev implementation.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 70 +++++++++++++++++++++++++++++-----------------------
1 file changed, 39 insertions(+), 31 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index e96f154cc0..8fe39aa5e3 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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) {
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 16/67] ui/vc: move VCCharDev specific fields out of QemuConsole
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (14 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 15/67] ui/vc: pass VCCharDev to VC-specific functions marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:16 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 17/67] ui/console: use OBJECT_DEFINE_TYPE for QemuConsole marcandre.lureau
` (51 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 147 +++++++++++++++++++++++++--------------------------
1 file changed, 73 insertions(+), 74 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 8fe39aa5e3..b9b545fa3d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 17/67] ui/console: use OBJECT_DEFINE_TYPE for QemuConsole
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (15 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 16/67] ui/vc: move VCCharDev specific fields out of QemuConsole marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-08-30 11:09 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 18/67] ui/console: change new_console() to use object initialization marcandre.lureau
` (50 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The following patch will move some object initialization to the
corresponding handlers.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index b9b545fa3d..7d0bb819ac 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 18/67] ui/console: change new_console() to use object initialization
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (16 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 17/67] ui/console: use OBJECT_DEFINE_TYPE for QemuConsole marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:19 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 19/67] ui/console: introduce different console objects marcandre.lureau
` (49 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 93 +++++++++++++++++++++++++++++++---------------------
1 file changed, 56 insertions(+), 37 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 7d0bb819ac..bdecfe7306 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 19/67] ui/console: introduce different console objects
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (17 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 18/67] ui/console: change new_console() to use object initialization marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:20 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 20/67] ui/console: instantiate a specific console type marcandre.lureau
` (48 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Boilerplate code to introduce different object types for the different
console types.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/ui/console.c b/ui/console.c
index bdecfe7306..4ca5064cc9 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)
{
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 20/67] ui/console: instantiate a specific console type
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (18 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 19/67] ui/console: introduce different console objects marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:21 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 21/67] ui/console: register the console from qemu_console_init() marcandre.lureau
` (47 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
This will allow to move code/data to the specific console types.
Replace console_type_t with object type check.
QemuConsole can be abstract.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 47 +++++++++++++++++++----------------------------
1 file changed, 19 insertions(+), 28 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 4ca5064cc9..dd8e8db525 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)) &&
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 21/67] ui/console: register the console from qemu_console_init()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (19 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 20/67] ui/console: instantiate a specific console type marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:21 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 22/67] ui/console: remove new_console() marcandre.lureau
` (46 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index dd8e8db525..02a24eaf5d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 22/67] ui/console: remove new_console()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (20 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 21/67] ui/console: register the console from qemu_console_init() marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:22 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 23/67] ui/console: specialize console_lookup_unused() marcandre.lureau
` (45 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 02a24eaf5d..e0e4f980d7 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 23/67] ui/console: specialize console_lookup_unused()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (21 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 22/67] ui/console: remove new_console() marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:23 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 24/67] ui/console: update the head from unused QemuConsole marcandre.lureau
` (44 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/console.h | 1 -
ui/console.c | 7 ++++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 1b08b0f8ad..465f0f93a0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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);
diff --git a/ui/console.c b/ui/console.c
index e0e4f980d7..08bed58b80 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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),
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 24/67] ui/console: update the head from unused QemuConsole
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (22 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 23/67] ui/console: specialize console_lookup_unused() marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:23 ` Daniel P. Berrangé
2023-08-30 9:37 ` [PATCH 25/67] ui/console: allocate ui_timer in QemuConsole marcandre.lureau
` (43 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
When recycling unused QemuConsole, we should still set the associated
head number for correct information and lookups.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/console.c b/ui/console.c
index 08bed58b80..a9a922b6e3 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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),
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 25/67] ui/console: allocate ui_timer in QemuConsole
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (23 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 24/67] ui/console: update the head from unused QemuConsole marcandre.lureau
@ 2023-08-30 9:37 ` marcandre.lureau
2023-09-01 14:24 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class marcandre.lureau
` (42 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Although at this point only QemuGraphicConsole have hw_ops that
implements ui_info() callback, it makes sense to keep the code in the
base QemuConsole, to simplify conditions for the caller.
As of now, the code didn't reach a NULL timer because dpy_set_ui_info()
checks if dpy_ui_info_supported() (hw_ops->ui_info != NULL), which is
false for text_console_ops. This is a bit fragile, let simply allocate
and free the timer in the base class.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index a9a922b6e3..8c4a2c83fa 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -197,6 +197,7 @@ static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl);
static bool console_compatible_with(QemuConsole *con,
DisplayChangeListener *dcl, Error **errp);
static QemuConsole *qemu_graphic_console_lookup_unused(void);
+static void dpy_set_ui_info_timer(void *opaque);
static void gui_update(void *opaque)
{
@@ -1334,6 +1335,9 @@ qemu_console_register(QemuConsole *c)
static void
qemu_console_finalize(Object *obj)
{
+ QemuConsole *c = QEMU_CONSOLE(obj);
+
+ g_clear_pointer(&c->ui_timer, timer_free);
/* TODO: should unregister from consoles and free itself */
}
@@ -1367,6 +1371,8 @@ qemu_console_init(Object *obj)
qemu_co_queue_init(&c->dump_queue);
c->ds = ds;
c->window_id = -1;
+ c->ui_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
+ dpy_set_ui_info_timer, c);
qemu_console_register(c);
}
@@ -2193,8 +2199,6 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,
} else {
trace_console_gfx_new();
s = (QemuConsole *)object_new(TYPE_QEMU_GRAPHIC_CONSOLE);
- s->ui_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
- dpy_set_ui_info_timer, s);
}
s->head = head;
graphic_console_set_hwops(s, hw_ops, opaque);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 25/67] ui/console: allocate ui_timer in QemuConsole
2023-08-30 9:37 ` [PATCH 25/67] ui/console: allocate ui_timer in QemuConsole marcandre.lureau
@ 2023-09-01 14:24 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 14:24 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:37:59PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Although at this point only QemuGraphicConsole have hw_ops that
> implements ui_info() callback, it makes sense to keep the code in the
> base QemuConsole, to simplify conditions for the caller.
>
> As of now, the code didn't reach a NULL timer because dpy_set_ui_info()
> checks if dpy_ui_info_supported() (hw_ops->ui_info != NULL), which is
> false for text_console_ops. This is a bit fragile, let simply allocate
> and free the timer in the base class.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (24 preceding siblings ...)
2023-08-30 9:37 ` [PATCH 25/67] ui/console: allocate ui_timer in QemuConsole marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:27 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 27/67] ui/console: free more QemuConsole resources marcandre.lureau
` (41 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The timer is only relevant when a text console exists.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 8c4a2c83fa..ffa68c3a22 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1399,6 +1399,10 @@ qemu_text_console_finalize(Object *obj)
static void
qemu_text_console_class_init(ObjectClass *oc, void *data)
{
+ if (!cursor_timer) {
+ cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
+ text_console_update_cursor, NULL);
+ }
}
static void
@@ -2144,8 +2148,6 @@ static DisplayState *get_alloc_displaystate(void)
{
if (!display_state) {
display_state = g_new0(DisplayState, 1);
- cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
- text_console_update_cursor, NULL);
}
return display_state;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
2023-08-30 9:38 ` [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class marcandre.lureau
@ 2023-09-01 14:27 ` Daniel P. Berrangé
2023-09-04 9:55 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 14:27 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:00PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The timer is only relevant when a text console exists.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> diff --git a/ui/console.c b/ui/console.c
> index 8c4a2c83fa..ffa68c3a22 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -1399,6 +1399,10 @@ qemu_text_console_finalize(Object *obj)
> static void
> qemu_text_console_class_init(ObjectClass *oc, void *data)
> {
> + if (!cursor_timer) {
> + cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
> + text_console_update_cursor, NULL);
> + }
Any possibility of moving 'cursor_timer' into a field in
QemuTextConsole ?
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class
2023-09-01 14:27 ` Daniel P. Berrangé
@ 2023-09-04 9:55 ` Marc-André Lureau
0 siblings, 0 replies; 157+ messages in thread
From: Marc-André Lureau @ 2023-09-04 9:55 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel, Gerd Hoffmann
Hi
On Fri, Sep 1, 2023 at 6:29 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 01:38:00PM +0400, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > The timer is only relevant when a text console exists.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > ui/console.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> > diff --git a/ui/console.c b/ui/console.c
> > index 8c4a2c83fa..ffa68c3a22 100644
> > --- a/ui/console.c
> > +++ b/ui/console.c
> > @@ -1399,6 +1399,10 @@ qemu_text_console_finalize(Object *obj)
> > static void
> > qemu_text_console_class_init(ObjectClass *oc, void *data)
> > {
> > + if (!cursor_timer) {
> > + cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
> > + text_console_update_cursor, NULL);
> > + }
>
> Any possibility of moving 'cursor_timer' into a field in
> QemuTextConsole ?
>
It's global, so all consoles blink at the same time I suppose. It's
not obvious to me how we could make it a class field either.
thanks
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 27/67] ui/console: free more QemuConsole resources
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (25 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 26/67] ui/vc: move cursor_timer initialization to QemuTextConsole class marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:29 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 28/67] ui/vc: move text fields to QemuTextConsole marcandre.lureau
` (40 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
This code path is probably not executed at this point, since console
aren't being released.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ui/console.c b/ui/console.c
index ffa68c3a22..3cd4c74eec 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 28/67] ui/vc: move text fields to QemuTextConsole
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (26 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 27/67] ui/console: free more QemuConsole resources marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:30 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 29/67] ui/console: move graphic fields to QemuGraphicConsole marcandre.lureau
` (39 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 177 ++++++++++++++++++++++++++-------------------------
1 file changed, 91 insertions(+), 86 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 3cd4c74eec..335d7ba841 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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_CONSOL
typedef 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_TEX
struct 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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 29/67] ui/console: move graphic fields to QemuGraphicConsole
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (27 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 28/67] ui/vc: move text fields to QemuTextConsole marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:31 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 30/67] ui/vc: fold text_console_do_init() in vc_chr_open() marcandre.lureau
` (38 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 110 ++++++++++++++++++++++++++++++---------------------
1 file changed, 64 insertions(+), 46 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 335d7ba841..9d884ba02f 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 30/67] ui/vc: fold text_console_do_init() in vc_chr_open()
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (28 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 29/67] ui/console: move graphic fields to QemuGraphicConsole marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:34 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 31/67] ui/vc: move some text console initialization to qom handlers marcandre.lureau
` (37 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 80 ++++++++++++++++++++--------------------------------
1 file changed, 31 insertions(+), 49 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 9d884ba02f..22505d093f 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 30/67] ui/vc: fold text_console_do_init() in vc_chr_open()
2023-08-30 9:38 ` [PATCH 30/67] ui/vc: fold text_console_do_init() in vc_chr_open() marcandre.lureau
@ 2023-09-01 14:34 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 14:34 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:04PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 80 ++++++++++++++++++++--------------------------------
> 1 file changed, 31 insertions(+), 49 deletions(-)
> @@ -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;
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
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 31/67] ui/vc: move some text console initialization to qom handlers
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (29 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 30/67] ui/vc: fold text_console_do_init() in vc_chr_open() marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:36 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 32/67] ui/console: simplify getting active_console size marcandre.lureau
` (36 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 22505d093f..5d521ba79d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 32/67] ui/console: simplify getting active_console size
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (30 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 31/67] ui/vc: move some text console initialization to qom handlers marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:37 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 33/67] ui/console: remove need for g_width/g_height marcandre.lureau
` (35 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 5d521ba79d..70e11f924d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 33/67] ui/console: remove need for g_width/g_height
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (31 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 32/67] ui/console: simplify getting active_console size marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:37 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 34/67] ui/vc: use common text console surface creation marcandre.lureau
` (34 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 70e11f924d..a3fd1c5059 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 34/67] ui/vc: use common text console surface creation
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (32 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 33/67] ui/console: remove need for g_width/g_height marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:38 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 35/67] ui/console: declare console types in console.h marcandre.lureau
` (33 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index a3fd1c5059..3d884956b7 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 35/67] ui/console: declare console types in console.h
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (33 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 34/67] ui/vc: use common text console surface creation marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:39 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers marcandre.lureau
` (32 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
We are going to split the console.c unit next, and implement
separately. But we need to check the underlying type in various places.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/console.h | 25 +++++++++++++++++++++----
ui/console.c | 15 ---------------
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 465f0f93a0..0f7f50deaf 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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;
};
diff --git a/ui/console.c b/ui/console.c
index 3d884956b7..ed9e7137b8 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (34 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 35/67] ui/console: declare console types in console.h marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:13 ` Philippe Mathieu-Daudé
2023-08-30 9:38 ` [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_ marcandre.lureau
` (31 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/qemu-pixman.h | 6 ++++++
ui/console.c | 39 ++++++++++++++++++---------------------
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index ce4518e4de..51f8709327 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -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 {
diff --git a/ui/console.c b/ui/console.c
index ed9e7137b8..88e37eaff3 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers
2023-08-30 9:38 ` [PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers marcandre.lureau
@ 2023-08-30 15:13 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:13 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/ui/qemu-pixman.h | 6 ++++++
> ui/console.c | 39 ++++++++++++++++++---------------------
> 2 files changed, 24 insertions(+), 21 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (35 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 11:11 ` Daniel P. Berrangé
` (2 more replies)
2023-08-30 9:38 ` [PATCH 38/67] ui/console: assert(surface) where appropriate marcandre.lureau
` (30 subsequent siblings)
67 siblings, 3 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 88e37eaff3..a157a5b31c 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_
2023-08-30 9:38 ` [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_ marcandre.lureau
@ 2023-08-30 11:11 ` Daniel P. Berrangé
2023-08-30 12:44 ` BALATON Zoltan
2023-08-30 15:13 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-08-30 11:11 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:11PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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 <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_
2023-08-30 9:38 ` [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_ marcandre.lureau
2023-08-30 11:11 ` Daniel P. Berrangé
@ 2023-08-30 12:44 ` BALATON Zoltan
2023-08-30 15:13 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 157+ messages in thread
From: BALATON Zoltan @ 2023-08-30 12:44 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Gerd Hoffmann
[-- Attachment #1: Type: text/plain, Size: 3432 bytes --]
On Wed, 30 Aug 2023, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
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
> 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 <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/ui/console.c b/ui/console.c
> index 88e37eaff3..a157a5b31c 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -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;
>
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_
2023-08-30 9:38 ` [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_ marcandre.lureau
2023-08-30 11:11 ` Daniel P. Berrangé
2023-08-30 12:44 ` BALATON Zoltan
@ 2023-08-30 15:13 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:13 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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 <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 38/67] ui/console: assert(surface) where appropriate
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (36 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_ marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 14:39 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 39/67] ui/console: fold text_console_update_cursor_timer marcandre.lureau
` (29 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The QemuTextConsole code paths assume a surface is being used as
scanout, let's make this more explicit.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ui/console.c b/ui/console.c
index a157a5b31c..04ec2d2488 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 39/67] ui/console: fold text_console_update_cursor_timer
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (37 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 38/67] ui/console: assert(surface) where appropriate marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:15 ` Philippe Mathieu-Daudé
2023-09-01 16:51 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 40/67] ui/vc: skip text console resize when possible marcandre.lureau
` (28 subsequent siblings)
67 siblings, 2 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 04ec2d2488..c31368667d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 39/67] ui/console: fold text_console_update_cursor_timer
2023-08-30 9:38 ` [PATCH 39/67] ui/console: fold text_console_update_cursor_timer marcandre.lureau
@ 2023-08-30 15:15 ` Philippe Mathieu-Daudé
2023-09-01 16:51 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:15 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
> 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);
This should be padded here ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> }
> }
>
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 39/67] ui/console: fold text_console_update_cursor_timer
2023-08-30 9:38 ` [PATCH 39/67] ui/console: fold text_console_update_cursor_timer marcandre.lureau
2023-08-30 15:15 ` Philippe Mathieu-Daudé
@ 2023-09-01 16:51 ` Daniel P. Berrangé
1 sibling, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 16:51 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:13PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 40/67] ui/vc: skip text console resize when possible
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (38 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 39/67] ui/console: fold text_console_update_cursor_timer marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 16:52 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 41/67] ui/console: minor stylistic changes marcandre.lureau
` (27 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
ui/console.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index c31368667d..6163f73640 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 41/67] ui/console: minor stylistic changes
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (39 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 40/67] ui/vc: skip text console resize when possible marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 16:52 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 42/67] ui/vc: move text console invalidate in helper marcandre.lureau
` (26 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 6163f73640..c0b60284b2 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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++;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 42/67] ui/vc: move text console invalidate in helper
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (40 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 41/67] ui/console: minor stylistic changes marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 16:54 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK marcandre.lureau
` (25 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
This will allow to split the VC code in a separate unit more easily.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/console.h | 1 +
ui/console.c | 13 +++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 0f7f50deaf..91d8bbc9dc 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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
diff --git a/ui/console.c b/ui/console.c
index c0b60284b2..7be2d4eef3 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (41 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 42/67] ui/vc: move text console invalidate in helper marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 17:13 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 44/67] ui/vc: change the argument for QemuTextConsole marcandre.lureau
` (24 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini, Eric Blake,
Markus Armbruster
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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(-)
diff --git a/qapi/char.json b/qapi/char.json
index 52aaff25eb..7e23fe3180 100644
--- a/qapi/char.json
+++ b/qapi/char.json
@@ -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',
diff --git a/include/chardev/char.h b/include/chardev/char.h
index 44cd82e405..01df55f9e8 100644
--- a/include/chardev/char.h
+++ b/include/chardev/char.h
@@ -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
diff --git a/ui/console.c b/ui/console.c
index 7be2d4eef3..9fccecafd7 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
diff --git a/ui/gtk.c b/ui/gtk.c
index 8ba41c8f13..ef98bb0648 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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;
diff --git a/ui/spice-app.c b/ui/spice-app.c
index ad7f0551ad..405fb7f9f5 100644
--- a/ui/spice-app.c
+++ b/ui/spice-app.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK
2023-08-30 9:38 ` [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK marcandre.lureau
@ 2023-09-01 17:13 ` Daniel P. Berrangé
2023-09-04 10:56 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 17:13 UTC (permalink / raw)
To: marcandre.lureau
Cc: qemu-devel, Gerd Hoffmann, Paolo Bonzini, Eric Blake,
Markus Armbruster
On Wed, Aug 30, 2023 at 01:38:17PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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(-)
>
> diff --git a/qapi/char.json b/qapi/char.json
> index 52aaff25eb..7e23fe3180 100644
> --- a/qapi/char.json
> +++ b/qapi/char.json
> @@ -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
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK
2023-09-01 17:13 ` Daniel P. Berrangé
@ 2023-09-04 10:56 ` Marc-André Lureau
0 siblings, 0 replies; 157+ messages in thread
From: Marc-André Lureau @ 2023-09-04 10:56 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: qemu-devel, Gerd Hoffmann, Paolo Bonzini, Eric Blake,
Markus Armbruster
Hi
On Fri, Sep 1, 2023 at 9:14 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 01:38:17PM +0400, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > 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.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > 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(-)
> >
> > diff --git a/qapi/char.json b/qapi/char.json
> > index 52aaff25eb..7e23fe3180 100644
> > --- a/qapi/char.json
> > +++ b/qapi/char.json
> > @@ -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.
Actually, VNC too. I adjusted the doc.
thanks
>
> 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
>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
>
> 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
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 44/67] ui/vc: change the argument for QemuTextConsole
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (42 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 17:15 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls marcandre.lureau
` (23 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Those functions are specifc to text/vc console, make that explicit from
the argument type.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 91d8bbc9dc..1ccd432b4d 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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 */
diff --git a/ui/console.c b/ui/console.c
index 9fccecafd7..a98adbb1b2 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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)
diff --git a/ui/gtk.c b/ui/gtk.c
index ef98bb0648..c34c133550 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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);
diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
index f068382209..efc0e76e8c 100644
--- a/ui/sdl2-input.c
+++ b/ui/sdl2-input.c
@@ -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;
}
}
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 0d91b555e3..16b515fcf9 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -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)
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 44/67] ui/vc: change the argument for QemuTextConsole
2023-08-30 9:38 ` [PATCH 44/67] ui/vc: change the argument for QemuTextConsole marcandre.lureau
@ 2023-09-01 17:15 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 17:15 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:18PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Those functions are specifc to text/vc console, make that explicit from
> the argument type.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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(-)
>
> diff --git a/include/ui/console.h b/include/ui/console.h
> index 91d8bbc9dc..1ccd432b4d 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -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 */
> diff --git a/ui/console.c b/ui/console.c
> index 9fccecafd7..a98adbb1b2 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -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)
> diff --git a/ui/gtk.c b/ui/gtk.c
> index ef98bb0648..c34c133550 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -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);
> diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
> index f068382209..efc0e76e8c 100644
> --- a/ui/sdl2-input.c
> +++ b/ui/sdl2-input.c
> @@ -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
> + 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;
> }
> }
> diff --git a/ui/sdl2.c b/ui/sdl2.c
> index 0d91b555e3..16b515fcf9 100644
> --- a/ui/sdl2.c
> +++ b/ui/sdl2.c
> @@ -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)
With or without my suggestion:
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (43 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 44/67] ui/vc: change the argument for QemuTextConsole marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 20:59 ` Akihiko Odaki
2023-08-30 9:38 ` [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions marcandre.lureau
` (22 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Peter Maydell,
Philippe Mathieu-Daudé, Akihiko Odaki
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 1ccd432b4d..9c362f0e87 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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 {
diff --git a/ui/console.c b/ui/console.c
index a98adbb1b2..6068e02928 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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);
diff --git a/ui/curses.c b/ui/curses.c
index de962faa7c..4ddbbae7cd 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -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);
}
}
}
diff --git a/ui/vnc.c b/ui/vnc.c
index 92964dcc0c..1fa4456744 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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);
break;
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;
}
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 0c2153d17c..9eb4da7713 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event
}
if (keysym) {
- kbd_put_keysym(keysym);
+ kbd_put_keysym_console(NULL, keysym);
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls
2023-08-30 9:38 ` [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls marcandre.lureau
@ 2023-08-30 20:59 ` Akihiko Odaki
2023-09-04 12:42 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Akihiko Odaki @ 2023-08-30 20:59 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
Cc: Gerd Hoffmann, Peter Maydell, Philippe Mathieu-Daudé
On 2023/08/30 18:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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(-)
>
> diff --git a/include/ui/console.h b/include/ui/console.h
> index 1ccd432b4d..9c362f0e87 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -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 {
> diff --git a/ui/console.c b/ui/console.c
> index a98adbb1b2..6068e02928 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -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);
> diff --git a/ui/curses.c b/ui/curses.c
> index de962faa7c..4ddbbae7cd 100644
> --- a/ui/curses.c
> +++ b/ui/curses.c
> @@ -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);
> }
> }
> }
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 92964dcc0c..1fa4456744 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -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.
> break;
> 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;
> }
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 0c2153d17c..9eb4da7713 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event
> }
>
> if (keysym) {
> - kbd_put_keysym(keysym);
> + kbd_put_keysym_console(NULL, keysym);
> }
> }
>
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls
2023-08-30 20:59 ` Akihiko Odaki
@ 2023-09-04 12:42 ` Marc-André Lureau
2023-09-04 12:47 ` Akihiko Odaki
0 siblings, 1 reply; 157+ messages in thread
From: Marc-André Lureau @ 2023-09-04 12:42 UTC (permalink / raw)
To: Akihiko Odaki
Cc: qemu-devel, Gerd Hoffmann, Peter Maydell,
Philippe Mathieu-Daudé
Hi
On Thu, Aug 31, 2023 at 12:59 AM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>
> On 2023/08/30 18:38, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > 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.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > 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(-)
> >
> > diff --git a/include/ui/console.h b/include/ui/console.h
> > index 1ccd432b4d..9c362f0e87 100644
> > --- a/include/ui/console.h
> > +++ b/include/ui/console.h
> > @@ -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 {
> > diff --git a/ui/console.c b/ui/console.c
> > index a98adbb1b2..6068e02928 100644
> > --- a/ui/console.c
> > +++ b/ui/console.c
> > @@ -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);
> > diff --git a/ui/curses.c b/ui/curses.c
> > index de962faa7c..4ddbbae7cd 100644
> > --- a/ui/curses.c
> > +++ b/ui/curses.c
> > @@ -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);
> > }
> > }
> > }
> > diff --git a/ui/vnc.c b/ui/vnc.c
> > index 92964dcc0c..1fa4456744 100644
> > --- a/ui/vnc.c
> > +++ b/ui/vnc.c
> > @@ -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.
>
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
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls
2023-09-04 12:42 ` Marc-André Lureau
@ 2023-09-04 12:47 ` Akihiko Odaki
0 siblings, 0 replies; 157+ messages in thread
From: Akihiko Odaki @ 2023-09-04 12:47 UTC (permalink / raw)
To: Marc-André Lureau
Cc: qemu-devel, Gerd Hoffmann, Peter Maydell,
Philippe Mathieu-Daudé
On 2023/09/04 21:42, Marc-André Lureau wrote:
> Hi
>
> On Thu, Aug 31, 2023 at 12:59 AM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>>
>> On 2023/08/30 18:38, marcandre.lureau@redhat.com wrote:
>>> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>> ---
>>> 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(-)
>>>
>>> diff --git a/include/ui/console.h b/include/ui/console.h
>>> index 1ccd432b4d..9c362f0e87 100644
>>> --- a/include/ui/console.h
>>> +++ b/include/ui/console.h
>>> @@ -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 {
>>> diff --git a/ui/console.c b/ui/console.c
>>> index a98adbb1b2..6068e02928 100644
>>> --- a/ui/console.c
>>> +++ b/ui/console.c
>>> @@ -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);
>>> diff --git a/ui/curses.c b/ui/curses.c
>>> index de962faa7c..4ddbbae7cd 100644
>>> --- a/ui/curses.c
>>> +++ b/ui/curses.c
>>> @@ -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);
>>> }
>>> }
>>> }
>>> diff --git a/ui/vnc.c b/ui/vnc.c
>>> index 92964dcc0c..1fa4456744 100644
>>> --- a/ui/vnc.c
>>> +++ b/ui/vnc.c
>>> @@ -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.
>>
>
> 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()).
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").
>
> Anyway, this patch is quite systematic. Further complicated changes
> should be done later. please ack/r-b
I see.
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>
> thanks
>
>
>
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (44 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:41 ` Philippe Mathieu-Daudé
2023-08-30 9:38 ` [PATCH 47/67] ui/console: remove redundant format field marcandre.lureau
` (21 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Peter Maydell,
Philippe Mathieu-Daudé, Akihiko Odaki
From: Marc-André Lureau <marcandre.lureau@redhat.com>
They are QemuTextConsole functions, let's make it clear.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 9c362f0e87..26d63d17a2 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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 {
diff --git a/ui/console.c b/ui/console.c
index 6068e02928..b8ffad30d3 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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]);
}
}
diff --git a/ui/curses.c b/ui/curses.c
index 4ddbbae7cd..8bde8c5cf7 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -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);
}
}
}
diff --git a/ui/gtk.c b/ui/gtk.c
index c34c133550..fab6d6581d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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;
}
diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
index efc0e76e8c..d4a25b6573 100644
--- a/ui/sdl2-input.c
+++ b/ui/sdl2-input.c
@@ -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;
}
}
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 16b515fcf9..ed21045172 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -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));
}
}
diff --git a/ui/vnc.c b/ui/vnc.c
index 1fa4456744..22894b7b1f 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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_console(NULL, QEMU_KEY_UP);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_UP);
break;
case 0xd0:
- kbd_put_keysym_console(NULL, QEMU_KEY_DOWN);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_DOWN);
break;
case 0xcb:
- kbd_put_keysym_console(NULL, QEMU_KEY_LEFT);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_LEFT);
break;
case 0xcd:
- kbd_put_keysym_console(NULL, QEMU_KEY_RIGHT);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_RIGHT);
break;
case 0xd3:
- kbd_put_keysym_console(NULL, QEMU_KEY_DELETE);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_DELETE);
break;
case 0xc7:
- kbd_put_keysym_console(NULL, QEMU_KEY_HOME);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_HOME);
break;
case 0xcf:
- kbd_put_keysym_console(NULL, QEMU_KEY_END);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_END);
break;
case 0xc9:
- kbd_put_keysym_console(NULL, QEMU_KEY_PAGEUP);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_PAGEUP);
break;
case 0xd1:
- kbd_put_keysym_console(NULL, QEMU_KEY_PAGEDOWN);
+ qemu_text_console_put_keysym(NULL, QEMU_KEY_PAGEDOWN);
break;
case 0x47:
- kbd_put_keysym_console(NULL, numlock ? '7' : QEMU_KEY_HOME);
+ qemu_text_console_put_keysym(NULL, numlock ? '7' : QEMU_KEY_HOME);
break;
case 0x48:
- kbd_put_keysym_console(NULL, numlock ? '8' : QEMU_KEY_UP);
+ qemu_text_console_put_keysym(NULL, numlock ? '8' : QEMU_KEY_UP);
break;
case 0x49:
- kbd_put_keysym_console(NULL, numlock ? '9' : QEMU_KEY_PAGEUP);
+ qemu_text_console_put_keysym(NULL, numlock ? '9' : QEMU_KEY_PAGEUP);
break;
case 0x4b:
- kbd_put_keysym_console(NULL, numlock ? '4' : QEMU_KEY_LEFT);
+ qemu_text_console_put_keysym(NULL, numlock ? '4' : QEMU_KEY_LEFT);
break;
case 0x4c:
- kbd_put_keysym_console(NULL, '5');
+ qemu_text_console_put_keysym(NULL, '5');
break;
case 0x4d:
- kbd_put_keysym_console(NULL, numlock ? '6' : QEMU_KEY_RIGHT);
+ qemu_text_console_put_keysym(NULL, numlock ? '6' : QEMU_KEY_RIGHT);
break;
case 0x4f:
- kbd_put_keysym_console(NULL, numlock ? '1' : QEMU_KEY_END);
+ qemu_text_console_put_keysym(NULL, numlock ? '1' : QEMU_KEY_END);
break;
case 0x50:
- kbd_put_keysym_console(NULL, numlock ? '2' : QEMU_KEY_DOWN);
+ qemu_text_console_put_keysym(NULL, numlock ? '2' : QEMU_KEY_DOWN);
break;
case 0x51:
- kbd_put_keysym_console(NULL, numlock ? '3' : QEMU_KEY_PAGEDOWN);
+ qemu_text_console_put_keysym(NULL, numlock ? '3' : QEMU_KEY_PAGEDOWN);
break;
case 0x52:
- kbd_put_keysym_console(NULL, '0');
+ qemu_text_console_put_keysym(NULL, '0');
break;
case 0x53:
- kbd_put_keysym_console(NULL, numlock ? '.' : QEMU_KEY_DELETE);
+ qemu_text_console_put_keysym(NULL, numlock ? '.' : QEMU_KEY_DELETE);
break;
case 0xb5:
- kbd_put_keysym_console(NULL, '/');
+ qemu_text_console_put_keysym(NULL, '/');
break;
case 0x37:
- kbd_put_keysym_console(NULL, '*');
+ qemu_text_console_put_keysym(NULL, '*');
break;
case 0x4a:
- kbd_put_keysym_console(NULL, '-');
+ qemu_text_console_put_keysym(NULL, '-');
break;
case 0x4e:
- kbd_put_keysym_console(NULL, '+');
+ qemu_text_console_put_keysym(NULL, '+');
break;
case 0x9c:
- kbd_put_keysym_console(NULL, '\n');
+ qemu_text_console_put_keysym(NULL, '\n');
break;
default:
if (control) {
- kbd_put_keysym_console(NULL, sym & 0x1f);
+ qemu_text_console_put_keysym(NULL, sym & 0x1f);
} else {
- kbd_put_keysym_console(NULL, sym);
+ qemu_text_console_put_keysym(NULL, sym);
}
break;
}
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 9eb4da7713..8b97319587 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event
}
if (keysym) {
- kbd_put_keysym_console(NULL, keysym);
+ qemu_text_console_keysym(NULL, keysym);
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions
2023-08-30 9:38 ` [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions marcandre.lureau
@ 2023-08-30 15:41 ` Philippe Mathieu-Daudé
2023-09-01 17:17 ` Daniel P. Berrangé
0 siblings, 1 reply; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:41 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann, Peter Maydell, Akihiko Odaki
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> They are QemuTextConsole functions, let's make it clear.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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(-)
>
> diff --git a/include/ui/console.h b/include/ui/console.h
> index 9c362f0e87..26d63d17a2 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -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);
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 9eb4da7713..8b97319587 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -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 --
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 8b97319587..b886db7510 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event
}
if (keysym) {
- qemu_text_console_keysym(NULL, keysym);
+ qemu_text_console_put_keysym(NULL, keysym);
}
}
---
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions
2023-08-30 15:41 ` Philippe Mathieu-Daudé
@ 2023-09-01 17:17 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 17:17 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: marcandre.lureau, qemu-devel, Gerd Hoffmann, Peter Maydell,
Akihiko Odaki
On Wed, Aug 30, 2023 at 05:41:51PM +0200, Philippe Mathieu-Daudé wrote:
> On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > They are QemuTextConsole functions, let's make it clear.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > 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(-)
> >
> > diff --git a/include/ui/console.h b/include/ui/console.h
> > index 9c362f0e87..26d63d17a2 100644
> > --- a/include/ui/console.h
> > +++ b/include/ui/console.h
> > @@ -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);
>
>
> > diff --git a/ui/cocoa.m b/ui/cocoa.m
> > index 9eb4da7713..8b97319587 100644
> > --- a/ui/cocoa.m
> > +++ b/ui/cocoa.m
> > @@ -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 --
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 8b97319587..b886db7510 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -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
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 47/67] ui/console: remove redundant format field
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (45 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 17:18 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 48/67] ui/vc: preliminary QemuTextConsole changes before split marcandre.lureau
` (20 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
It's already part of PIXMAN image.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 26d63d17a2..93bb03a9e2 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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)
diff --git a/ui/console-gl.c b/ui/console-gl.c
index 8e3c9a3c8c..103b954017 100644
--- a/ui/console-gl.c
+++ b/ui/console-gl.c
@@ -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;
diff --git a/ui/console.c b/ui/console.c
index b8ffad30d3..f7bc27f596 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
diff --git a/ui/gtk.c b/ui/gtk.c
index fab6d6581d..7b9e005bf8 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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
*
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 3f3f8013d8..d977ab139d 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -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);
}
diff --git a/ui/vnc.c b/ui/vnc.c
index 22894b7b1f..6fd86996a5 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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) {
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 48/67] ui/vc: preliminary QemuTextConsole changes before split
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (46 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 47/67] ui/console: remove redundant format field marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 17:19 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 49/67] ui/vc: split off the VC part from console.c marcandre.lureau
` (19 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Those changes will help to split console.c unit in the following commit.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 52 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index f7bc27f596..c2c1f22979 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 49/67] ui/vc: split off the VC part from console.c
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (47 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 48/67] ui/vc: preliminary QemuTextConsole changes before split marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 17:23 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 50/67] ui/console: move DisplaySurface to its own header marcandre.lureau
` (18 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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
diff --git a/ui/console-priv.h b/ui/console-priv.h
new file mode 100644
index 0000000000..88569ed2cc
--- /dev/null
+++ b/ui/console-priv.h
@@ -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
diff --git a/ui/console-vc.c b/ui/console-vc.c
new file mode 100644
index 0000000000..656f099556
--- /dev/null
+++ b/ui/console-vc.c
@@ -0,0 +1,1079 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * QEMU VC
+ */
+#include "qemu/osdep.h"
+
+#include "chardev/char.h"
+#include "qapi/error.h"
+#include "qemu/fifo8.h"
+#include "qemu/option.h"
+#include "ui/console.h"
+
+#include "trace.h"
+#include "console-priv.h"
+
+#define DEFAULT_BACKSCROLL 512
+#define CONSOLE_CURSOR_PERIOD 500
+
+typedef struct TextAttributes {
+ uint8_t fgcol:4;
+ uint8_t bgcol:4;
+ uint8_t bold:1;
+ uint8_t uline:1;
+ uint8_t blink:1;
+ uint8_t invers:1;
+ 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;
+} TextCell;
+
+#define MAX_ESC_PARAMS 3
+
+enum TTYState {
+ TTY_STATE_NORM,
+ TTY_STATE_ESC,
+ TTY_STATE_CSI,
+};
+
+typedef 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;
+
+OBJECT_DEFINE_TYPE(QemuTextConsole, qemu_text_console, QEMU_TEXT_CONSOLE, QEMU_CONSOLE)
+
+typedef struct QemuFixedTextConsole {
+ QemuTextConsole parent;
+} QemuFixedTextConsole;
+
+typedef QemuTextConsoleClass QemuFixedTextConsoleClass;
+
+OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_text_console, QEMU_FIXED_TEXT_CONSOLE, QEMU_TEXT_CONSOLE)
+
+struct VCChardev {
+ Chardev parent;
+ QemuTextConsole *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;
+
+static const pixman_color_t color_table_rgb[2][8] = {
+ { /* dark */
+ [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_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 */
+ }
+};
+
+static bool cursor_visible_phase;
+static QEMUTimer *cursor_timer;
+
+const char *
+qemu_text_console_get_label(QemuTextConsole *c)
+{
+ return c->chr ? c->chr->label : NULL;
+}
+
+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 = {
+ .x = posx, .y = posy, .width = width, .height = height
+ };
+
+ assert(surface);
+ pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface->image,
+ &color, 1, &rect);
+}
+
+/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, 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);
+
+ assert(surface);
+ pixman_image_composite(PIXMAN_OP_SRC,
+ surface->image, NULL, surface->image,
+ xs, ys, 0, 0, xd, yd, w, h);
+}
+
+static void vga_putcharxy(QemuConsole *s, int x, int y, int ch,
+ TextAttributes *t_attrib)
+{
+ static pixman_image_t *glyphs[256];
+ 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];
+ } else {
+ fgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol];
+ bgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol];
+ }
+
+ if (!glyphs[ch]) {
+ glyphs[ch] = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, ch);
+ }
+ qemu_pixman_glyph_render(glyphs[ch], surface->image,
+ &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT);
+}
+
+static void invalidate_xy(QemuTextConsole *s, int x, int y)
+{
+ if (!qemu_console_is_visible(QEMU_CONSOLE(s))) {
+ return;
+ }
+ if (s->update_x0 > x * FONT_WIDTH)
+ s->update_x0 = x * FONT_WIDTH;
+ if (s->update_y0 > y * FONT_HEIGHT)
+ s->update_y0 = y * FONT_HEIGHT;
+ if (s->update_x1 < (x + 1) * FONT_WIDTH)
+ s->update_x1 = (x + 1) * FONT_WIDTH;
+ if (s->update_y1 < (y + 1) * FONT_HEIGHT)
+ s->update_y1 = (y + 1) * FONT_HEIGHT;
+}
+
+static void console_show_cursor(QemuTextConsole *s, int show)
+{
+ TextCell *c;
+ int y, y1;
+ int x = s->x;
+
+ s->cursor_invalidate = 1;
+
+ if (x >= s->width) {
+ x = s->width - 1;
+ }
+ y1 = (s->y_base + s->y) % s->total_height;
+ y = y1 - s->y_displayed;
+ if (y < 0) {
+ y += s->total_height;
+ }
+ if (y < s->height) {
+ c = &s->cells[y1 * s->width + x];
+ if (show && cursor_visible_phase) {
+ TextAttributes t_attrib = TEXT_ATTRIBUTES_DEFAULT;
+ t_attrib.invers = !(t_attrib.invers); /* invert fg and bg */
+ vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &t_attrib);
+ } else {
+ vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &(c->t_attrib));
+ }
+ invalidate_xy(s, x, y);
+ }
+}
+
+static void console_refresh(QemuTextConsole *s)
+{
+ DisplaySurface *surface = qemu_console_surface(QEMU_CONSOLE(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;
+ s->text_y[1] = s->height - 1;
+ s->cursor_invalidate = 1;
+
+ 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;
+ for (x = 0; x < s->width; x++) {
+ vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch,
+ &(c->t_attrib));
+ c++;
+ }
+ if (++y1 == s->total_height) {
+ y1 = 0;
+ }
+ }
+ console_show_cursor(s, 1);
+ dpy_gfx_update(QEMU_CONSOLE(s), 0, 0,
+ surface_width(surface), surface_height(surface));
+}
+
+static void console_scroll(QemuTextConsole *s, int ydelta)
+{
+ int i, y1;
+
+ if (ydelta > 0) {
+ for(i = 0; i < ydelta; i++) {
+ if (s->y_displayed == s->y_base)
+ break;
+ if (++s->y_displayed == s->total_height)
+ s->y_displayed = 0;
+ }
+ } else {
+ ydelta = -ydelta;
+ i = s->backscroll_height;
+ if (i > s->total_height - s->height)
+ i = s->total_height - s->height;
+ y1 = s->y_base - i;
+ if (y1 < 0)
+ y1 += s->total_height;
+ for(i = 0; i < ydelta; i++) {
+ if (s->y_displayed == y1)
+ break;
+ if (--s->y_displayed < 0)
+ s->y_displayed = s->total_height - 1;
+ }
+ }
+ console_refresh(s);
+}
+
+static void kbd_send_chars(QemuTextConsole *s)
+{
+ uint32_t len, avail;
+
+ len = qemu_chr_be_can_write(s->chr);
+ avail = fifo8_num_used(&s->out_fifo);
+ while (len > 0 && avail > 0) {
+ const uint8_t *buf;
+ uint32_t size;
+
+ buf = fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size);
+ qemu_chr_be_write(s->chr, buf, size);
+ len = qemu_chr_be_can_write(s->chr);
+ avail -= size;
+ }
+}
+
+/* called when an ascii key is pressed */
+void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym)
+{
+ uint8_t buf[16], *q;
+ int c;
+ uint32_t num_free;
+
+ switch(keysym) {
+ case QEMU_KEY_CTRL_UP:
+ console_scroll(s, -1);
+ break;
+ case QEMU_KEY_CTRL_DOWN:
+ console_scroll(s, 1);
+ break;
+ case QEMU_KEY_CTRL_PAGEUP:
+ console_scroll(s, -10);
+ break;
+ case QEMU_KEY_CTRL_PAGEDOWN:
+ console_scroll(s, 10);
+ break;
+ default:
+ /* convert the QEMU keysym to VT100 key string */
+ q = buf;
+ if (keysym >= 0xe100 && keysym <= 0xe11f) {
+ *q++ = '\033';
+ *q++ = '[';
+ c = keysym - 0xe100;
+ if (c >= 10)
+ *q++ = '0' + (c / 10);
+ *q++ = '0' + (c % 10);
+ *q++ = '~';
+ } else if (keysym >= 0xe120 && keysym <= 0xe17f) {
+ *q++ = '\033';
+ *q++ = '[';
+ *q++ = keysym & 0xff;
+ } else if (s->echo && (keysym == '\r' || keysym == '\n')) {
+ qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true);
+ *q++ = '\n';
+ } else {
+ *q++ = keysym;
+ }
+ if (s->echo) {
+ 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));
+ kbd_send_chars(s);
+ break;
+ }
+}
+
+static void text_console_update(void *opaque, console_ch_t *chardata)
+{
+ QemuTextConsole *s = QEMU_TEXT_CONSOLE(opaque);
+ int i, j, src;
+
+ if (s->text_x[0] <= s->text_x[1]) {
+ src = (s->y_base + s->text_y[0]) * s->width;
+ chardata += s->text_y[0] * s->width;
+ for (i = s->text_y[0]; i <= s->text_y[1]; i ++)
+ for (j = 0; j < s->width; j++, src++) {
+ console_write_ch(chardata ++,
+ ATTR2CHTYPE(s->cells[src].ch,
+ s->cells[src].t_attrib.fgcol,
+ s->cells[src].t_attrib.bgcol,
+ s->cells[src].t_attrib.bold));
+ }
+ 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;
+ s->text_x[1] = 0;
+ s->text_y[1] = 0;
+ }
+ if (s->cursor_invalidate) {
+ dpy_text_cursor(QEMU_CONSOLE(s), s->x, s->y);
+ s->cursor_invalidate = 0;
+ }
+}
+
+static void text_console_resize(QemuTextConsole *t)
+{
+ QemuConsole *s = QEMU_CONSOLE(t);
+ TextCell *cells, *c, *c1;
+ 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 = w;
+ t->height = h;
+
+ w1 = MIN(t->width, last_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 = &t->cells[y * last_width];
+ for (x = 0; x < w1; x++) {
+ *c++ = *c1++;
+ }
+ }
+ for (x = w1; x < t->width; x++) {
+ c->ch = ' ';
+ c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
+ c++;
+ }
+ }
+ g_free(t->cells);
+ t->cells = cells;
+}
+
+static void vc_put_lf(VCChardev *vc)
+{
+ QemuTextConsole *s = vc->console;
+ TextCell *c;
+ int x, y1;
+
+ s->y++;
+ if (s->y >= s->height) {
+ s->y = s->height - 1;
+
+ if (s->y_displayed == s->y_base) {
+ if (++s->y_displayed == s->total_height)
+ s->y_displayed = 0;
+ }
+ if (++s->y_base == s->total_height)
+ s->y_base = 0;
+ if (s->backscroll_height < s->total_height)
+ s->backscroll_height++;
+ y1 = (s->y_base + s->height - 1) % s->total_height;
+ c = &s->cells[y1 * s->width];
+ for(x = 0; x < s->width; x++) {
+ c->ch = ' ';
+ c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
+ c++;
+ }
+ if (s->y_displayed == s->y_base) {
+ s->text_x[0] = 0;
+ s->text_y[0] = 0;
+ s->text_x[1] = s->width - 1;
+ s->text_y[1] = s->height - 1;
+
+ 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;
+ s->update_y1 = s->height * FONT_HEIGHT;
+ }
+ }
+}
+
+/* Set console attributes depending on the current escape codes.
+ * 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 vc_handle_escape(VCChardev *vc)
+{
+ int i;
+
+ for (i = 0; i < vc->nb_esc_params; i++) {
+ switch (vc->esc_params[i]) {
+ case 0: /* reset all console attributes to default */
+ vc->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
+ break;
+ case 1:
+ vc->t_attrib.bold = 1;
+ break;
+ case 4:
+ vc->t_attrib.uline = 1;
+ break;
+ case 5:
+ vc->t_attrib.blink = 1;
+ break;
+ case 7:
+ vc->t_attrib.invers = 1;
+ break;
+ case 8:
+ vc->t_attrib.unvisible = 1;
+ break;
+ case 22:
+ vc->t_attrib.bold = 0;
+ break;
+ case 24:
+ vc->t_attrib.uline = 0;
+ break;
+ case 25:
+ vc->t_attrib.blink = 0;
+ break;
+ case 27:
+ vc->t_attrib.invers = 0;
+ break;
+ case 28:
+ vc->t_attrib.unvisible = 0;
+ break;
+ /* set foreground color */
+ case 30:
+ vc->t_attrib.fgcol = QEMU_COLOR_BLACK;
+ break;
+ case 31:
+ vc->t_attrib.fgcol = QEMU_COLOR_RED;
+ break;
+ case 32:
+ vc->t_attrib.fgcol = QEMU_COLOR_GREEN;
+ break;
+ case 33:
+ vc->t_attrib.fgcol = QEMU_COLOR_YELLOW;
+ break;
+ case 34:
+ vc->t_attrib.fgcol = QEMU_COLOR_BLUE;
+ break;
+ case 35:
+ vc->t_attrib.fgcol = QEMU_COLOR_MAGENTA;
+ break;
+ case 36:
+ vc->t_attrib.fgcol = QEMU_COLOR_CYAN;
+ break;
+ case 37:
+ vc->t_attrib.fgcol = QEMU_COLOR_WHITE;
+ break;
+ /* set background color */
+ case 40:
+ vc->t_attrib.bgcol = QEMU_COLOR_BLACK;
+ break;
+ case 41:
+ vc->t_attrib.bgcol = QEMU_COLOR_RED;
+ break;
+ case 42:
+ vc->t_attrib.bgcol = QEMU_COLOR_GREEN;
+ break;
+ case 43:
+ vc->t_attrib.bgcol = QEMU_COLOR_YELLOW;
+ break;
+ case 44:
+ vc->t_attrib.bgcol = QEMU_COLOR_BLUE;
+ break;
+ case 45:
+ vc->t_attrib.bgcol = QEMU_COLOR_MAGENTA;
+ break;
+ case 46:
+ vc->t_attrib.bgcol = QEMU_COLOR_CYAN;
+ break;
+ case 47:
+ vc->t_attrib.bgcol = QEMU_COLOR_WHITE;
+ break;
+ }
+ }
+}
+
+static void vc_update_xy(VCChardev *vc, int x, int y)
+{
+ QemuTextConsole *s = vc->console;
+ TextCell *c;
+ int y1, y2;
+
+ 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;
+ if (y2 < 0) {
+ y2 += s->total_height;
+ }
+ if (y2 < s->height) {
+ if (x >= s->width) {
+ x = s->width - 1;
+ }
+ c = &s->cells[y1 * s->width + x];
+ vga_putcharxy(QEMU_CONSOLE(s), x, y2, c->ch,
+ &(c->t_attrib));
+ invalidate_xy(s, x, y2);
+ }
+}
+
+static void vc_clear_xy(VCChardev *vc, int x, int y)
+{
+ QemuTextConsole *s = vc->console;
+ int y1 = (s->y_base + y) % s->total_height;
+ if (x >= s->width) {
+ x = s->width - 1;
+ }
+ TextCell *c = &s->cells[y1 * s->width + x];
+ c->ch = ' ';
+ c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
+ vc_update_xy(vc, x, y);
+}
+
+static void vc_put_one(VCChardev *vc, int ch)
+{
+ QemuTextConsole *s = vc->console;
+ TextCell *c;
+ int y1;
+ if (s->x >= s->width) {
+ /* line wrap */
+ s->x = 0;
+ 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 = vc->t_attrib;
+ vc_update_xy(vc, s->x, s->y);
+ s->x++;
+}
+
+static void vc_respond_str(VCChardev *vc, const char *buf)
+{
+ while (*buf) {
+ vc_put_one(vc, *buf);
+ buf++;
+ }
+}
+
+/* set cursor, checking bounds */
+static void vc_set_cursor(VCChardev *vc, int x, int y)
+{
+ QemuTextConsole *s = vc->console;
+
+ if (x < 0) {
+ x = 0;
+ }
+ if (y < 0) {
+ y = 0;
+ }
+ if (y >= s->height) {
+ y = s->height - 1;
+ }
+ if (x >= s->width) {
+ x = s->width - 1;
+ }
+
+ s->x = x;
+ s->y = y;
+}
+
+static void vc_putchar(VCChardev *vc, int ch)
+{
+ QemuTextConsole *s = vc->console;
+ int i;
+ int x, y;
+ char response[40];
+
+ switch(vc->state) {
+ case TTY_STATE_NORM:
+ switch(ch) {
+ case '\r': /* carriage return */
+ s->x = 0;
+ break;
+ case '\n': /* newline */
+ vc_put_lf(vc);
+ break;
+ case '\b': /* backspace */
+ if (s->x > 0)
+ s->x--;
+ break;
+ case '\t': /* tabspace */
+ if (s->x + (8 - (s->x % 8)) > s->width) {
+ s->x = 0;
+ vc_put_lf(vc);
+ } else {
+ s->x = s->x + (8 - (s->x % 8));
+ }
+ break;
+ case '\a': /* alert aka. bell */
+ /* TODO: has to be implemented */
+ break;
+ case 14:
+ /* SI (shift in), character set 0 (ignored) */
+ break;
+ case 15:
+ /* SO (shift out), character set 1 (ignored) */
+ break;
+ case 27: /* esc (introducing an escape sequence) */
+ vc->state = TTY_STATE_ESC;
+ break;
+ default:
+ vc_put_one(vc, ch);
+ break;
+ }
+ break;
+ case TTY_STATE_ESC: /* check if it is a terminal escape sequence */
+ if (ch == '[') {
+ for(i=0;i<MAX_ESC_PARAMS;i++)
+ vc->esc_params[i] = 0;
+ vc->nb_esc_params = 0;
+ vc->state = TTY_STATE_CSI;
+ } else {
+ vc->state = TTY_STATE_NORM;
+ }
+ break;
+ case TTY_STATE_CSI: /* handle escape sequence parameters */
+ if (ch >= '0' && ch <= '9') {
+ 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 (vc->nb_esc_params < MAX_ESC_PARAMS)
+ vc->nb_esc_params++;
+ if (ch == ';' || ch == '?') {
+ break;
+ }
+ 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 (vc->esc_params[0] == 0) {
+ vc->esc_params[0] = 1;
+ }
+ vc_set_cursor(vc, s->x, s->y - vc->esc_params[0]);
+ break;
+ case 'B':
+ /* move cursor down */
+ if (vc->esc_params[0] == 0) {
+ vc->esc_params[0] = 1;
+ }
+ vc_set_cursor(vc, s->x, s->y + vc->esc_params[0]);
+ break;
+ case 'C':
+ /* move cursor right */
+ if (vc->esc_params[0] == 0) {
+ vc->esc_params[0] = 1;
+ }
+ vc_set_cursor(vc, s->x + vc->esc_params[0], s->y);
+ break;
+ case 'D':
+ /* move cursor left */
+ if (vc->esc_params[0] == 0) {
+ vc->esc_params[0] = 1;
+ }
+ vc_set_cursor(vc, s->x - vc->esc_params[0], s->y);
+ break;
+ case 'G':
+ /* move cursor to column */
+ 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, vc->esc_params[1] - 1, vc->esc_params[0] - 1);
+ break;
+ case 'J':
+ switch (vc->esc_params[0]) {
+ case 0:
+ /* clear to end of screen */
+ for (y = s->y; y < s->height; y++) {
+ for (x = 0; x < s->width; x++) {
+ if (y == s->y && x < s->x) {
+ continue;
+ }
+ vc_clear_xy(vc, x, y);
+ }
+ }
+ break;
+ case 1:
+ /* clear from beginning of screen */
+ for (y = 0; y <= s->y; y++) {
+ for (x = 0; x < s->width; x++) {
+ if (y == s->y && x > s->x) {
+ break;
+ }
+ vc_clear_xy(vc, x, y);
+ }
+ }
+ break;
+ case 2:
+ /* clear entire screen */
+ for (y = 0; y <= s->height; y++) {
+ for (x = 0; x < s->width; x++) {
+ vc_clear_xy(vc, x, y);
+ }
+ }
+ break;
+ }
+ break;
+ case 'K':
+ switch (vc->esc_params[0]) {
+ case 0:
+ /* clear to eol */
+ for(x = s->x; x < s->width; x++) {
+ 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++) {
+ vc_clear_xy(vc, x, s->y);
+ }
+ break;
+ case 2:
+ /* clear entire line */
+ for(x = 0; x < s->width; x++) {
+ vc_clear_xy(vc, x, s->y);
+ }
+ break;
+ }
+ break;
+ case 'm':
+ vc_handle_escape(vc);
+ break;
+ case 'n':
+ switch (vc->esc_params[0]) {
+ case 5:
+ /* report console status (always succeed)*/
+ 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);
+ vc_respond_str(vc, response);
+ break;
+ }
+ break;
+ case 's':
+ /* save cursor position */
+ vc->x_saved = s->x;
+ vc->y_saved = s->y;
+ break;
+ case 'u':
+ /* restore cursor position */
+ s->x = vc->x_saved;
+ s->y = vc->y_saved;
+ break;
+ default:
+ trace_console_putchar_unhandled(ch);
+ break;
+ }
+ break;
+ }
+ }
+}
+
+#define TYPE_CHARDEV_VC "chardev-vc"
+DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV,
+ TYPE_CHARDEV_VC)
+
+static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)
+{
+ VCChardev *drv = VC_CHARDEV(chr);
+ QemuTextConsole *s = drv->console;
+ int i;
+
+ s->update_x0 = s->width * FONT_WIDTH;
+ s->update_y0 = s->height * FONT_HEIGHT;
+ s->update_x1 = 0;
+ s->update_y1 = 0;
+ console_show_cursor(s, 0);
+ for(i = 0; i < len; i++) {
+ vc_putchar(drv, buf[i]);
+ }
+ console_show_cursor(s, 1);
+ if (s->update_x0 < s->update_x1) {
+ 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;
+}
+
+void qemu_text_console_update_cursor(void)
+{
+ 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);
+ }
+}
+
+static void
+cursor_timer_cb(void *opaque)
+{
+ qemu_text_console_update_cursor();
+}
+
+static void text_console_invalidate(void *opaque)
+{
+ QemuTextConsole *s = QEMU_TEXT_CONSOLE(opaque);
+
+ if (!QEMU_IS_FIXED_TEXT_CONSOLE(s)) {
+ text_console_resize(QEMU_TEXT_CONSOLE(s));
+ }
+ console_refresh(s);
+}
+
+static void
+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, cursor_timer_cb, NULL);
+ }
+}
+
+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
+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 void vc_chr_accept_input(Chardev *chr)
+{
+ VCChardev *drv = VC_CHARDEV(chr);
+
+ kbd_send_chars(drv->console);
+}
+
+static void vc_chr_set_echo(Chardev *chr, bool echo)
+{
+ VCChardev *drv = VC_CHARDEV(chr);
+
+ drv->console->echo = echo;
+}
+
+void qemu_text_console_select(QemuTextConsole *c)
+{
+ dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height);
+ qemu_text_console_update_cursor();
+}
+
+static void vc_chr_open(Chardev *chr,
+ ChardevBackend *backend,
+ bool *be_opened,
+ Error **errp)
+{
+ ChardevVC *vc = backend->u.vc.data;
+ VCChardev *drv = VC_CHARDEV(chr);
+ QemuTextConsole *s;
+ unsigned width = 0;
+ unsigned height = 0;
+
+ if (vc->has_width) {
+ width = vc->width;
+ } else if (vc->has_cols) {
+ width = vc->cols * FONT_WIDTH;
+ }
+
+ if (vc->has_height) {
+ height = vc->height;
+ } else if (vc->has_rows) {
+ height = vc->rows * FONT_HEIGHT;
+ }
+
+ 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));
+ }
+
+ dpy_gfx_replace_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(width, height));
+
+ s->chr = chr;
+ drv->console = 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;
+}
+
+static void vc_chr_parse(QemuOpts *opts, ChardevBackend *backend, Error **errp)
+{
+ int val;
+ ChardevVC *vc;
+
+ backend->type = CHARDEV_BACKEND_KIND_VC;
+ vc = backend->u.vc.data = g_new0(ChardevVC, 1);
+ qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc));
+
+ val = qemu_opt_get_number(opts, "width", 0);
+ if (val != 0) {
+ vc->has_width = true;
+ vc->width = val;
+ }
+
+ val = qemu_opt_get_number(opts, "height", 0);
+ if (val != 0) {
+ vc->has_height = true;
+ vc->height = val;
+ }
+
+ val = qemu_opt_get_number(opts, "cols", 0);
+ if (val != 0) {
+ vc->has_cols = true;
+ vc->cols = val;
+ }
+
+ val = qemu_opt_get_number(opts, "rows", 0);
+ if (val != 0) {
+ vc->has_rows = true;
+ vc->rows = val;
+ }
+}
+
+static void char_vc_class_init(ObjectClass *oc, void *data)
+{
+ ChardevClass *cc = CHARDEV_CLASS(oc);
+
+ cc->parse = vc_chr_parse;
+ cc->open = vc_chr_open;
+ cc->chr_write = vc_chr_write;
+ cc->chr_accept_input = vc_chr_accept_input;
+ cc->chr_set_echo = vc_chr_set_echo;
+}
+
+static const TypeInfo char_vc_type_info = {
+ .name = TYPE_CHARDEV_VC,
+ .parent = TYPE_CHARDEV,
+ .instance_size = sizeof(VCChardev),
+ .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);
+ }
+}
diff --git a/ui/console.c b/ui/console.c
index c2c1f22979..da341f08da 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -29,68 +29,16 @@
#include "qapi/qapi-commands-ui.h"
#include "qapi/visitor.h"
#include "qemu/coroutine.h"
-#include "qemu/fifo8.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qemu/option.h"
-#include "qemu/timer.h"
#include "chardev/char.h"
#include "trace.h"
#include "exec/memory.h"
#include "qom/object.h"
-#define DEFAULT_BACKSCROLL 512
-#define CONSOLE_CURSOR_PERIOD 500
-
-typedef struct TextAttributes {
- uint8_t fgcol:4;
- uint8_t bgcol:4;
- uint8_t bold:1;
- uint8_t uline:1;
- uint8_t blink:1;
- uint8_t invers:1;
- 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;
-} TextCell;
-
-#define MAX_ESC_PARAMS 3
-
-enum TTYState {
- TTY_STATE_NORM,
- TTY_STATE_ESC,
- TTY_STATE_CSI,
-};
-
-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;
-};
+#include "console-priv.h"
OBJECT_DEFINE_ABSTRACT_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJECT)
@@ -108,54 +56,6 @@ typedef QemuConsoleClass QemuGraphicConsoleClass;
OBJECT_DEFINE_TYPE(QemuGraphicConsole, qemu_graphic_console, QEMU_GRAPHIC_CONSOLE, QEMU_CONSOLE)
-typedef 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;
-
-OBJECT_DEFINE_TYPE(QemuTextConsole, qemu_text_console, QEMU_TEXT_CONSOLE, QEMU_CONSOLE)
-
-typedef struct QemuFixedTextConsole {
- QemuTextConsole parent;
-} QemuFixedTextConsole;
-
-typedef QemuTextConsoleClass QemuFixedTextConsoleClass;
-
-OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_text_console, QEMU_FIXED_TEXT_CONSOLE, QEMU_TEXT_CONSOLE)
-
-struct VCChardev {
- Chardev parent;
- QemuTextConsole *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;
-
struct DisplayState {
QEMUTimer *gui_timer;
uint64_t last_update;
@@ -169,12 +69,9 @@ static DisplayState *display_state;
static QemuConsole *active_console;
static QTAILQ_HEAD(, QemuConsole) consoles =
QTAILQ_HEAD_INITIALIZER(consoles);
-static bool cursor_visible_phase;
-static QEMUTimer *cursor_timer;
static void dpy_refresh(DisplayState *s);
static DisplayState *get_alloc_displaystate(void);
-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);
@@ -330,663 +227,6 @@ void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
}
}
-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 = {
- .x = posx, .y = posy, .width = width, .height = height
- };
-
- assert(surface);
- pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface->image,
- &color, 1, &rect);
-}
-
-/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, 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);
-
- assert(surface);
- pixman_image_composite(PIXMAN_OP_SRC,
- surface->image, NULL, surface->image,
- xs, ys, 0, 0, xd, yd, w, h);
-}
-
-/***********************************************************/
-/* basic char display */
-
-#define FONT_HEIGHT 16
-#define FONT_WIDTH 8
-
-#include "vgafont.h"
-
-static const pixman_color_t color_table_rgb[2][8] = {
- { /* dark */
- [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_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 */
- }
-};
-
-static void vga_putcharxy(QemuConsole *s, int x, int y, int ch,
- TextAttributes *t_attrib)
-{
- static pixman_image_t *glyphs[256];
- 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];
- } else {
- fgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol];
- bgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol];
- }
-
- if (!glyphs[ch]) {
- glyphs[ch] = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, ch);
- }
- qemu_pixman_glyph_render(glyphs[ch], surface->image,
- &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT);
-}
-
-static void text_console_resize(QemuTextConsole *t)
-{
- QemuConsole *s = QEMU_CONSOLE(t);
- TextCell *cells, *c, *c1;
- 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 = w;
- t->height = h;
-
- w1 = MIN(t->width, last_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 = &t->cells[y * last_width];
- for (x = 0; x < w1; x++) {
- *c++ = *c1++;
- }
- }
- for (x = w1; x < t->width; x++) {
- c->ch = ' ';
- c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
- c++;
- }
- }
- g_free(t->cells);
- t->cells = cells;
-}
-
-static void invalidate_xy(QemuTextConsole *s, int x, int y)
-{
- if (!qemu_console_is_visible(QEMU_CONSOLE(s))) {
- return;
- }
- if (s->update_x0 > x * FONT_WIDTH)
- s->update_x0 = x * FONT_WIDTH;
- if (s->update_y0 > y * FONT_HEIGHT)
- s->update_y0 = y * FONT_HEIGHT;
- if (s->update_x1 < (x + 1) * FONT_WIDTH)
- s->update_x1 = (x + 1) * FONT_WIDTH;
- if (s->update_y1 < (y + 1) * FONT_HEIGHT)
- s->update_y1 = (y + 1) * FONT_HEIGHT;
-}
-
-static void vc_update_xy(VCChardev *vc, int x, int y)
-{
- QemuTextConsole *s = vc->console;
- TextCell *c;
- int y1, y2;
-
- 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;
- if (y2 < 0) {
- y2 += s->total_height;
- }
- if (y2 < s->height) {
- if (x >= s->width) {
- x = s->width - 1;
- }
- c = &s->cells[y1 * s->width + x];
- vga_putcharxy(QEMU_CONSOLE(s), x, y2, c->ch,
- &(c->t_attrib));
- invalidate_xy(s, x, y2);
- }
-}
-
-static void console_show_cursor(QemuTextConsole *s, int show)
-{
- TextCell *c;
- int y, y1;
- int x = s->x;
-
- s->cursor_invalidate = 1;
-
- if (x >= s->width) {
- x = s->width - 1;
- }
- y1 = (s->y_base + s->y) % s->total_height;
- y = y1 - s->y_displayed;
- if (y < 0) {
- y += s->total_height;
- }
- if (y < s->height) {
- c = &s->cells[y1 * s->width + x];
- if (show && cursor_visible_phase) {
- TextAttributes t_attrib = TEXT_ATTRIBUTES_DEFAULT;
- t_attrib.invers = !(t_attrib.invers); /* invert fg and bg */
- vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &t_attrib);
- } else {
- vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &(c->t_attrib));
- }
- invalidate_xy(s, x, y);
- }
-}
-
-static void console_refresh(QemuTextConsole *s)
-{
- DisplaySurface *surface = qemu_console_surface(QEMU_CONSOLE(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;
- s->text_y[1] = s->height - 1;
- s->cursor_invalidate = 1;
-
- 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;
- for (x = 0; x < s->width; x++) {
- vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch,
- &(c->t_attrib));
- c++;
- }
- if (++y1 == s->total_height) {
- y1 = 0;
- }
- }
- console_show_cursor(s, 1);
- dpy_gfx_update(QEMU_CONSOLE(s), 0, 0,
- surface_width(surface), surface_height(surface));
-}
-
-static void console_scroll(QemuTextConsole *s, int ydelta)
-{
- int i, y1;
-
- if (ydelta > 0) {
- for(i = 0; i < ydelta; i++) {
- if (s->y_displayed == s->y_base)
- break;
- if (++s->y_displayed == s->total_height)
- s->y_displayed = 0;
- }
- } else {
- ydelta = -ydelta;
- i = s->backscroll_height;
- if (i > s->total_height - s->height)
- i = s->total_height - s->height;
- y1 = s->y_base - i;
- if (y1 < 0)
- y1 += s->total_height;
- for(i = 0; i < ydelta; i++) {
- if (s->y_displayed == y1)
- break;
- if (--s->y_displayed < 0)
- s->y_displayed = s->total_height - 1;
- }
- }
- console_refresh(s);
-}
-
-static void vc_put_lf(VCChardev *vc)
-{
- QemuTextConsole *s = vc->console;
- TextCell *c;
- int x, y1;
-
- s->y++;
- if (s->y >= s->height) {
- s->y = s->height - 1;
-
- if (s->y_displayed == s->y_base) {
- if (++s->y_displayed == s->total_height)
- s->y_displayed = 0;
- }
- if (++s->y_base == s->total_height)
- s->y_base = 0;
- if (s->backscroll_height < s->total_height)
- s->backscroll_height++;
- y1 = (s->y_base + s->height - 1) % s->total_height;
- c = &s->cells[y1 * s->width];
- for(x = 0; x < s->width; x++) {
- c->ch = ' ';
- c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
- c++;
- }
- if (s->y_displayed == s->y_base) {
- s->text_x[0] = 0;
- s->text_y[0] = 0;
- s->text_x[1] = s->width - 1;
- s->text_y[1] = s->height - 1;
-
- 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;
- s->update_y1 = s->height * FONT_HEIGHT;
- }
- }
-}
-
-/* Set console attributes depending on the current escape codes.
- * 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 vc_handle_escape(VCChardev *vc)
-{
- int i;
-
- for (i = 0; i < vc->nb_esc_params; i++) {
- switch (vc->esc_params[i]) {
- case 0: /* reset all console attributes to default */
- vc->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
- break;
- case 1:
- vc->t_attrib.bold = 1;
- break;
- case 4:
- vc->t_attrib.uline = 1;
- break;
- case 5:
- vc->t_attrib.blink = 1;
- break;
- case 7:
- vc->t_attrib.invers = 1;
- break;
- case 8:
- vc->t_attrib.unvisible = 1;
- break;
- case 22:
- vc->t_attrib.bold = 0;
- break;
- case 24:
- vc->t_attrib.uline = 0;
- break;
- case 25:
- vc->t_attrib.blink = 0;
- break;
- case 27:
- vc->t_attrib.invers = 0;
- break;
- case 28:
- vc->t_attrib.unvisible = 0;
- break;
- /* set foreground color */
- case 30:
- vc->t_attrib.fgcol = QEMU_COLOR_BLACK;
- break;
- case 31:
- vc->t_attrib.fgcol = QEMU_COLOR_RED;
- break;
- case 32:
- vc->t_attrib.fgcol = QEMU_COLOR_GREEN;
- break;
- case 33:
- vc->t_attrib.fgcol = QEMU_COLOR_YELLOW;
- break;
- case 34:
- vc->t_attrib.fgcol = QEMU_COLOR_BLUE;
- break;
- case 35:
- vc->t_attrib.fgcol = QEMU_COLOR_MAGENTA;
- break;
- case 36:
- vc->t_attrib.fgcol = QEMU_COLOR_CYAN;
- break;
- case 37:
- vc->t_attrib.fgcol = QEMU_COLOR_WHITE;
- break;
- /* set background color */
- case 40:
- vc->t_attrib.bgcol = QEMU_COLOR_BLACK;
- break;
- case 41:
- vc->t_attrib.bgcol = QEMU_COLOR_RED;
- break;
- case 42:
- vc->t_attrib.bgcol = QEMU_COLOR_GREEN;
- break;
- case 43:
- vc->t_attrib.bgcol = QEMU_COLOR_YELLOW;
- break;
- case 44:
- vc->t_attrib.bgcol = QEMU_COLOR_BLUE;
- break;
- case 45:
- vc->t_attrib.bgcol = QEMU_COLOR_MAGENTA;
- break;
- case 46:
- vc->t_attrib.bgcol = QEMU_COLOR_CYAN;
- break;
- case 47:
- vc->t_attrib.bgcol = QEMU_COLOR_WHITE;
- break;
- }
- }
-}
-
-static void vc_clear_xy(VCChardev *vc, int x, int y)
-{
- QemuTextConsole *s = vc->console;
- int y1 = (s->y_base + y) % s->total_height;
- if (x >= s->width) {
- x = s->width - 1;
- }
- TextCell *c = &s->cells[y1 * s->width + x];
- c->ch = ' ';
- c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
- vc_update_xy(vc, x, y);
-}
-
-static void vc_put_one(VCChardev *vc, int ch)
-{
- QemuTextConsole *s = vc->console;
- TextCell *c;
- int y1;
- if (s->x >= s->width) {
- /* line wrap */
- s->x = 0;
- 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 = vc->t_attrib;
- vc_update_xy(vc, s->x, s->y);
- s->x++;
-}
-
-static void vc_respond_str(VCChardev *vc, const char *buf)
-{
- while (*buf) {
- vc_put_one(vc, *buf);
- buf++;
- }
-}
-
-/* set cursor, checking bounds */
-static void vc_set_cursor(VCChardev *vc, int x, int y)
-{
- QemuTextConsole *s = vc->console;
-
- if (x < 0) {
- x = 0;
- }
- if (y < 0) {
- y = 0;
- }
- if (y >= s->height) {
- y = s->height - 1;
- }
- if (x >= s->width) {
- x = s->width - 1;
- }
-
- s->x = x;
- s->y = y;
-}
-
-static void vc_putchar(VCChardev *vc, int ch)
-{
- QemuTextConsole *s = vc->console;
- int i;
- int x, y;
- char response[40];
-
- switch(vc->state) {
- case TTY_STATE_NORM:
- switch(ch) {
- case '\r': /* carriage return */
- s->x = 0;
- break;
- case '\n': /* newline */
- vc_put_lf(vc);
- break;
- case '\b': /* backspace */
- if (s->x > 0)
- s->x--;
- break;
- case '\t': /* tabspace */
- if (s->x + (8 - (s->x % 8)) > s->width) {
- s->x = 0;
- vc_put_lf(vc);
- } else {
- s->x = s->x + (8 - (s->x % 8));
- }
- break;
- case '\a': /* alert aka. bell */
- /* TODO: has to be implemented */
- break;
- case 14:
- /* SI (shift in), character set 0 (ignored) */
- break;
- case 15:
- /* SO (shift out), character set 1 (ignored) */
- break;
- case 27: /* esc (introducing an escape sequence) */
- vc->state = TTY_STATE_ESC;
- break;
- default:
- vc_put_one(vc, ch);
- break;
- }
- break;
- case TTY_STATE_ESC: /* check if it is a terminal escape sequence */
- if (ch == '[') {
- for(i=0;i<MAX_ESC_PARAMS;i++)
- vc->esc_params[i] = 0;
- vc->nb_esc_params = 0;
- vc->state = TTY_STATE_CSI;
- } else {
- vc->state = TTY_STATE_NORM;
- }
- break;
- case TTY_STATE_CSI: /* handle escape sequence parameters */
- if (ch >= '0' && ch <= '9') {
- 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 (vc->nb_esc_params < MAX_ESC_PARAMS)
- vc->nb_esc_params++;
- if (ch == ';' || ch == '?') {
- break;
- }
- 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 (vc->esc_params[0] == 0) {
- vc->esc_params[0] = 1;
- }
- vc_set_cursor(vc, s->x, s->y - vc->esc_params[0]);
- break;
- case 'B':
- /* move cursor down */
- if (vc->esc_params[0] == 0) {
- vc->esc_params[0] = 1;
- }
- vc_set_cursor(vc, s->x, s->y + vc->esc_params[0]);
- break;
- case 'C':
- /* move cursor right */
- if (vc->esc_params[0] == 0) {
- vc->esc_params[0] = 1;
- }
- vc_set_cursor(vc, s->x + vc->esc_params[0], s->y);
- break;
- case 'D':
- /* move cursor left */
- if (vc->esc_params[0] == 0) {
- vc->esc_params[0] = 1;
- }
- vc_set_cursor(vc, s->x - vc->esc_params[0], s->y);
- break;
- case 'G':
- /* move cursor to column */
- 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, vc->esc_params[1] - 1, vc->esc_params[0] - 1);
- break;
- case 'J':
- switch (vc->esc_params[0]) {
- case 0:
- /* clear to end of screen */
- for (y = s->y; y < s->height; y++) {
- for (x = 0; x < s->width; x++) {
- if (y == s->y && x < s->x) {
- continue;
- }
- vc_clear_xy(vc, x, y);
- }
- }
- break;
- case 1:
- /* clear from beginning of screen */
- for (y = 0; y <= s->y; y++) {
- for (x = 0; x < s->width; x++) {
- if (y == s->y && x > s->x) {
- break;
- }
- vc_clear_xy(vc, x, y);
- }
- }
- break;
- case 2:
- /* clear entire screen */
- for (y = 0; y <= s->height; y++) {
- for (x = 0; x < s->width; x++) {
- vc_clear_xy(vc, x, y);
- }
- }
- break;
- }
- break;
- case 'K':
- switch (vc->esc_params[0]) {
- case 0:
- /* clear to eol */
- for(x = s->x; x < s->width; x++) {
- 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++) {
- vc_clear_xy(vc, x, s->y);
- }
- break;
- case 2:
- /* clear entire line */
- for(x = 0; x < s->width; x++) {
- vc_clear_xy(vc, x, s->y);
- }
- break;
- }
- break;
- case 'm':
- vc_handle_escape(vc);
- break;
- case 'n':
- switch (vc->esc_params[0]) {
- case 5:
- /* report console status (always succeed)*/
- 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);
- vc_respond_str(vc, response);
- break;
- }
- break;
- case 's':
- /* save cursor position */
- vc->x_saved = s->x;
- vc->y_saved = s->y;
- break;
- case 'u':
- /* restore cursor position */
- s->x = vc->x_saved;
- s->y = vc->y_saved;
- break;
- default:
- trace_console_putchar_unhandled(ch);
- break;
- }
- break;
- }
- }
-}
-
static void displaychangelistener_gfx_switch(DisplayChangeListener *dcl,
struct DisplaySurface *new_surface,
bool update)
@@ -1065,13 +305,6 @@ 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;
@@ -1096,101 +329,6 @@ void console_select(unsigned int index)
}
}
-#define TYPE_CHARDEV_VC "chardev-vc"
-DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV,
- TYPE_CHARDEV_VC)
-
-static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)
-{
- VCChardev *drv = VC_CHARDEV(chr);
- QemuTextConsole *s = drv->console;
- int i;
-
- s->update_x0 = s->width * FONT_WIDTH;
- s->update_y0 = s->height * FONT_HEIGHT;
- s->update_x1 = 0;
- s->update_y1 = 0;
- console_show_cursor(s, 0);
- for(i = 0; i < len; i++) {
- vc_putchar(drv, buf[i]);
- }
- console_show_cursor(s, 1);
- if (s->update_x0 < s->update_x1) {
- 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(QemuTextConsole *s)
-{
- uint32_t len, avail;
-
- len = qemu_chr_be_can_write(s->chr);
- avail = fifo8_num_used(&s->out_fifo);
- while (len > 0 && avail > 0) {
- const uint8_t *buf;
- uint32_t size;
-
- buf = fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size);
- qemu_chr_be_write(s->chr, buf, size);
- len = qemu_chr_be_can_write(s->chr);
- avail -= size;
- }
-}
-
-/* called when an ascii key is pressed */
-static void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym)
-{
- uint8_t buf[16], *q;
- int c;
- uint32_t num_free;
-
- switch(keysym) {
- case QEMU_KEY_CTRL_UP:
- console_scroll(s, -1);
- break;
- case QEMU_KEY_CTRL_DOWN:
- console_scroll(s, 1);
- break;
- case QEMU_KEY_CTRL_PAGEUP:
- console_scroll(s, -10);
- break;
- case QEMU_KEY_CTRL_PAGEDOWN:
- console_scroll(s, 10);
- break;
- default:
- /* convert the QEMU keysym to VT100 key string */
- q = buf;
- if (keysym >= 0xe100 && keysym <= 0xe11f) {
- *q++ = '\033';
- *q++ = '[';
- c = keysym - 0xe100;
- if (c >= 10)
- *q++ = '0' + (c / 10);
- *q++ = '0' + (c % 10);
- *q++ = '~';
- } else if (keysym >= 0xe120 && keysym <= 0xe17f) {
- *q++ = '\033';
- *q++ = '[';
- *q++ = keysym & 0xff;
- } else if (s->echo && (keysym == '\r' || keysym == '\n')) {
- qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true);
- *q++ = '\n';
- } else {
- *q++ = keysym;
- }
- if (s->echo) {
- 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));
- kbd_send_chars(s);
- break;
- }
-}
-
void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym)
{
if (!s) {
@@ -1249,45 +387,6 @@ void qemu_text_console_put_string(QemuTextConsole *s, const char *str, int len)
}
}
-static void text_console_invalidate(void *opaque)
-{
- QemuTextConsole *s = QEMU_TEXT_CONSOLE(opaque);
-
- 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)
-{
- QemuTextConsole *s = QEMU_TEXT_CONSOLE(opaque);
- int i, j, src;
-
- if (s->text_x[0] <= s->text_x[1]) {
- src = (s->y_base + s->text_y[0]) * s->width;
- chardata += s->text_y[0] * s->width;
- for (i = s->text_y[0]; i <= s->text_y[1]; i ++)
- for (j = 0; j < s->width; j++, src++) {
- console_write_ch(chardata ++,
- ATTR2CHTYPE(s->cells[src].ch,
- s->cells[src].t_attrib.fgcol,
- s->cells[src].t_attrib.bgcol,
- s->cells[src].t_attrib.bold));
- }
- 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;
- s->text_x[1] = 0;
- s->text_y[1] = 0;
- }
- if (s->cursor_invalidate) {
- dpy_text_cursor(QEMU_CONSOLE(s), s->x, s->y);
- s->cursor_invalidate = 0;
- }
-}
-
static void
qemu_console_register(QemuConsole *c)
{
@@ -1396,51 +495,6 @@ 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)
-{
- if (!cursor_timer) {
- cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
- qemu_text_console_update_cursor, NULL);
- }
-}
-
-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
-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)
-{
-}
-
#ifdef WIN32
void qemu_displaysurface_win32_set_handle(DisplaySurface *surface,
HANDLE h, uint32_t offset)
@@ -1692,6 +746,7 @@ dcl_set_graphic_cursor(DisplayChangeListener *dcl, QemuGraphicConsole *con)
dcl->ops->dpy_mouse_set(dcl, con->cursor_x, con->cursor_y, con->cursor_on);
}
}
+
void register_displaychangelistener(DisplayChangeListener *dcl)
{
QemuConsole *con;
@@ -1712,7 +767,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
if (QEMU_IS_GRAPHIC_CONSOLE(con)) {
dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(con));
}
- qemu_text_console_update_cursor(NULL);
+ qemu_text_console_update_cursor();
}
void update_displaychangelistener(DisplayChangeListener *dcl,
@@ -2399,13 +1454,6 @@ 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)) {
@@ -2500,20 +1548,6 @@ int qemu_console_get_height(QemuConsole *con, int fallback)
}
}
-static void vc_chr_accept_input(Chardev *chr)
-{
- VCChardev *drv = VC_CHARDEV(chr);
-
- kbd_send_chars(drv->console);
-}
-
-static void vc_chr_set_echo(Chardev *chr, bool echo)
-{
- VCChardev *drv = VC_CHARDEV(chr);
-
- drv->console->echo = echo;
-}
-
int qemu_invalidate_text_consoles(void)
{
QemuConsole *s;
@@ -2531,70 +1565,6 @@ int qemu_invalidate_text_consoles(void)
return count;
}
-static void qemu_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);
- }
-}
-
-static void vc_chr_open(Chardev *chr,
- ChardevBackend *backend,
- bool *be_opened,
- Error **errp)
-{
- ChardevVC *vc = backend->u.vc.data;
- VCChardev *drv = VC_CHARDEV(chr);
- QemuTextConsole *s;
- unsigned width = 0;
- unsigned height = 0;
-
- if (vc->has_width) {
- width = vc->width;
- } else if (vc->has_cols) {
- width = vc->cols * FONT_WIDTH;
- }
-
- if (vc->has_height) {
- height = vc->height;
- } else if (vc->has_rows) {
- height = vc->rows * FONT_HEIGHT;
- }
-
- 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));
- }
-
- dpy_gfx_replace_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(width, height));
-
- s->chr = chr;
- drv->console = 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)
{
DisplaySurface *surface = qemu_console_surface(s);
@@ -2721,63 +1691,3 @@ void qemu_display_help(void)
}
}
}
-
-static void vc_chr_parse(QemuOpts *opts, ChardevBackend *backend, Error **errp)
-{
- int val;
- ChardevVC *vc;
-
- backend->type = CHARDEV_BACKEND_KIND_VC;
- vc = backend->u.vc.data = g_new0(ChardevVC, 1);
- qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc));
-
- val = qemu_opt_get_number(opts, "width", 0);
- if (val != 0) {
- vc->has_width = true;
- vc->width = val;
- }
-
- val = qemu_opt_get_number(opts, "height", 0);
- if (val != 0) {
- vc->has_height = true;
- vc->height = val;
- }
-
- val = qemu_opt_get_number(opts, "cols", 0);
- if (val != 0) {
- vc->has_cols = true;
- vc->cols = val;
- }
-
- val = qemu_opt_get_number(opts, "rows", 0);
- if (val != 0) {
- vc->has_rows = true;
- vc->rows = val;
- }
-}
-
-static void char_vc_class_init(ObjectClass *oc, void *data)
-{
- ChardevClass *cc = CHARDEV_CLASS(oc);
-
- cc->parse = vc_chr_parse;
- cc->open = vc_chr_open;
- cc->chr_write = vc_chr_write;
- cc->chr_accept_input = vc_chr_accept_input;
- cc->chr_set_echo = vc_chr_set_echo;
-}
-
-static const TypeInfo char_vc_type_info = {
- .name = TYPE_CHARDEV_VC,
- .parent = TYPE_CHARDEV,
- .instance_size = sizeof(VCChardev),
- .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);
- }
-}
diff --git a/ui/meson.build b/ui/meson.build
index d81609fb0e..0a1e8272a3 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -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',
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 49/67] ui/vc: split off the VC part from console.c
2023-08-30 9:38 ` [PATCH 49/67] ui/vc: split off the VC part from console.c marcandre.lureau
@ 2023-09-01 17:23 ` Daniel P. Berrangé
2023-09-04 12:57 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 17:23 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:23PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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)
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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
>
> diff --git a/ui/console-vc.c b/ui/console-vc.c
> new file mode 100644
> index 0000000000..656f099556
> --- /dev/null
> +++ b/ui/console-vc.c
> @@ -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
--
|: 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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 49/67] ui/vc: split off the VC part from console.c
2023-09-01 17:23 ` Daniel P. Berrangé
@ 2023-09-04 12:57 ` Marc-André Lureau
2023-09-04 13:05 ` Daniel P. Berrangé
0 siblings, 1 reply; 157+ messages in thread
From: Marc-André Lureau @ 2023-09-04 12:57 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel, Gerd Hoffmann
Hi
On Fri, Sep 1, 2023 at 9:23 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 01:38:23PM +0400, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > 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)
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > 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
> >
> > diff --git a/ui/console-vc.c b/ui/console-vc.c
> > new file mode 100644
> > index 0000000000..656f099556
> > --- /dev/null
> > +++ b/ui/console-vc.c
> > @@ -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
>
> The include/ui/console.h header 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
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 49/67] ui/vc: split off the VC part from console.c
2023-09-04 12:57 ` Marc-André Lureau
@ 2023-09-04 13:05 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-04 13:05 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Gerd Hoffmann
On Mon, Sep 04, 2023 at 04:57:45PM +0400, Marc-André Lureau wrote:
> Hi
>
> On Fri, Sep 1, 2023 at 9:23 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Wed, Aug 30, 2023 at 01:38:23PM +0400, marcandre.lureau@redhat.com wrote:
> > > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > > 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)
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > > 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
> > >
> > > diff --git a/ui/console-vc.c b/ui/console-vc.c
> > > new file mode 100644
> > > index 0000000000..656f099556
> > > --- /dev/null
> > > +++ b/ui/console-vc.c
> > > @@ -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
>
> >
> > The include/ui/console.h header 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,
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 50/67] ui/console: move DisplaySurface to its own header
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (48 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 49/67] ui/vc: split off the VC part from console.c marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 17:24 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 51/67] build-sys: add optional "pixman" feature marcandre.lureau
` (17 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Mostly for readability reasons.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/console.h | 84 +---------------------------------------
include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+), 83 deletions(-)
create mode 100644 include/ui/surface.h
diff --git a/include/ui/console.h b/include/ui/console.h
index 93bb03a9e2..79e4702912 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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)
diff --git a/include/ui/surface.h b/include/ui/surface.h
new file mode 100644
index 0000000000..37725a303e
--- /dev/null
+++ b/include/ui/surface.h
@@ -0,0 +1,91 @@
+#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
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 50/67] ui/console: move DisplaySurface to its own header
2023-08-30 9:38 ` [PATCH 50/67] ui/console: move DisplaySurface to its own header marcandre.lureau
@ 2023-09-01 17:24 ` Daniel P. Berrangé
2023-09-04 12:59 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 17:24 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:24PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Mostly for readability reasons.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/ui/console.h | 84 +---------------------------------------
> include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 92 insertions(+), 83 deletions(-)
> create mode 100644 include/ui/surface.h
>
> diff --git a/include/ui/surface.h b/include/ui/surface.h
> new file mode 100644
> index 0000000000..37725a303e
> --- /dev/null
> +++ b/include/ui/surface.h
> @@ -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.
> +#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
> --
> 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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 50/67] ui/console: move DisplaySurface to its own header
2023-09-01 17:24 ` Daniel P. Berrangé
@ 2023-09-04 12:59 ` Marc-André Lureau
2023-09-04 13:05 ` Daniel P. Berrangé
0 siblings, 1 reply; 157+ messages in thread
From: Marc-André Lureau @ 2023-09-04 12:59 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel, Gerd Hoffmann
Hi
On Fri, Sep 1, 2023 at 9:24 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 01:38:24PM +0400, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Mostly for readability reasons.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > include/ui/console.h | 84 +---------------------------------------
> > include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 92 insertions(+), 83 deletions(-)
> > create mode 100644 include/ui/surface.h
> >
>
> > diff --git a/include/ui/surface.h b/include/ui/surface.h
> > new file mode 100644
> > index 0000000000..37725a303e
> > --- /dev/null
> > +++ b/include/ui/surface.h
> > @@ -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.
>
Done. R-B with that change?
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 50/67] ui/console: move DisplaySurface to its own header
2023-09-04 12:59 ` Marc-André Lureau
@ 2023-09-04 13:05 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-04 13:05 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Gerd Hoffmann
On Mon, Sep 04, 2023 at 04:59:31PM +0400, Marc-André Lureau wrote:
> Hi
>
> On Fri, Sep 1, 2023 at 9:24 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Wed, Aug 30, 2023 at 01:38:24PM +0400, marcandre.lureau@redhat.com wrote:
> > > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > > Mostly for readability reasons.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > > include/ui/console.h | 84 +---------------------------------------
> > > include/ui/surface.h | 91 ++++++++++++++++++++++++++++++++++++++++++++
> > > 2 files changed, 92 insertions(+), 83 deletions(-)
> > > create mode 100644 include/ui/surface.h
> > >
> >
> > > diff --git a/include/ui/surface.h b/include/ui/surface.h
> > > new file mode 100644
> > > index 0000000000..37725a303e
> > > --- /dev/null
> > > +++ b/include/ui/surface.h
> > > @@ -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.
> >
>
>
> Done. R-B with that change?
Yep, Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
with the GPL-2.0-or-later addition
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 51/67] build-sys: add optional "pixman" feature
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (49 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 50/67] ui/console: move DisplaySurface to its own header marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:48 ` Philippe Mathieu-Daudé
2023-08-30 9:38 ` [PATCH 52/67] ui: compile out some qemu-pixman functions when !PIXMAN marcandre.lureau
` (16 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé, Thomas Huth, Philippe Mathieu-Daudé
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Set CONFIG_PIXMAN accordinly.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
meson.build | 6 ++++--
Kconfig.host | 3 +++
meson_options.txt | 2 ++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
index 98e68ef0b1..3bd7046099 100644
--- a/meson.build
+++ b/meson.build
@@ -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'] : []) + \
diff --git a/Kconfig.host b/Kconfig.host
index d763d89269..b6ac2b9316 100644
--- a/Kconfig.host
+++ b/Kconfig.host
@@ -11,6 +11,9 @@ config OPENGL
config X11
bool
+config PIXMAN
+ bool
+
config SPICE
bool
diff --git a/meson_options.txt b/meson_options.txt
index aaea5ddd77..89654fd77d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -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',
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 51/67] build-sys: add optional "pixman" feature
2023-08-30 9:38 ` [PATCH 51/67] build-sys: add optional "pixman" feature marcandre.lureau
@ 2023-08-30 15:48 ` Philippe Mathieu-Daudé
2023-08-30 15:55 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:48 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
Cc: Gerd Hoffmann, Paolo Bonzini, Daniel P. Berrangé,
Thomas Huth
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Set CONFIG_PIXMAN accordinly.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> meson.build | 6 ++++--
> Kconfig.host | 3 +++
> meson_options.txt | 2 ++
> 3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 98e68ef0b1..3bd7046099 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -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'] : []) + \
> diff --git a/Kconfig.host b/Kconfig.host
> index d763d89269..b6ac2b9316 100644
> --- a/Kconfig.host
> +++ b/Kconfig.host
> @@ -11,6 +11,9 @@ config OPENGL
> config X11
> bool
>
> +config PIXMAN
> + bool
> +
> config SPICE
> bool
>
> diff --git a/meson_options.txt b/meson_options.txt
> index aaea5ddd77..89654fd77d 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -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 --
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 9da3fe299b..16957ea9f0 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -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 ;;
---
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 51/67] build-sys: add optional "pixman" feature
2023-08-30 15:48 ` Philippe Mathieu-Daudé
@ 2023-08-30 15:55 ` Philippe Mathieu-Daudé
2023-09-01 17:25 ` Daniel P. Berrangé
0 siblings, 1 reply; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:55 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
Cc: Gerd Hoffmann, Paolo Bonzini, Daniel P. Berrangé,
Thomas Huth
On 30/8/23 17:48, Philippe Mathieu-Daudé wrote:
> On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
>> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>>
>> Set CONFIG_PIXMAN accordinly.
>>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>> meson.build | 6 ++++--
>> Kconfig.host | 3 +++
>> meson_options.txt | 2 ++
>> 3 files changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/meson.build b/meson.build
>> index 98e68ef0b1..3bd7046099 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -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')
>> diff --git a/meson_options.txt b/meson_options.txt
>> index aaea5ddd77..89654fd77d 100644
>> --- a/meson_options.txt
>> +++ b/meson_options.txt
>> @@ -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 --
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index 9da3fe299b..16957ea9f0 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -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 ;;
> ---
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
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 51/67] build-sys: add optional "pixman" feature
2023-08-30 15:55 ` Philippe Mathieu-Daudé
@ 2023-09-01 17:25 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 17:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: marcandre.lureau, qemu-devel, Gerd Hoffmann, Paolo Bonzini,
Thomas Huth
On Wed, Aug 30, 2023 at 05:55:26PM +0200, Philippe Mathieu-Daudé wrote:
> On 30/8/23 17:48, Philippe Mathieu-Daudé wrote:
> > On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> > > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > > Set CONFIG_PIXMAN accordinly.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > > meson.build | 6 ++++--
> > > Kconfig.host | 3 +++
> > > meson_options.txt | 2 ++
> > > 3 files changed, 9 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/meson.build b/meson.build
> > > index 98e68ef0b1..3bd7046099 100644
> > > --- a/meson.build
> > > +++ b/meson.build
> > > @@ -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')
>
>
> > > diff --git a/meson_options.txt b/meson_options.txt
> > > index aaea5ddd77..89654fd77d 100644
> > > --- a/meson_options.txt
> > > +++ b/meson_options.txt
> > > @@ -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 --
> > diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> > index 9da3fe299b..16957ea9f0 100644
> > --- a/scripts/meson-buildoptions.sh
> > +++ b/scripts/meson-buildoptions.sh
> > @@ -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 ;;
> > ---
>
> 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
--
|: 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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 52/67] ui: compile out some qemu-pixman functions when !PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (50 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 51/67] build-sys: add optional "pixman" feature marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 53/67] ui: add pixman-compat.h marcandre.lureau
` (15 subsequent siblings)
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Those functions require the PIXMAN library.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/qemu-pixman.h | 7 +++++--
ui/qemu-pixman.c | 6 ++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index 51f8709327..c5a0911cc7 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -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)
diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index be00a96340..4272a43744 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -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 */
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 53/67] ui: add pixman-compat.h
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (51 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 52/67] ui: compile out some qemu-pixman functions when !PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 11:17 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 54/67] ui/vc: console-vc requires PIXMAN marcandre.lureau
` (14 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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
diff --git a/include/ui/pixman-compat.h b/include/ui/pixman-compat.h
new file mode 100644
index 0000000000..e511c8b946
--- /dev/null
+++ b/include/ui/pixman-compat.h
@@ -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 */
diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index c5a0911cc7..9c693df8dd 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -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,
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 53/67] ui: add pixman-compat.h
2023-08-30 9:38 ` [PATCH 53/67] ui: add pixman-compat.h marcandre.lureau
@ 2023-08-30 11:17 ` Daniel P. Berrangé
2023-08-30 11:23 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-08-30 11:17 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:27PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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.
>
> diff --git a/include/ui/pixman-compat.h b/include/ui/pixman-compat.h
> new file mode 100644
> index 0000000000..e511c8b946
> --- /dev/null
> +++ b/include/ui/pixman-compat.h
> @@ -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 */
> diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
> index c5a0911cc7..9c693df8dd 100644
> --- a/include/ui/qemu-pixman.h
> +++ b/include/ui/qemu-pixman.h
> @@ -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,
> --
> 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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 53/67] ui: add pixman-compat.h
2023-08-30 11:17 ` Daniel P. Berrangé
@ 2023-08-30 11:23 ` Marc-André Lureau
0 siblings, 0 replies; 157+ messages in thread
From: Marc-André Lureau @ 2023-08-30 11:23 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel, Gerd Hoffmann
Hi
On Wed, Aug 30, 2023 at 3:17 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 01:38:27PM +0400, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > 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.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > 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.
It's very limited though, as that compat doesn't offer any pixel manipulation.
>
> 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.
>
> Keeping building stuff that actually wants pixman, via a
> compat API is imposing a burden on QEMU without a compelling
> gain IMHO.
>
> >
> > diff --git a/include/ui/pixman-compat.h b/include/ui/pixman-compat.h
> > new file mode 100644
> > index 0000000000..e511c8b946
> > --- /dev/null
> > +++ b/include/ui/pixman-compat.h
> > @@ -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 */
> > diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
> > index c5a0911cc7..9c693df8dd 100644
> > --- a/include/ui/qemu-pixman.h
> > +++ b/include/ui/qemu-pixman.h
> > @@ -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,
> > --
> > 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 :|
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 54/67] ui/vc: console-vc requires PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (52 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 53/67] ui: add pixman-compat.h marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-01 17:28 ` Daniel P. Berrangé
2023-08-30 9:38 ` [PATCH 55/67] qmp/hmp: disable screendump if PIXMAN is missing marcandre.lureau
` (13 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Add stubs for the fallback paths.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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
diff --git a/ui/console-vc-stubs.c b/ui/console-vc-stubs.c
new file mode 100644
index 0000000000..76ea880d27
--- /dev/null
+++ b/ui/console-vc-stubs.c
@@ -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);
+ }
+}
diff --git a/ui/meson.build b/ui/meson.build
index 0a1e8272a3..3085e10a72 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -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
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 54/67] ui/vc: console-vc requires PIXMAN
2023-08-30 9:38 ` [PATCH 54/67] ui/vc: console-vc requires PIXMAN marcandre.lureau
@ 2023-09-01 17:28 ` Daniel P. Berrangé
2023-09-04 13:41 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-01 17:28 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann
On Wed, Aug 30, 2023 at 01:38:28PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Add stubs for the fallback paths.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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
>
> diff --git a/ui/console-vc-stubs.c b/ui/console-vc-stubs.c
> new file mode 100644
> index 0000000000..76ea880d27
> --- /dev/null
> +++ b/ui/console-vc-stubs.c
> @@ -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);
> +}
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.
> +
> +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);
> + }
> +}
> diff --git a/ui/meson.build b/ui/meson.build
> index 0a1e8272a3..3085e10a72 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -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
> --
> 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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 54/67] ui/vc: console-vc requires PIXMAN
2023-09-01 17:28 ` Daniel P. Berrangé
@ 2023-09-04 13:41 ` Marc-André Lureau
2023-09-04 13:44 ` Daniel P. Berrangé
0 siblings, 1 reply; 157+ messages in thread
From: Marc-André Lureau @ 2023-09-04 13:41 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel, Gerd Hoffmann
Hi
On Fri, Sep 1, 2023 at 9:28 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 01:38:28PM +0400, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Add stubs for the fallback paths.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > 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
> >
> > diff --git a/ui/console-vc-stubs.c b/ui/console-vc-stubs.c
> > new file mode 100644
> > index 0000000000..76ea880d27
> > --- /dev/null
> > +++ b/ui/console-vc-stubs.c
> > @@ -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);
> > +}
>
> 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)
>
> > +
> > +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);
> > + }
> > +}
> > diff --git a/ui/meson.build b/ui/meson.build
> > index 0a1e8272a3..3085e10a72 100644
> > --- a/ui/meson.build
> > +++ b/ui/meson.build
> > @@ -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
> > --
> > 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 :|
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 54/67] ui/vc: console-vc requires PIXMAN
2023-09-04 13:41 ` Marc-André Lureau
@ 2023-09-04 13:44 ` Daniel P. Berrangé
0 siblings, 0 replies; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-09-04 13:44 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Gerd Hoffmann
On Mon, Sep 04, 2023 at 05:41:23PM +0400, Marc-André Lureau wrote:
> Hi
>
> On Fri, Sep 1, 2023 at 9:28 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Wed, Aug 30, 2023 at 01:38:28PM +0400, marcandre.lureau@redhat.com wrote:
> > > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > > Add stubs for the fallback paths.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > > 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
> > >
> > > diff --git a/ui/console-vc-stubs.c b/ui/console-vc-stubs.c
> > > new file mode 100644
> > > index 0000000000..76ea880d27
> > > --- /dev/null
> > > +++ b/ui/console-vc-stubs.c
> > > @@ -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);
> > > +}
> >
> > 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).
Yeah, probably best to just use 'null' of 'vc' for that scenario,
since the stub is effectively 'null' anyway.
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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 55/67] qmp/hmp: disable screendump if PIXMAN is missing
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (53 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 54/67] ui/vc: console-vc requires PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:18 ` Philippe Mathieu-Daudé
2023-08-30 9:38 ` [PATCH 56/67] virtio-gpu: replace PIXMAN for region/rect test marcandre.lureau
` (12 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Dr. David Alan Gilbert,
Eric Blake, Markus Armbruster
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The command requires color conversion and line-by-line feeding. We could
have a simple fallback for simple formats though.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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(-)
diff --git a/qapi/ui.json b/qapi/ui.json
index 006616aa77..e74cc3efb6 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -200,7 +200,8 @@
{ 'command': 'screendump',
'data': {'filename': 'str', '*device': 'str', '*head': 'int',
'*format': 'ImageFormat'},
- 'coroutine': true }
+ 'coroutine': true,
+ 'if': 'CONFIG_PIXMAN' }
##
# == Spice
diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c
index c671389473..26c8ced1f2 100644
--- a/ui/ui-hmp-cmds.c
+++ b/ui/ui-hmp-cmds.c
@@ -437,6 +437,7 @@ void sendkey_completion(ReadLineState *rs, int nb_args, const char *str)
}
}
+#ifdef CONFIG_PIXMAN
void coroutine_fn
hmp_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)
{
diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c
index debc07d678..d772e1cb7f 100644
--- a/ui/ui-qmp-cmds.c
+++ b/ui/ui-qmp-cmds.c
@@ -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 */
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 2cbd0f77a0..bfb2e2d5e2 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -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",
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 55/67] qmp/hmp: disable screendump if PIXMAN is missing
2023-08-30 9:38 ` [PATCH 55/67] qmp/hmp: disable screendump if PIXMAN is missing marcandre.lureau
@ 2023-08-30 15:18 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:18 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
Cc: Gerd Hoffmann, Dr. David Alan Gilbert, Eric Blake,
Markus Armbruster
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The command requires color conversion and line-by-line feeding. We could
> have a simple fallback for simple formats though.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 56/67] virtio-gpu: replace PIXMAN for region/rect test
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (54 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 55/67] qmp/hmp: disable screendump if PIXMAN is missing marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 57/67] ui/console: when PIXMAN is unavailable, don't draw placeholder msg marcandre.lureau
` (11 subsequent siblings)
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau, Michael S. Tsirkin
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Use a simpler implementation for rectangle geometry & intersect, drop
the need for (more complex) PIXMAN functions.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
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
diff --git a/include/ui/rect.h b/include/ui/rect.h
new file mode 100644
index 0000000000..63edf7a39d
--- /dev/null
+++ b/include/ui/rect.h
@@ -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
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index bbd5c6561a..e77187a610 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -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)
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 57/67] ui/console: when PIXMAN is unavailable, don't draw placeholder msg
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (55 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 56/67] virtio-gpu: replace PIXMAN for region/rect test marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 58/67] vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN marcandre.lureau
` (10 subsequent siblings)
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ui/console.c b/ui/console.c
index da341f08da..c4cd70318e 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -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;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 58/67] vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (56 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 57/67] ui/console: when PIXMAN is unavailable, don't draw placeholder msg marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 59/67] ui/gl: opengl doesn't require PIXMAN marcandre.lureau
` (9 subsequent siblings)
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau, Michael S. Tsirkin
From: Marc-André Lureau <marcandre.lureau@redhat.com>
This simply means that 2d drawing updates won't be handled, but 3d
should work.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/display/vhost-user-gpu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
index e8ee03094e..f57c893970 100644
--- a/hw/display/vhost-user-gpu.c
+++ b/hw/display/vhost-user-gpu.c
@@ -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);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 59/67] ui/gl: opengl doesn't require PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (57 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 58/67] vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 60/67] ui/vnc: VNC requires PIXMAN marcandre.lureau
` (8 subsequent siblings)
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The QEMU fallback covers the requirements. We still need the flags of
header inclusion with CONFIG_PIXMAN.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/meson.build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/meson.build b/ui/meson.build
index 3085e10a72..7c99613950 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -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
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 60/67] ui/vnc: VNC requires PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (58 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 59/67] ui/gl: opengl doesn't require PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-09-04 14:01 ` Paolo Bonzini
2023-08-30 9:38 ` [PATCH 61/67] ui/spice: SPICE/QXL " marcandre.lureau
` (7 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé, Thomas Huth, Philippe Mathieu-Daudé
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
meson.build | 5 ++++-
ui/meson.build | 4 ++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index 3bd7046099..ceafbc5b73 100644
--- a/meson.build
+++ b/meson.build
@@ -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')
diff --git a/ui/meson.build b/ui/meson.build
index 7c99613950..b3525ef064 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -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 = {}
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 60/67] ui/vnc: VNC requires PIXMAN
2023-08-30 9:38 ` [PATCH 60/67] ui/vnc: VNC requires PIXMAN marcandre.lureau
@ 2023-09-04 14:01 ` Paolo Bonzini
0 siblings, 0 replies; 157+ messages in thread
From: Paolo Bonzini @ 2023-09-04 14:01 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
Cc: Gerd Hoffmann, Daniel P. Berrangé, Thomas Huth,
Philippe Mathieu-Daudé
On 8/30/23 11:38, marcandre.lureau@redhat.com wrote:
> -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
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 61/67] ui/spice: SPICE/QXL requires PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (59 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 60/67] ui/vnc: VNC requires PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:21 ` Philippe Mathieu-Daudé
2023-09-04 14:03 ` Paolo Bonzini
2023-08-30 9:38 ` [PATCH 62/67] ui/gtk: -display gtk " marcandre.lureau
` (6 subsequent siblings)
67 siblings, 2 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/display/Kconfig | 2 +-
ui/meson.build | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/hw/display/Kconfig b/hw/display/Kconfig
index 7b3da68d1c..4d8b0cec40 100644
--- a/hw/display/Kconfig
+++ b/hw/display/Kconfig
@@ -93,7 +93,7 @@ config VGA
config QXL
bool
- depends on SPICE && PCI
+ depends on SPICE && PCI && PIXMAN
select VGA
config VIRTIO_GPU
diff --git a/ui/meson.build b/ui/meson.build
index b3525ef064..08d845d43a 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -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 = [
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 61/67] ui/spice: SPICE/QXL requires PIXMAN
2023-08-30 9:38 ` [PATCH 61/67] ui/spice: SPICE/QXL " marcandre.lureau
@ 2023-08-30 15:21 ` Philippe Mathieu-Daudé
2023-09-04 14:42 ` Paolo Bonzini
2023-09-04 14:03 ` Paolo Bonzini
1 sibling, 1 reply; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:21 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann, Paolo Bonzini
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/display/Kconfig | 2 +-
> ui/meson.build | 12 ++++++------
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/hw/display/Kconfig b/hw/display/Kconfig
> index 7b3da68d1c..4d8b0cec40 100644
> --- a/hw/display/Kconfig
> +++ b/hw/display/Kconfig
> @@ -93,7 +93,7 @@ config VGA
>
> config QXL
> bool
> - depends on SPICE && PCI
> + depends on SPICE && PCI && PIXMAN
Shouldn't this be:
--- a/Kconfig.host
+++ b/Kconfig.host
@@ -14,4 +14,5 @@ config X11
config SPICE
bool
+ depends on PIXMAN
---
?
>
> config VIRTIO_GPU
> diff --git a/ui/meson.build b/ui/meson.build
> index b3525ef064..08d845d43a 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -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 = [
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 61/67] ui/spice: SPICE/QXL requires PIXMAN
2023-08-30 15:21 ` Philippe Mathieu-Daudé
@ 2023-09-04 14:42 ` Paolo Bonzini
0 siblings, 0 replies; 157+ messages in thread
From: Paolo Bonzini @ 2023-09-04 14:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Marc-André Lureau, qemu-devel, Gerd Hoffmann
[-- Attachment #1: Type: text/plain, Size: 2086 bytes --]
Il mer 30 ago 2023, 17:21 Philippe Mathieu-Daudé <philmd@linaro.org> ha
scritto:
> On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > hw/display/Kconfig | 2 +-
> > ui/meson.build | 12 ++++++------
> > 2 files changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/hw/display/Kconfig b/hw/display/Kconfig
> > index 7b3da68d1c..4d8b0cec40 100644
> > --- a/hw/display/Kconfig
> > +++ b/hw/display/Kconfig
> > @@ -93,7 +93,7 @@ config VGA
> >
> > config QXL
> > bool
> > - depends on SPICE && PCI
> > + depends on SPICE && PCI && PIXMAN
>
> Shouldn't this be:
>
> --- a/Kconfig.host
> +++ b/Kconfig.host
> @@ -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
> ---
>
> ?
>
> >
> > config VIRTIO_GPU
> > diff --git a/ui/meson.build b/ui/meson.build
> > index b3525ef064..08d845d43a 100644
> > --- a/ui/meson.build
> > +++ b/ui/meson.build
> > @@ -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 = [
>
>
[-- Attachment #2: Type: text/html, Size: 3371 bytes --]
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 61/67] ui/spice: SPICE/QXL requires PIXMAN
2023-08-30 9:38 ` [PATCH 61/67] ui/spice: SPICE/QXL " marcandre.lureau
2023-08-30 15:21 ` Philippe Mathieu-Daudé
@ 2023-09-04 14:03 ` Paolo Bonzini
1 sibling, 0 replies; 157+ messages in thread
From: Paolo Bonzini @ 2023-09-04 14:03 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann
On 8/30/23 11:38, marcandre.lureau@redhat.com wrote:
> diff --git a/ui/meson.build b/ui/meson.build
> index b3525ef064..08d845d43a 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -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
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 62/67] ui/gtk: -display gtk requires PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (60 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 61/67] ui/spice: SPICE/QXL " marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 63/67] ui/dbus: do not require PIXMAN marcandre.lureau
` (5 subsequent siblings)
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/meson.build b/ui/meson.build
index 08d845d43a..40dff7b3e0 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -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()
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 63/67] ui/dbus: do not require PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (61 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 62/67] ui/gtk: -display gtk " marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 64/67] arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN marcandre.lureau
` (4 subsequent siblings)
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Implement a fallback path for region 2D update.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/dbus-listener.c | 62 ++++++++++++++++++++++++++++++----------------
ui/meson.build | 2 +-
2 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c
index 30917271ab..f773c40685 100644
--- a/ui/dbus-listener.c
+++ b/ui/dbus-listener.c
@@ -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
diff --git a/ui/meson.build b/ui/meson.build
index 40dff7b3e0..dec2d471cc 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -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',
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 64/67] arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (62 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 63/67] ui/dbus: do not require PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:25 ` Philippe Mathieu-Daudé
2023-08-30 9:38 ` [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN marcandre.lureau
` (3 subsequent siblings)
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini,
Peter Maydell, open list:ARM TCG CPUs
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The Display Port has some strong PIXMAN dependency.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/arm/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 7e68348440..7ea956b286 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -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
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 64/67] arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN
2023-08-30 9:38 ` [PATCH 64/67] arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN marcandre.lureau
@ 2023-08-30 15:25 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:25 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
Cc: Gerd Hoffmann, Paolo Bonzini, Peter Maydell,
open list:ARM TCG CPUs
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The Display Port has some strong PIXMAN dependency.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/arm/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 7e68348440..7ea956b286 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -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.
> select AHCI
> select ARM_GIC
> select CADENCE
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (63 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 64/67] arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 12:34 ` BALATON Zoltan
2023-09-04 14:05 ` Paolo Bonzini
2023-08-30 9:38 ` [PATCH 66/67] sh4/kconfig: make R2D depend on SH4 " marcandre.lureau
` (2 subsequent siblings)
67 siblings, 2 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini
From: Marc-André Lureau <marcandre.lureau@redhat.com>
SM501 is going to depend on PIXMAN next.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
configs/devices/ppc-softmmu/default.mak | 2 +-
hw/ppc/Kconfig | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configs/devices/ppc-softmmu/default.mak b/configs/devices/ppc-softmmu/default.mak
index a887f5438b..603ed701ed 100644
--- a/configs/devices/ppc-softmmu/default.mak
+++ b/configs/devices/ppc-softmmu/default.mak
@@ -8,7 +8,7 @@ CONFIG_PPC440=y
CONFIG_VIRTEX=y
# For Sam460ex
-CONFIG_SAM460EX=y
+#CONFIG_SAM460EX=n
# For Macs
CONFIG_MAC_OLDWORLD=y
diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
index 5dfbf47ef5..86d3f5cfca 100644
--- a/hw/ppc/Kconfig
+++ b/hw/ppc/Kconfig
@@ -58,6 +58,8 @@ config PPC4XX
config SAM460EX
bool
+ default y
+ depends on PPC && PIXMAN
select PFLASH_CFI01
select IDE_SII3112
select M41T80
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
2023-08-30 9:38 ` [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN marcandre.lureau
@ 2023-08-30 12:34 ` BALATON Zoltan
2023-09-04 16:24 ` Paolo Bonzini
2023-09-05 20:07 ` Marc-André Lureau
2023-09-04 14:05 ` Paolo Bonzini
1 sibling, 2 replies; 157+ messages in thread
From: BALATON Zoltan @ 2023-08-30 12:34 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Gerd Hoffmann, Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 1430 bytes --]
On Wed, 30 Aug 2023, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> configs/devices/ppc-softmmu/default.mak | 2 +-
> hw/ppc/Kconfig | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/configs/devices/ppc-softmmu/default.mak b/configs/devices/ppc-softmmu/default.mak
> index a887f5438b..603ed701ed 100644
> --- a/configs/devices/ppc-softmmu/default.mak
> +++ b/configs/devices/ppc-softmmu/default.mak
> @@ -8,7 +8,7 @@ CONFIG_PPC440=y
> CONFIG_VIRTEX=y
>
> # For Sam460ex
> -CONFIG_SAM460EX=y
> +#CONFIG_SAM460EX=n
>
> # For Macs
> CONFIG_MAC_OLDWORLD=y
> diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
> index 5dfbf47ef5..86d3f5cfca 100644
> --- a/hw/ppc/Kconfig
> +++ b/hw/ppc/Kconfig
> @@ -58,6 +58,8 @@ config PPC4XX
>
> config SAM460EX
> bool
> + default y
> + depends on PPC && PIXMAN
> select PFLASH_CFI01
> select IDE_SII3112
> select M41T80
>
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
2023-08-30 12:34 ` BALATON Zoltan
@ 2023-09-04 16:24 ` Paolo Bonzini
2023-09-05 20:07 ` Marc-André Lureau
1 sibling, 0 replies; 157+ messages in thread
From: Paolo Bonzini @ 2023-09-04 16:24 UTC (permalink / raw)
To: BALATON Zoltan, Marc-André Lureau; +Cc: qemu-devel, Gerd Hoffmann
On 8/30/23 14:34, BALATON Zoltan wrote:
>
>> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>>
>> 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 && PIXMAN
fails to compile without pixman, due to a contradiction (default.mak
requires enabling SAM460EX, hw/ppc/Kconfig requires disabling it because
CONFIG_PIXMAN=n).
> 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
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
2023-08-30 12:34 ` BALATON Zoltan
2023-09-04 16:24 ` Paolo Bonzini
@ 2023-09-05 20:07 ` Marc-André Lureau
2023-09-06 11:00 ` Paolo Bonzini
1 sibling, 1 reply; 157+ messages in thread
From: Marc-André Lureau @ 2023-09-05 20:07 UTC (permalink / raw)
To: BALATON Zoltan; +Cc: qemu-devel, Gerd Hoffmann, Paolo Bonzini
Hi
On Wed, Aug 30, 2023 at 4:35 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:
>
> On Wed, 30 Aug 2023, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > 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)
> 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'))
> The sm501 already
> has fallback when pixman fails so could work without pixman too, see
> x-pixman property in sm501.c.
Correct, I have changed it to conditionally compile x-pixman related code.
thanks
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
2023-09-05 20:07 ` Marc-André Lureau
@ 2023-09-06 11:00 ` Paolo Bonzini
0 siblings, 0 replies; 157+ messages in thread
From: Paolo Bonzini @ 2023-09-06 11:00 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: BALATON Zoltan, qemu-devel, Gerd Hoffmann
On Tue, Sep 5, 2023 at 10:07 PM Marc-André Lureau
<marcandre.lureau@gmail.com> wrote:
> 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'))
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
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN
2023-08-30 9:38 ` [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN marcandre.lureau
2023-08-30 12:34 ` BALATON Zoltan
@ 2023-09-04 14:05 ` Paolo Bonzini
1 sibling, 0 replies; 157+ messages in thread
From: Paolo Bonzini @ 2023-09-04 14:05 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann
On 8/30/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau<marcandre.lureau@redhat.com>
>
> SM501 is going to depend on PIXMAN next.
>
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
> configs/devices/ppc-softmmu/default.mak | 2 +-
> hw/ppc/Kconfig | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/configs/devices/ppc-softmmu/default.mak b/configs/devices/ppc-softmmu/default.mak
> index a887f5438b..603ed701ed 100644
> --- a/configs/devices/ppc-softmmu/default.mak
> +++ b/configs/devices/ppc-softmmu/default.mak
> @@ -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
^ permalink raw reply [flat|nested] 157+ messages in thread
* [PATCH 66/67] sh4/kconfig: make R2D depend on SH4 & PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (64 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 65/67] ppc/kconfig: make SAM460EX depend on PPC & PIXMAN marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 9:38 ` [PATCH 67/67] display/kconfig: make SM501 depend on PIXMAN marcandre.lureau
2023-08-30 10:52 ` [PATCH 00/67] Make pixman an optional dependency Thomas Huth
67 siblings, 0 replies; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini,
Yoshinori Sato
From: Marc-André Lureau <marcandre.lureau@redhat.com>
SM501 is going to depend on PIXMAN next.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
configs/devices/sh4-softmmu/default.mak | 2 +-
hw/sh4/Kconfig | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configs/devices/sh4-softmmu/default.mak b/configs/devices/sh4-softmmu/default.mak
index 565e8b0b5d..5a78b83044 100644
--- a/configs/devices/sh4-softmmu/default.mak
+++ b/configs/devices/sh4-softmmu/default.mak
@@ -7,5 +7,5 @@
# Boards:
#
-CONFIG_R2D=y
+#CONFIG_R2D=n
CONFIG_SHIX=y
diff --git a/hw/sh4/Kconfig b/hw/sh4/Kconfig
index ab733a3f76..aa2dff348d 100644
--- a/hw/sh4/Kconfig
+++ b/hw/sh4/Kconfig
@@ -1,5 +1,7 @@
config R2D
bool
+ default y
+ depends on SH4 && PIXMAN
imply PCI_DEVICES
imply TEST_DEVICES
imply RTL8139_PCI
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* [PATCH 67/67] display/kconfig: make SM501 depend on PIXMAN
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (65 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 66/67] sh4/kconfig: make R2D depend on SH4 " marcandre.lureau
@ 2023-08-30 9:38 ` marcandre.lureau
2023-08-30 15:27 ` Philippe Mathieu-Daudé
2023-08-30 10:52 ` [PATCH 00/67] Make pixman an optional dependency Thomas Huth
67 siblings, 1 reply; 157+ messages in thread
From: marcandre.lureau @ 2023-08-30 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Marc-André Lureau, Paolo Bonzini
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/display/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/display/Kconfig b/hw/display/Kconfig
index 4d8b0cec40..e8077c16d8 100644
--- a/hw/display/Kconfig
+++ b/hw/display/Kconfig
@@ -74,6 +74,7 @@ config FRAMEBUFFER
config SM501
bool
+ depends on PIXMAN
select I2C
select DDC
select SERIAL
--
2.41.0
^ permalink raw reply related [flat|nested] 157+ messages in thread
* Re: [PATCH 67/67] display/kconfig: make SM501 depend on PIXMAN
2023-08-30 9:38 ` [PATCH 67/67] display/kconfig: make SM501 depend on PIXMAN marcandre.lureau
@ 2023-08-30 15:27 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 157+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-30 15:27 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann, Paolo Bonzini
On 30/8/23 11:38, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/display/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/display/Kconfig b/hw/display/Kconfig
> index 4d8b0cec40..e8077c16d8 100644
> --- a/hw/display/Kconfig
> +++ b/hw/display/Kconfig
> @@ -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.
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 00/67] Make pixman an optional dependency
2023-08-30 9:37 [PATCH 00/67] Make pixman an optional dependency marcandre.lureau
` (66 preceding siblings ...)
2023-08-30 9:38 ` [PATCH 67/67] display/kconfig: make SM501 depend on PIXMAN marcandre.lureau
@ 2023-08-30 10:52 ` Thomas Huth
2023-08-30 11:01 ` Marc-André Lureau
67 siblings, 1 reply; 157+ messages in thread
From: Thomas Huth @ 2023-08-30 10:52 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Gerd Hoffmann, Peter Maydell
On 30/08/2023 11.37, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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:
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
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 00/67] Make pixman an optional dependency
2023-08-30 10:52 ` [PATCH 00/67] Make pixman an optional dependency Thomas Huth
@ 2023-08-30 11:01 ` Marc-André Lureau
2023-08-30 11:21 ` Daniel P. Berrangé
0 siblings, 1 reply; 157+ messages in thread
From: Marc-André Lureau @ 2023-08-30 11:01 UTC (permalink / raw)
To: Thomas Huth; +Cc: qemu-devel, Gerd Hoffmann, Peter Maydell
Hi
On Wed, Aug 30, 2023 at 2:53 PM Thomas Huth <thuth@redhat.com> wrote:
>
> On 30/08/2023 11.37, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > 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:
>
> 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
> 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.
> 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.
> 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.
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 00/67] Make pixman an optional dependency
2023-08-30 11:01 ` Marc-André Lureau
@ 2023-08-30 11:21 ` Daniel P. Berrangé
2023-08-30 11:32 ` Marc-André Lureau
0 siblings, 1 reply; 157+ messages in thread
From: Daniel P. Berrangé @ 2023-08-30 11:21 UTC (permalink / raw)
To: Marc-André Lureau
Cc: Thomas Huth, qemu-devel, Gerd Hoffmann, Peter Maydell
On Wed, Aug 30, 2023 at 03:01:27PM +0400, Marc-André Lureau wrote:
> Hi
>
> On Wed, Aug 30, 2023 at 2:53 PM Thomas Huth <thuth@redhat.com> wrote:
> >
> > On 30/08/2023 11.37, marcandre.lureau@redhat.com wrote:
> > > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > > 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:
> >
> > 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
>
> > 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.
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.
> > 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.
> > 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
--
|: 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 :|
^ permalink raw reply [flat|nested] 157+ messages in thread
* Re: [PATCH 00/67] Make pixman an optional dependency
2023-08-30 11:21 ` Daniel P. Berrangé
@ 2023-08-30 11:32 ` Marc-André Lureau
0 siblings, 0 replies; 157+ messages in thread
From: Marc-André Lureau @ 2023-08-30 11:32 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: Thomas Huth, qemu-devel, Gerd Hoffmann, Peter Maydell
Hi
On Wed, Aug 30, 2023 at 3:21 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Aug 30, 2023 at 03:01:27PM +0400, Marc-André Lureau wrote:
> > Hi
> >
> > On Wed, Aug 30, 2023 at 2:53 PM Thomas Huth <thuth@redhat.com> wrote:
> > >
> > > On 30/08/2023 11.37, marcandre.lureau@redhat.com wrote:
> > > > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > >
> > > > 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:
> > >
> > > 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
> >
> > > 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.
>
> 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.
>
> > > 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.
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.
^ permalink raw reply [flat|nested] 157+ messages in thread