From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KKDXt-0002xK-Db for qemu-devel@nongnu.org; Sat, 19 Jul 2008 10:36:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KKDXp-0002s6-SK for qemu-devel@nongnu.org; Sat, 19 Jul 2008 10:36:25 -0400 Received: from [199.232.76.173] (port=49145 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KKDXp-0002rg-EZ for qemu-devel@nongnu.org; Sat, 19 Jul 2008 10:36:21 -0400 Received: from an-out-0708.google.com ([209.85.132.246]:24287) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KKDXp-00034r-8F for qemu-devel@nongnu.org; Sat, 19 Jul 2008 10:36:21 -0400 Received: by an-out-0708.google.com with SMTP id d18so453759and.130 for ; Sat, 19 Jul 2008 07:36:20 -0700 (PDT) Message-ID: Date: Sat, 19 Jul 2008 16:36:20 +0200 From: "andrzej zaborowski" Subject: Re: [Qemu-devel] [PATCH 6/6] kvm: qemu: fix vga screendump In-Reply-To: <1216329580-20804-6-git-send-email-aliguori@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1216329580-20804-1-git-send-email-aliguori@us.ibm.com> <1216329580-20804-6-git-send-email-aliguori@us.ibm.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 2008/7/17 Anthony Liguori : > From: Avi Kivity > Commit 737d2050 ("Implement resolution switching in common console code") > uses qemu_console_resize() instead of dpy_resize(). This means console->ds > is examined instead of the VGA private ds, and the resize does not take place, > leading to a segfault. > > Fix by modifying the DisplayState directly rather than swapping the pointer. The screen dumping is hacky but maybe it's a good idea to keep the hacks local to hw/vga.c, with something like the following diff. I think we need to fix the screen dumping globally (some graphic cards will need fixing too). diff --git a/console.c b/console.c index 1c94980..bc0c349 100644 --- a/console.c +++ b/console.c @@ -1334,8 +1334,7 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p) void qemu_console_resize(QEMUConsole *console, int width, int height) { - if (console->g_width != width || console->g_height != height - || !console->ds->data) { + if (console->g_width != width || console->g_height != height) { console->g_width = width; console->g_height = height; if (active_console == console) { diff --git a/hw/vga.c b/hw/vga.c index 5a3203c..5c66209 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -2228,8 +2228,6 @@ int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, /********************************************************/ /* vga screen dump */ -static int vga_save_w, vga_save_h; - static void vga_save_dpy_update(DisplayState *s, int x, int y, int w, int h) { @@ -2237,10 +2235,14 @@ static void vga_save_dpy_update(DisplayState *s, static void vga_save_dpy_resize(DisplayState *s, int w, int h) { +} + +static void vga_save_dpy_alloc(DisplayState *s, int w, int h) +{ s->linesize = w * 4; s->data = qemu_malloc(h * s->linesize); - vga_save_w = w; - vga_save_h = h; + s->width = w; + s->height = h; } static void vga_save_dpy_refresh(DisplayState *s) @@ -2281,26 +2283,27 @@ int ppm_save(const char *filename, uint8_t *data, static void vga_screen_dump(void *opaque, const char *filename) { VGAState *s = (VGAState *)opaque; - DisplayState *saved_ds, ds1, *ds = &ds1; + DisplayState saved_ds, *ds = s->ds; /* XXX: this is a little hackish */ - vga_invalidate_display(s); - saved_ds = s->ds; + saved_ds = *s->ds; memset(ds, 0, sizeof(DisplayState)); ds->dpy_update = vga_save_dpy_update; ds->dpy_resize = vga_save_dpy_resize; ds->dpy_refresh = vga_save_dpy_refresh; ds->depth = 32; + qemu_console_resize(s->console, -1, -1); - s->ds = ds; s->graphic_mode = -1; + ds->dpy_resize = vga_save_dpy_alloc; + vga_invalidate_display(s); vga_update_display(s); if (ds->data) { - ppm_save(filename, ds->data, vga_save_w, vga_save_h, - s->ds->linesize); + ppm_save(filename, ds->data, ds->width, ds->height, ds->linesize); + qemu_free(ds->data); } - s->ds = saved_ds; + *s->ds = saved_ds; }