Something like this, please comment, not ready to submit.
From: Alexandru DAMIAN <alexandru.dam...@intel.com> Date: Wed, 3 Apr 2013 13:43:31 +0300 Subject: [PATCH] qemu console: Add depth preservation on allocation Since there are multiple bit depths supported for consoles, we must preserve the depth when creating new consoles for resizing, etc. Signed-off-by: Alexandru DAMIAN <alexandru.dam...@intel.com> --- hw/vga.c | 6 +++--- hw/vmware_vga.c | 2 +- include/ui/console.h | 4 ++-- ui/console.c | 17 ++++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index f9292ed..204efa0 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -1324,7 +1324,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cw != s->last_cw || cheight != s->last_ch || s->last_depth) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; - qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); + qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height, s->last_depth); surface = qemu_console_surface(s->con); dpy_text_resize(s->con, width, height); s->last_depth = 0; @@ -1677,7 +1677,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) s->vram_ptr + (s->start_addr * 4), byteswap); dpy_gfx_replace_surface(s->con, surface); } else { - qemu_console_resize(s->con, disp_width, height); + qemu_console_resize(s->con, disp_width, height, depth); surface = qemu_console_surface(s->con); } s->last_scr_width = disp_width; @@ -2049,7 +2049,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata) cw != s->last_cw || cheight != s->last_ch) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; - qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); + qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height, s->last_depth); dpy_text_resize(s->con, width, height); s->last_depth = 0; s->last_width = width; diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index 75ef404..85696e1 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -985,7 +985,7 @@ static inline void vmsvga_check_size(struct vmsvga_state_s *s) if (s->new_width != surface_width(surface) || s->new_height != surface_height(surface)) { - qemu_console_resize(s->vga.con, s->new_width, s->new_height); + qemu_console_resize(s->vga.con, s->new_width, s->new_height, surface_bits_per_pixel(surface)); s->invalidated = 1; } } diff --git a/include/ui/console.h b/include/ui/console.h index a234c72..868c068 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -201,7 +201,7 @@ DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp, PixelFormat qemu_different_endianness_pixelformat(int bpp); PixelFormat qemu_default_pixelformat(int bpp); -DisplaySurface *qemu_create_displaysurface(int width, int height); +DisplaySurface *qemu_create_displaysurface(int width, int height, int depth); void qemu_free_displaysurface(DisplaySurface *surface); static inline int is_surface_bgr(DisplaySurface *surface) @@ -302,7 +302,7 @@ int is_fixedsize_console(void); void text_consoles_set_display(DisplayState *ds); void console_select(unsigned int index); void console_color_init(DisplayState *ds); -void qemu_console_resize(QemuConsole *con, int width, int height); +void qemu_console_resize(QemuConsole *con, int width, int height, int depth); void qemu_console_copy(QemuConsole *con, int src_x, int src_y, int dst_x, int dst_y, int w, int h); DisplaySurface *qemu_console_surface(QemuConsole *con); diff --git a/ui/console.c b/ui/console.c index e84ba8b..cc35cad 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1059,7 +1059,7 @@ void console_select(unsigned int index) } active_console = s; if (ds->have_gfx) { - surface = qemu_create_displaysurface(s->g_width, s->g_height); + surface = qemu_create_displaysurface(s->g_width, s->g_height, 32); dpy_gfx_replace_surface(s, surface); } if (ds->have_text) { @@ -1266,14 +1266,17 @@ static void qemu_alloc_display(DisplaySurface *surface, int width, int height, #endif } -DisplaySurface *qemu_create_displaysurface(int width, int height) +DisplaySurface *qemu_create_displaysurface(int width, int height, int depth) { DisplaySurface *surface = g_new0(DisplaySurface, 1); int linesize = width * 4; + // when first allocating a display, depth comes through as 0 from s->last_depth + if (depth == 0) depth = 32; + trace_displaysurface_create(surface, width, height); qemu_alloc_display(surface, width, height, linesize, - qemu_default_pixelformat(32), 0); + qemu_default_pixelformat(depth), 0); return surface; } @@ -1472,7 +1475,7 @@ static void dumb_display_init(void) width = active_console->g_width; height = active_console->g_height; } - ds->surface = qemu_create_displaysurface(width, height); + ds->surface = qemu_create_displaysurface(width, height, 32); register_displaystate(ds); } @@ -1515,7 +1518,7 @@ QemuConsole *graphic_console_init(vga_hw_update_ptr update, s->hw_text_update = text_update; s->hw = opaque; - ds->surface = qemu_create_displaysurface(640, 480); + ds->surface = qemu_create_displaysurface(640, 480, 32); register_displaystate(ds); return s; @@ -1668,13 +1671,13 @@ void text_consoles_set_display(DisplayState *ds) } } -void qemu_console_resize(QemuConsole *s, int width, int height) +void qemu_console_resize(QemuConsole *s, int width, int height, int depth) { s->g_width = width; s->g_height = height; if (is_graphic_console()) { DisplaySurface *surface; - surface = qemu_create_displaysurface(width, height); + surface = qemu_create_displaysurface(width, height, depth); dpy_gfx_replace_surface(s, surface); } } -- 1.7.10.4 On Wed, Apr 3, 2013 at 1:13 PM, Damian, Alexandru < alexandru.dam...@intel.com> wrote: > It fixes my test case, that is starting up with 32 bits depth console and > then switching to 16 bits depth - > since the depth is cached, xf64-video-vmware gets 565-weight but 32 bit > depth, and refuses to start. > > There is another similar bug I'm tackling now - when the window resizes, > qemu_console_resize() creates > a new console with a hardcoded 32-bit depth, instead of current depth, > which breaks the display. > > I'm gonna test the live migration too. > > Alex > > > > On Wed, Apr 3, 2013 at 12:49 PM, Gerd Hoffmann <kra...@redhat.com> wrote: > >> On 03/29/13 17:28, Alex DAMIAN wrote: >> > From: Alexandru DAMIAN <alexandru.dam...@intel.com> >> > >> > Do not cache depth and bypp information in the device state. >> > >> > This resolves a bug where Xorg video-vmare driver refuses >> > to start up because the depth value read is the one cached from the >> > device start (default 32 from ui/console.c) and it is not consistent >> > with the graphical console depth, which may be different from >> > the default depth. >> >> Does it actually work? /me posted a simliar patch and according to Jan >> (Cc'ed) it doesn't fix the issue. >> >> > @@ -1113,7 +1111,6 @@ static const VMStateDescription >> vmstate_vmware_vga_internal = { >> > .minimum_version_id_old = 0, >> > .post_load = vmsvga_post_load, >> > .fields = (VMStateField[]) { >> > - VMSTATE_INT32_EQUAL(depth, struct vmsvga_state_s), >> >> This breaks live migration. >> >> cheers, >> Gerd >> >> >> >