From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LOwtN-0005b5-Vd for qemu-devel@nongnu.org; Mon, 19 Jan 2009 11:22:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LOwtM-0005ao-Gp for qemu-devel@nongnu.org; Mon, 19 Jan 2009 11:22:25 -0500 Received: from [199.232.76.173] (port=35810 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOwtM-0005ae-6A for qemu-devel@nongnu.org; Mon, 19 Jan 2009 11:22:24 -0500 Received: from smtp.ctxuk.citrix.com ([62.200.22.115]:41510 helo=SMTP.EU.CITRIX.COM) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LOwtL-0003k1-RR for qemu-devel@nongnu.org; Mon, 19 Jan 2009 11:22:24 -0500 Message-ID: <4974A802.7080506@eu.citrix.com> Date: Mon, 19 Jan 2009 16:19:14 +0000 From: Stefano Stabellini MIME-Version: 1.0 Subject: Re: [PATCH] Adds null check for DisplayStatus (wasRe: [Qemu-devel] [6344] graphical_console_init change (Stefano Stabellini) References: <4973267B.9010901@juno.dti.ne.jp> <49734152.7080302@juno.dti.ne.jp> <49746680.3070400@eu.citrix.com> <49749B91.6080200@juno.dti.ne.jp> <49749CB7.1020508@eu.citrix.com> <4974A593.1020607@codemonkey.ws> In-Reply-To: <4974A593.1020607@codemonkey.ws> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 Anthony Liguori wrote: > Stefano Stabellini wrote: >> Thanks for testing it. >> Anthony, before committing this patch, check out the other equivalent >> patch I sent as I reply to 'add a -vga none cli option'. >> > > Hi Stefan, > > Are you working on a fix for the SEGV when not using -nographic? If I run: > > qemu -hda image.foo -snapshot -vga none > > I get a segv b/c SDL_SetVideoMode() uses ds_get_width/height and > ds->surface == NULL. > Yes, the complete fix is the following, it also solves the other bug that arises when you set -vga none but you do not specify -nographic: diff --git a/vl.c b/vl.c index bfacdcf..b356323 100644 --- a/vl.c +++ b/vl.c @@ -2774,26 +2774,17 @@ DisplayState *get_displaystate(void) } /* dumb display */ - -static void dumb_update(DisplayState *ds, int x, int y, int w, int h) +static void dumb_display_init(void) { -} - -static void dumb_resize(DisplayState *ds) -{ -} + DisplayState *ds; -static void dumb_display_init(DisplayState *ds) -{ - DisplayChangeListener *dcl = qemu_mallocz(sizeof(DisplayChangeListener)); - if (!dcl) + ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState)); + if (ds == NULL) { + fprintf(stderr, "dumb_display_init: DisplayState allocation failed\n"); exit(1); - dcl->dpy_update = dumb_update; - dcl->dpy_resize = dumb_resize; - dcl->dpy_refresh = NULL; - dcl->idle = 1; - dcl->gui_timer_interval = 500; - register_displaychangelistener(ds, dcl); + } + ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4); + register_displaystate(ds); } /***********************************************************/ @@ -5535,6 +5526,8 @@ int main(int argc, char **argv, char **envp) } } + if (!display_state) + dumb_display_init(); /* just use the first displaystate for the moment */ ds = display_state; /* terminal init */ @@ -5543,8 +5536,6 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "fatal: -nographic can't be used with -curses\n"); exit(1); } - /* nearly nothing to do */ - dumb_display_init(ds); } else { #if defined(CONFIG_CURSES) if (curses) { @@ -5563,8 +5554,6 @@ int main(int argc, char **argv, char **envp) sdl_display_init(ds, full_screen, no_frame); #elif defined(CONFIG_COCOA) cocoa_display_init(ds, full_screen); -#else - dumb_display_init(ds); #endif } }