Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ki9hJ-0002kk-1Y for qemu-devel@nongnu.org; Tue, 23 Sep 2008 11:21:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ki9hH-0002kY-GR for qemu-devel@nongnu.org; Tue, 23 Sep 2008 11:21:03 -0400 Received: from [199.232.76.173] (port=34609 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ki9hH-0002kV-Ab for qemu-devel@nongnu.org; Tue, 23 Sep 2008 11:21:03 -0400 Received: from mail.gondor.com ([212.117.64.182]:3606 helo=moria.gondor.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ki9hG-0005ZY-SC for qemu-devel@nongnu.org; Tue, 23 Sep 2008 11:21:03 -0400 Date: Tue, 23 Sep 2008 17:20:58 +0200 From: Jan Niehusmann Message-ID: <20080923152058.GA27742@jannic.reliablesolutions.de> References: <20080922171558.GA11353@x61s.gondor.com> <48D7DF10.4030004@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH] Wrapper around dpy_copy to fix segfault with -vnc option Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: andrzej zaborowski Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org On Mon, Sep 22, 2008 at 11:15:04PM +0200, andrzej zaborowski wrote: > Yes, I don't think hw/ code should be concerned with what console is > active. Logically the dpy_ functions should take the pointer returned > from graphic_console_init() as first parameter. > > Please also check the code is formatted consistently with qemu. > > I didn't receive Jan's message but the check seems to not be enough > because there can be multiple graphical consoles with different sizes > - if I'm guessing correctly what this patch tries to fix. Based on these comments I had another look at the code. If there can be multiple graphical consoles, the only sensible test is 'console == active_console' where console must be provided by the caller. So, indeed, a pointer to the console must be provided instead of a pointer to the DisplayState. To make function names consistent, I called the function qemu_console_copy in analogy to qemu_console_resize (which is a similar wrapper around dpy_resize). Signed-off-by: Jan Niehusmann diff --git a/qemu/console.c b/qemu/console.c index 785710a..1f4907c 100644 --- a/qemu/console.c +++ b/qemu/console.c @@ -1343,3 +1343,10 @@ void qemu_console_resize(QEMUConsole *console, int width, int height) } } } + +void qemu_console_copy(QEMUConsole *console, int src_x, int src_y, int dst_x, int dst_y, int w, int h) { + if ( active_console == console && console->ds->dpy_copy ) { + console->ds->dpy_copy(console->ds, src_x, src_y, dst_x, dst_y, w, h); + } +} + diff --git a/qemu/console.h b/qemu/console.h index 7b8571f..05e7e64 100644 --- a/qemu/console.h +++ b/qemu/console.h @@ -140,6 +140,7 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p); void console_select(unsigned int index); void console_color_init(DisplayState *ds); void qemu_console_resize(QEMUConsole *console, int width, int height); +void qemu_console_copy(QEMUConsole *console, int src_x, int src_y, int dst_x, int dst_y, int w, int h); /* sdl.c */ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame); diff --git a/qemu/hw/cirrus_vga.c b/qemu/hw/cirrus_vga.c index 0cf5b24..4f3aef9 100644 --- a/qemu/hw/cirrus_vga.c +++ b/qemu/hw/cirrus_vga.c @@ -775,13 +775,13 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h) s->cirrus_blt_width, s->cirrus_blt_height); if (notify) - s->ds->dpy_copy(s->ds, - sx, sy, dx, dy, - s->cirrus_blt_width / depth, - s->cirrus_blt_height); + qemu_console_copy(s->console, + sx, sy, dx, dy, + s->cirrus_blt_width / depth, + s->cirrus_blt_height); /* we don't have to notify the display that this portion has - changed since dpy_copy implies this */ + changed since qemu_console_copy implies this */ if (!notify) cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, diff --git a/qemu/hw/vmware_vga.c b/qemu/hw/vmware_vga.c index efbcd96..625cd83 100644 --- a/qemu/hw/vmware_vga.c +++ b/qemu/hw/vmware_vga.c @@ -384,7 +384,7 @@ static inline void vmsvga_copy_rect(struct vmsvga_state_s *s, # ifdef DIRECT_VRAM if (s->ds->dpy_copy) - s->ds->dpy_copy(s->ds, x0, y0, x1, y1, w, h); + qemu_console_copy(s->console, x0, y0, x1, y1, w, h); else # endif {