From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M7GHT-0001ua-1Z for qemu-devel@nongnu.org; Thu, 21 May 2009 17:58:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M7GHO-0001qu-9s for qemu-devel@nongnu.org; Thu, 21 May 2009 17:58:26 -0400 Received: from [199.232.76.173] (port=34828 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7GHO-0001qr-6i for qemu-devel@nongnu.org; Thu, 21 May 2009 17:58:22 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:40546) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M7GHN-0004Uk-Lr for qemu-devel@nongnu.org; Thu, 21 May 2009 17:58:21 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e33.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n4LLuP5X026116 for ; Thu, 21 May 2009 15:56:25 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4LLwCMk182998 for ; Thu, 21 May 2009 15:58:12 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4LLwBhC007581 for ; Thu, 21 May 2009 15:58:12 -0600 Message-ID: <4A15CE70.7030201@us.ibm.com> Date: Thu, 21 May 2009 16:58:08 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1242930079-19798-1-git-send-email-glommer@redhat.com> In-Reply-To: <1242930079-19798-1-git-send-email-glommer@redhat.com> Content-Type: multipart/mixed; boundary="------------080602020107060502060908" Subject: [Qemu-devel] Re: [PATCH] run vnc without sdl List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------080602020107060502060908 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Glauber Costa wrote: > commit f92f8afebe038a4eae9ad90a140c9529f94919a6 > "Eliminate --disable-gfx-check and make VNC default when SDL not available" > broke usage of vnc. Passing -vnc now fails because it cannot initialize > SDL. > > Signed-off-by: Glauber Costa > What do you think about the attached? My goal with the original refactoring was to more cleanly separate things that's why I didn't want to introduce the !vnc_display. Ideally, we could make the various display states register themselves and completely eliminate the #ifdefs... -- Regards, Anthony Liguori --------------080602020107060502060908 Content-Type: text/x-patch; name="introduce_display_type.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="introduce_display_type.patch" commit e83ee25a46da8f612692337ce4a8207661163d09 Author: Anthony Liguori Date: Thu May 21 16:54:00 2009 -0500 Refactor how display drivers are selected My previous commit, f92f8afebe, broke -vnc (spotted by Glauber Costa). This is because it's necessary to tell when the no special display parameters have been passed and default to SDL or VNC appropriately. This refactors the display selection logic to be less complicated which has the effect of fixing the regression mentioned above. Signed-off-by: Anthony Liguori diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 39bd955..e605cda 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -277,7 +277,7 @@ void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, } fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (uint8_t *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); - fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)nographic); + fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); diff --git a/qemu-char.c b/qemu-char.c index 664cbfd..1c0c9f5 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -571,7 +571,7 @@ static void fd_chr_update_read_handler(CharDriverState *chr) FDCharDriver *s = chr->opaque; if (s->fd_in >= 0) { - if (nographic && s->fd_in == 0) { + if (display_type == DT_NOGRAPHIC && s->fd_in == 0) { } else { qemu_set_fd_handler2(s->fd_in, fd_chr_read_poll, fd_chr_read, NULL, chr); @@ -584,7 +584,7 @@ static void fd_chr_close(struct CharDriverState *chr) FDCharDriver *s = chr->opaque; if (s->fd_in >= 0) { - if (nographic && s->fd_in == 0) { + if (display_type == DT_NOGRAPHIC && s->fd_in == 0) { } else { qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL); } @@ -714,7 +714,7 @@ static void term_init(void) tty.c_oflag |= OPOST; tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); /* if graphical mode, we allow Ctrl-C handling */ - if (nographic) + if (display_type == DT_NOGRAPHIC) tty.c_lflag &= ~ISIG; tty.c_cflag &= ~(CSIZE|PARENB); tty.c_cflag |= CS8; diff --git a/sysemu.h b/sysemu.h index 7d65804..4063533 100644 --- a/sysemu.h +++ b/sysemu.h @@ -86,6 +86,15 @@ int tap_win32_init(VLANState *vlan, const char *model, /* SLIRP */ void do_info_slirp(Monitor *mon); +typedef enum DisplayType +{ + DT_DEFAULT, + DT_CURSES, + DT_SDL, + DT_VNC, + DT_NOGRAPHIC, +} DisplayType; + extern int bios_size; extern int cirrus_vga_enabled; extern int std_vga_enabled; @@ -94,7 +103,7 @@ extern int xenfb_enabled; extern int graphic_width; extern int graphic_height; extern int graphic_depth; -extern int nographic; +extern DisplayType display_type; extern const char *keyboard_layout; extern int win2k_install_hack; extern int rtc_td_hack; diff --git a/vl.c b/vl.c index 68c8514..a0ce977 100644 --- a/vl.c +++ b/vl.c @@ -201,9 +201,7 @@ DriveInfo drives_table[MAX_DRIVES+1]; int nb_drives; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; static DisplayState *display_state; -int nographic; -static int curses; -static int sdl = 1; +DisplayType display_type = DT_DEFAULT; const char* keyboard_layout = NULL; int64_t ticks_per_sec; ram_addr_t ram_size; @@ -4842,6 +4840,7 @@ int main(int argc, char **argv, char **envp) const char *run_as = NULL; #endif CPUState *env; + int show_vnc_port = 0; qemu_cache_utils_init(envp); @@ -4882,8 +4881,6 @@ int main(int argc, char **argv, char **envp) initrd_filename = NULL; ram_size = 0; snapshot = 0; - nographic = 0; - curses = 0; kernel_filename = NULL; kernel_cmdline = ""; cyls = heads = secs = 0; @@ -5075,11 +5072,11 @@ int main(int argc, char **argv, char **envp) numa_add(optarg); break; case QEMU_OPTION_nographic: - nographic = 1; + display_type = DT_NOGRAPHIC; break; #ifdef CONFIG_CURSES case QEMU_OPTION_curses: - curses = 1; + display_type = DT_CURSES; break; #endif case QEMU_OPTION_portrait: @@ -5358,7 +5355,7 @@ int main(int argc, char **argv, char **envp) no_quit = 1; break; case QEMU_OPTION_sdl: - sdl = 1; + display_type = DT_SDL; break; #endif case QEMU_OPTION_pidfile: @@ -5420,6 +5417,7 @@ int main(int argc, char **argv, char **envp) } break; case QEMU_OPTION_vnc: + display_type = DT_VNC; vnc_display = optarg; break; #ifdef TARGET_I386 @@ -5578,7 +5576,7 @@ int main(int argc, char **argv, char **envp) exit(1); } - if (nographic) { + if (display_type == DT_NOGRAPHIC) { if (serial_device_index == 0) serial_devices[0] = "stdio"; if (parallel_device_index == 0) @@ -5944,44 +5942,46 @@ int main(int argc, char **argv, char **envp) dumb_display_init(); /* just use the first displaystate for the moment */ ds = display_state; - /* terminal init */ - if (nographic) { - if (curses) { - fprintf(stderr, "fatal: -nographic can't be used with -curses\n"); - exit(1); - } - } else { + + if (display_type == DT_DEFAULT) { +#if defined(CONFIG_SDL) || defined(CONFIG_COCOA) + display_type = DT_SDL; +#else + display_type = DT_VNC; + vnc_display = "localhost:0,to=99"; + show_vnc_port = 1; +#endif + } + + + switch (display_type) { + case DT_NOGRAPHIC: + break; #if defined(CONFIG_CURSES) - if (curses) { - /* At the moment curses cannot be used with other displays */ - curses_display_init(ds, full_screen); - } else + case DT_CURSES: + curses_display_init(ds, full_screen); + break; #endif -#if defined(CONFIG_SDL) || defined(CONFIG_COCOA) - if (sdl) { #if defined(CONFIG_SDL) - sdl_display_init(ds, full_screen, no_frame); + case DT_SDL: + sdl_display_init(ds, full_screen, no_frame); + break; #elif defined(CONFIG_COCOA) - cocoa_display_init(ds, full_screen); -#endif - } else + case DT_SDL: + cocoa_display_init(ds, full_screen); + break; #endif - { - int print_port = 0; - - if (vnc_display == NULL) { - vnc_display = "localhost:0,to=99"; - print_port = 1; - } - - vnc_display_init(ds); - if (vnc_display_open(ds, vnc_display) < 0) - exit(1); + case DT_VNC: + vnc_display_init(ds); + if (vnc_display_open(ds, vnc_display) < 0) + exit(1); - if (print_port) { - printf("VNC server running on `%s'\n", vnc_display_local_addr(ds)); - } + if (show_vnc_port) { + printf("VNC server running on `%s'\n", vnc_display_local_addr(ds)); } + break; + default: + break; } dpy_resize(ds); @@ -5994,7 +5994,7 @@ int main(int argc, char **argv, char **envp) dcl = dcl->next; } - if (nographic || (vnc_display && !sdl)) { + if (display_type == DT_NOGRAPHIC || display_type == DT_VNC) { nographic_timer = qemu_new_timer(rt_clock, nographic_update, NULL); qemu_mod_timer(nographic_timer, qemu_get_clock(rt_clock)); } --------------080602020107060502060908--