diff options
author | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-06-02 22:54:02 +0000 |
---|---|---|
committer | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-06-02 22:54:02 +0000 |
commit | 9e219fc50e7743de01d37e77ea77ceb0c024595f (patch) | |
tree | 244f75a03f5e6e10d058c606110eaabb3f008747 | |
parent | 137cf1e1e3b56f74d76e17cc07e23d749eeaab46 (diff) | |
download | xen-9e219fc50e7743de01d37e77ea77ceb0c024595f.tar.gz xen-9e219fc50e7743de01d37e77ea77ceb0c024595f.tar.bz2 xen-9e219fc50e7743de01d37e77ea77ceb0c024595f.zip |
bitkeeper revision 1.928 (40be5a8aziacBnOxNaBHmDnYSJp9Dw)
Domains != 0 now install virtual console on tty1. We also install
dummy devices tty2-63 to suppress warnings from overzealous distro
default startup scripts. Documentation is updated to reflect these
changes.
-rw-r--r-- | README.CD | 16 | ||||
-rw-r--r-- | docs/Console-HOWTO.txt | 27 | ||||
-rw-r--r-- | docs/Xen-HOWTO.txt | 15 | ||||
-rw-r--r-- | xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c | 89 |
4 files changed, 104 insertions, 43 deletions
@@ -545,15 +545,19 @@ remove ttyN from /etc/inittab for domains>0. Due to a bug in the RH9 as it ignores the '#' and tries to access them anyway. Every Xenolinux instance owns a bidirectional 'virtual -console'. Boot-time output can be directed to this console by -specifying 'console=xencons0' as a boot parameter. It is also possible -to log in via the virtual console. To do this, you must run a mingetty -on the virtual console, which you can achieve as follows: +console'. Boot-time output will be directed to this console by default +for all domain other than 0 (because the console name is tty0); domain +0 requires you to specify 'console=xencons0' as a boot parameter. It +is also possible to log in via the virtual console --- once again, for +most domains your normal startup scripts will work as normal (e.g., by +running mingetty on tty1-7). For domain 0, you must connect to the +special 'xencons' device node: # mkdir -p /dev/xen # mknod /dev/xen/cons c 4 123 # echo "c:2345:respawn:/sbin/mingetty --noclear xen/cons" >>/etc/inittab -If you wish to permit root logins via the virtual console then you must -also add 'xen/cons' to the list of trusted ttys in /etc/securetty. +If you wish to permit root logins via the special DOM0 node then you +must also add 'xen/cons' to the list of trusted ttys in +/etc/securetty. Note that, because domains>0 don't have any privileged access at all, certain commands in the default boot sequence will fail e.g. attempts diff --git a/docs/Console-HOWTO.txt b/docs/Console-HOWTO.txt index 22927785dc..d62f719117 100644 --- a/docs/Console-HOWTO.txt +++ b/docs/Console-HOWTO.txt @@ -30,16 +30,17 @@ Connecting to the virtual console Logging in via virtual console ------------------------------ It is possible to log in to a guest OS via its virtual console if a - 'getty' is running. To achieve this, a suitable device node must be - created, and a new line added to inittab: + 'getty' is running. In most domains the virtual console is named tty1 + so standard startup scripts and /etc/inittab should work + fine. Furthermore, tty2-63 are created as dummy console devices to + suppress warnings from standard startup scripts. + + In domain 0 we avoid conflict with the 'real' console by registering + the virtual console with a special device number. A suitable device + node must therefore be created, and a new line added to inittab: # mkdir -p /dev/xen # mknod /dev/xen/cons c 4 123 # echo "c:2345:respawn:/sbin/mingetty --noclear xen/cons" >>/etc/inittab - - [NOTE to users in the lab -- existing Xen installations may be running - mingetty on /dev/console. This is incorrect behaviour! Please modify - such setups to run mingetty on /dev/xen/cons.] - Additionally, if you wish to allow root logins via the virtual console, then 'xen/cons' must be added to the trusted tty list in /etc/securetty. On some systems you *may* also need to modify the @@ -48,12 +49,12 @@ Logging in via virtual console Virtual console for other domains --------------------------------- Every guest OS has a virtual console that is accessible via - 'console=xencons0' at boot time, or mingetty running on - /dev/xen/cons. However, domains other than domain 0 do not have access - to the physical serial line. Instead, their console data is sent to - and from a control daemon running in domain 0. When properly - installed, this daemon can be started from the init scripts (e.g., - rc.local): + 'console=tty0' at boot time (or 'console=xencons0' for domain 0), and + mingetty running on /dev/tty1 (or /dev/xen/cons for domain 0). + However, domains other than domain 0 do not have access to the + physical serial line. Instead, their console data is sent to and from + a control daemon running in domain 0. When properly installed, this + daemon can be started from the init scripts (e.g., rc.local): # /usr/sbin/xend start Alternatively, Redhat- and LSB-compatible Linux installations can use diff --git a/docs/Xen-HOWTO.txt b/docs/Xen-HOWTO.txt index af88c12a62..8e61559347 100644 --- a/docs/Xen-HOWTO.txt +++ b/docs/Xen-HOWTO.txt @@ -276,18 +276,13 @@ terminal session. This module is also installed as /usr/bin/xencons, from a copy in tools/misc/xencons. An alternative to manually running a terminal client is to specify '-c' to xc_dom_create.py, or add 'auto_console=True' to the defaults file. This will cause -xc_dom_create.py to automatically become teh console terminal after +xc_dom_create.py to automatically become the console terminal after starting the domain. -Boot-time output can be directed to this 'virtual console' by -specifying 'console=xencons0' as a boot parameter. It is also possible -to log in via the virtual console. To do this, you must run a mingetty -on the virtual console, which you can achieve as follows: - # mkdir -p /dev/xen - # mknod /dev/xen/cons c 4 123 - # echo "c:2345:respawn:/sbin/mingetty --noclear xen/cons" >>/etc/inittab -If you wish to permit root logins via the virtual console then you must -also add 'xen/cons' to the list of trusted ttys in /etc/securetty. +Boot-time output will be directed to this console by default, because +the console name is tty0. It is also possible to log in via the +virtual console --- once again, your normal startup scripts will work +as normal (e.g., by running mingetty on tty1-7). Manage Running Domains diff --git a/xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c b/xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c index 4136d3fda7..0d2a0ab9f6 100644 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c @@ -30,7 +30,13 @@ #include <asm/hypervisor-ifs/event_channel.h> #include <asm/ctrl_if.h> -#define XEN_TTY_MINOR 123 +/* + * NB. /dev/xencons[0-9]+ are only exported by domain 0. + * All other domains use the normal /dev/tty[0-9]+ device nodes. + * Only /dev/tty1 is currently hooked up to real I/O -- all others are + * dummies to suppress warnings from standard distro startip scripts. + */ +#define XENCONS_TTY_MINOR 123 /* The kernel and user-land drivers share a common transmit buffer. */ #define WBUF_SIZE 4096 @@ -93,22 +99,34 @@ static void kcons_write_dom0( static kdev_t kcons_device(struct console *c) { - /* - * This is the magic that binds our "struct console" to our - * "tty_struct", defined below. - */ - return MKDEV(TTY_MAJOR, XEN_TTY_MINOR); + return MKDEV(TTY_MAJOR, 1); +} + +static kdev_t kcons_device_dom0(struct console *c) +{ + return MKDEV(TTY_MAJOR, XENCONS_TTY_MINOR); } static struct console kcons_info = { - name: "xencons", - device: kcons_device, flags: CON_PRINTBUFFER, index: -1, }; void xen_console_init(void) { + if ( start_info.flags & SIF_INITDOMAIN ) + { + strcpy(kcons_info.name, "xencons"); + kcons_info.device = kcons_device_dom0; + kcons_info.write = kcons_write_dom0; + } + else + { + strcpy(kcons_info.name, "tty"); + kcons_info.device = kcons_device; + kcons_info.write = kcons_write; + } + kcons_info.write = (start_info.flags & SIF_INITDOMAIN) ? kcons_write_dom0 : kcons_write; register_console(&kcons_info); @@ -177,9 +195,9 @@ void xencons_force_flush(void) static struct tty_driver xencons_driver; static int xencons_refcount; -static struct tty_struct *xencons_table[1]; -static struct termios *xencons_termios[1]; -static struct termios *xencons_termios_locked[1]; +static struct tty_struct *xencons_table[MAX_NR_CONSOLES]; +static struct termios *xencons_termios[MAX_NR_CONSOLES]; +static struct termios *xencons_termios_locked[MAX_NR_CONSOLES]; static struct tty_struct *xencons_tty; static int xencons_priv_irq; static char x_char; @@ -323,6 +341,10 @@ static int xencons_chars_in_buffer(struct tty_struct *tty) static void xencons_send_xchar(struct tty_struct *tty, char ch) { unsigned long flags; + + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + spin_lock_irqsave(&xencons_lock, flags); x_char = ch; __xencons_tx_flush(); @@ -331,12 +353,18 @@ static void xencons_send_xchar(struct tty_struct *tty, char ch) static void xencons_throttle(struct tty_struct *tty) { + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + if ( I_IXOFF(tty) ) xencons_send_xchar(tty, STOP_CHAR(tty)); } static void xencons_unthrottle(struct tty_struct *tty) { + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + if ( I_IXOFF(tty) ) { if ( x_char != 0 ) @@ -349,6 +377,10 @@ static void xencons_unthrottle(struct tty_struct *tty) static void xencons_flush_buffer(struct tty_struct *tty) { unsigned long flags; + + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + spin_lock_irqsave(&xencons_lock, flags); wc = wp = 0; spin_unlock_irqrestore(&xencons_lock, flags); @@ -372,6 +404,9 @@ static int xencons_write(struct tty_struct *tty, int from_user, if ( from_user && verify_area(VERIFY_READ, buf, count) ) return -EINVAL; + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return count; + spin_lock_irqsave(&xencons_lock, flags); for ( i = 0; i < count; i++ ) @@ -396,6 +431,10 @@ static int xencons_write(struct tty_struct *tty, int from_user, static void xencons_put_char(struct tty_struct *tty, u_char ch) { unsigned long flags; + + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + spin_lock_irqsave(&xencons_lock, flags); (void)__xencons_put_char(ch); spin_unlock_irqrestore(&xencons_lock, flags); @@ -404,6 +443,10 @@ static void xencons_put_char(struct tty_struct *tty, u_char ch) static void xencons_flush_chars(struct tty_struct *tty) { unsigned long flags; + + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + spin_lock_irqsave(&xencons_lock, flags); __xencons_tx_flush(); spin_unlock_irqrestore(&xencons_lock, flags); @@ -413,6 +456,9 @@ static void xencons_wait_until_sent(struct tty_struct *tty, int timeout) { unsigned long orig_jiffies = jiffies; + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + while ( tty->driver.chars_in_buffer(tty) ) { set_current_state(TASK_INTERRUPTIBLE); @@ -431,6 +477,9 @@ static int xencons_open(struct tty_struct *tty, struct file *filp) int line; unsigned long flags; + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return 0; + MOD_INC_USE_COUNT; line = MINOR(tty->device) - tty->driver.minor_start; if ( line != 0 ) @@ -453,6 +502,9 @@ static void xencons_close(struct tty_struct *tty, struct file *filp) { unsigned long flags; + if ( MINOR(tty->device) != xencons_driver.minor_start ) + return; + if ( tty->count == 1 ) { tty->closing = 1; @@ -474,10 +526,8 @@ static int __init xencons_init(void) { memset(&xencons_driver, 0, sizeof(struct tty_driver)); xencons_driver.magic = TTY_DRIVER_MAGIC; - xencons_driver.name = "xencons"; xencons_driver.major = TTY_MAJOR; - xencons_driver.minor_start = XEN_TTY_MINOR; - xencons_driver.num = 1; + xencons_driver.num = MAX_NR_CONSOLES; xencons_driver.type = TTY_DRIVER_TYPE_SERIAL; xencons_driver.subtype = SERIAL_TYPE_NORMAL; xencons_driver.init_termios = tty_std_termios; @@ -488,6 +538,17 @@ static int __init xencons_init(void) xencons_driver.termios = xencons_termios; xencons_driver.termios_locked = xencons_termios_locked; + if ( start_info.flags & SIF_INITDOMAIN ) + { + xencons_driver.name = "xencons"; + xencons_driver.minor_start = XENCONS_TTY_MINOR; + } + else + { + xencons_driver.name = "tty"; + xencons_driver.minor_start = 1; + } + xencons_driver.open = xencons_open; xencons_driver.close = xencons_close; xencons_driver.write = xencons_write; |