Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen: Enable console tty by default in domU if it's not a dummy

Without console= arguments on the kernel command line, the first
console to register becomes enabled and the preferred console (the one
behind /dev/console). This is normally tty (assuming
CONFIG_VT_CONSOLE is enabled, which it commonly is).

This is okay as long tty is a useful console. But unless we have the
PV framebuffer, and it is enabled for this domain, tty0 in domU is
merely a dummy. In that case, we want the preferred console to be the
Xen console hvc0, and we want it without having to fiddle with the
kernel command line. Commit b8c2d3dfbc117dff26058fbac316b8acfc2cb5f7
did that for us.

Since we now have the PV framebuffer, we want to enable and prefer tty
again, but only when PVFB is enabled. But even then we still want to
enable the Xen console as well.

Problem: when tty registers, we can't yet know whether the PVFB is
enabled. By the time we can know (xenstore is up), the console setup
game is over.

Solution: enable console tty by default, but keep hvc as the preferred
console. Change the preferred console to tty when PVFB probes
successfully, unless we've been given console kernel parameters.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Markus Armbruster and committed by
Thomas Gleixner
9e124fe1 a15af1c9

+33 -1
+3 -1
arch/x86/xen/enlighten.c
··· 1256 1256 ? __pa(xen_start_info->mod_start) : 0; 1257 1257 boot_params.hdr.ramdisk_size = xen_start_info->mod_len; 1258 1258 1259 - if (!is_initial_xendomain()) 1259 + if (!is_initial_xendomain()) { 1260 + add_preferred_console("tty", 0, NULL); 1260 1261 add_preferred_console("hvc", 0, NULL); 1262 + } 1261 1263 1262 1264 /* Start the world */ 1263 1265 start_kernel();
+25
drivers/video/xen-fbfront.c
··· 18 18 * frame buffer. 19 19 */ 20 20 21 + #include <linux/console.h> 21 22 #include <linux/kernel.h> 22 23 #include <linux/errno.h> 23 24 #include <linux/fb.h> ··· 49 48 50 49 static u32 xenfb_mem_len = XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH / 8; 51 50 51 + static void xenfb_make_preferred_console(void); 52 52 static int xenfb_remove(struct xenbus_device *); 53 53 static void xenfb_init_shared_page(struct xenfb_info *); 54 54 static int xenfb_connect_backend(struct xenbus_device *, struct xenfb_info *); ··· 350 348 if (ret < 0) 351 349 goto error; 352 350 351 + xenfb_make_preferred_console(); 353 352 return 0; 354 353 355 354 error_nomem: ··· 359 356 error: 360 357 xenfb_remove(dev); 361 358 return ret; 359 + } 360 + 361 + static __devinit void 362 + xenfb_make_preferred_console(void) 363 + { 364 + struct console *c; 365 + 366 + if (console_set_on_cmdline) 367 + return; 368 + 369 + acquire_console_sem(); 370 + for (c = console_drivers; c; c = c->next) { 371 + if (!strcmp(c->name, "tty") && c->index == 0) 372 + break; 373 + } 374 + release_console_sem(); 375 + if (c) { 376 + unregister_console(c); 377 + c->flags |= CON_CONSDEV; 378 + c->flags &= ~CON_PRINTBUFFER; /* don't print again */ 379 + register_console(c); 380 + } 362 381 } 363 382 364 383 static int xenfb_resume(struct xenbus_device *dev)
+2
include/linux/console.h
··· 108 108 struct console *next; 109 109 }; 110 110 111 + extern int console_set_on_cmdline; 112 + 111 113 extern int add_preferred_console(char *name, int idx, char *options); 112 114 extern int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options); 113 115 extern void register_console(struct console *);
+3
kernel/printk.c
··· 121 121 static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES]; 122 122 static int selected_console = -1; 123 123 static int preferred_console = -1; 124 + int console_set_on_cmdline; 125 + EXPORT_SYMBOL(console_set_on_cmdline); 124 126 125 127 /* Flag: console code may call schedule() */ 126 128 static int console_may_schedule; ··· 892 890 *s = 0; 893 891 894 892 __add_preferred_console(buf, idx, options, brl_options); 893 + console_set_on_cmdline = 1; 895 894 return 1; 896 895 } 897 896 __setup("console=", console_setup);