xencons: further Dom0 handling improvements c/s 1242:731ff1f10c46 ("xencons: generalize use of add_preferred_console()") still left cases where (in Dom0) the console would get registered with index -1. Eliminate these cases by - also calling add_preferred_console() in Dom0 when "xencons=" was specified - setting the index directly when in Dom0 and "xencons=" was not given Also do some cleanup: - Move the declaration of console_use_vt into the respective global header (where it should have been placed from the beginning), and use a #define instead of a variable when !XEN. - Replace the needless uses of goto in xen_console_init() with plain return statements. Reported-by: Olaf Hering Signed-off-by: Jan Beulich --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -130,7 +130,9 @@ LIST_HEAD(tty_drivers); /* linked list vt.c for deeply disgusting hack reasons */ DEFINE_MUTEX(tty_mutex); +#ifndef console_use_vt int console_use_vt = 1; +#endif #ifdef CONFIG_UNIX98_PTYS extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ --- a/drivers/xen/console/console.c +++ b/drivers/xen/console/console.c @@ -86,9 +86,8 @@ static int __init xencons_setup(char *st { char *q; int n; - extern int console_use_vt; - console_use_vt = 1; + console_use_vt = -1; if (!strncmp(str, "ttyS", 4)) { xc_mode = XC_SERIAL; str += 4; @@ -193,13 +192,13 @@ static struct console kcons_info = { static int __init xen_console_init(void) { if (!is_running_on_xen()) - goto out; + return 0; if (is_initial_xendomain()) { kcons_info.write = kcons_write_dom0; } else { if (!xen_start_info->console.domU.evtchn) - goto out; + return 0; kcons_info.write = kcons_write; } @@ -229,16 +228,17 @@ static int __init xen_console_init(void) break; default: - goto out; + return 0; } wbuf = alloc_bootmem(wbuf_size); - if (!is_initial_xendomain()) + if (console_use_vt <= 0 || !is_initial_xendomain()) add_preferred_console(kcons_info.name, xc_num, NULL); + else + kcons_info.index = xc_num; register_console(&kcons_info); - out: return 0; } console_initcall(xen_console_init); --- a/include/linux/console.h +++ b/include/linux/console.h @@ -63,6 +63,12 @@ extern const struct consw vga_con; /* VG extern const struct consw newport_con; /* SGI Newport console */ extern const struct consw prom_con; /* SPARC PROM console */ +#ifdef CONFIG_XEN +extern int console_use_vt; +#else +#define console_use_vt 1 +#endif + int con_is_bound(const struct consw *csw); int register_con_driver(const struct consw *csw, int first, int last); int unregister_con_driver(const struct consw *csw);