direct-io.hg

changeset 1424:26483a083da1

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.
author kaf24@scramble.cl.cam.ac.uk
date Wed Jun 02 22:54:02 2004 +0000 (2004-06-02)
parents 7e6b26d1ec0a
children 46406c62b1d3
files README.CD docs/Console-HOWTO.txt docs/Xen-HOWTO.txt xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c
line diff
     1.1 --- a/README.CD	Wed Jun 02 14:04:13 2004 +0000
     1.2 +++ b/README.CD	Wed Jun 02 22:54:02 2004 +0000
     1.3 @@ -545,15 +545,19 @@ remove ttyN from /etc/inittab for domain
     1.4  as it ignores the '#' and tries to access them anyway.
     1.5  
     1.6  Every Xenolinux instance owns a bidirectional 'virtual
     1.7 -console'. Boot-time output can be directed to this console by
     1.8 -specifying 'console=xencons0' as a boot parameter. It is also possible
     1.9 -to log in via the virtual console. To do this, you must run a mingetty
    1.10 -on the virtual console, which you can achieve as follows:
    1.11 +console'. Boot-time output will be directed to this console by default
    1.12 +for all domain other than 0 (because the console name is tty0); domain
    1.13 +0 requires you to specify 'console=xencons0' as a boot parameter. It
    1.14 +is also possible to log in via the virtual console --- once again, for
    1.15 +most domains your normal startup scripts will work as normal (e.g., by
    1.16 +running mingetty on tty1-7). For domain 0, you must connect to the
    1.17 +special 'xencons' device node:
    1.18   # mkdir -p /dev/xen
    1.19   # mknod /dev/xen/cons c 4 123
    1.20   # echo "c:2345:respawn:/sbin/mingetty --noclear xen/cons" >>/etc/inittab
    1.21 -If you wish to permit root logins via the virtual console then you must
    1.22 -also add 'xen/cons' to the list of trusted ttys in /etc/securetty.
    1.23 +If you wish to permit root logins via the special DOM0 node then you
    1.24 +must also add 'xen/cons' to the list of trusted ttys in
    1.25 +/etc/securetty.
    1.26  
    1.27  Note that, because domains>0 don't have any privileged access at all,
    1.28  certain commands in the default boot sequence will fail e.g. attempts
     2.1 --- a/docs/Console-HOWTO.txt	Wed Jun 02 14:04:13 2004 +0000
     2.2 +++ b/docs/Console-HOWTO.txt	Wed Jun 02 22:54:02 2004 +0000
     2.3 @@ -30,16 +30,17 @@ Connecting to the virtual console
     2.4  Logging in via virtual console
     2.5  ------------------------------
     2.6   It is possible to log in to a guest OS via its virtual console if a
     2.7 - 'getty' is running. To achieve this, a suitable device node must be
     2.8 - created, and a new line added to inittab:
     2.9 + 'getty' is running. In most domains the virtual console is named tty1
    2.10 + so standard startup scripts and /etc/inittab should work
    2.11 + fine. Furthermore, tty2-63 are created as dummy console devices to
    2.12 + suppress warnings from standard startup scripts.
    2.13 +
    2.14 + In domain 0 we avoid conflict with the 'real' console by registering
    2.15 + the virtual console with a special device number. A suitable device
    2.16 + node must therefore be created, and a new line added to inittab:
    2.17    # mkdir -p /dev/xen
    2.18    # mknod /dev/xen/cons c 4 123
    2.19    # echo "c:2345:respawn:/sbin/mingetty --noclear xen/cons" >>/etc/inittab
    2.20 -
    2.21 - [NOTE to users in the lab -- existing Xen installations may be running
    2.22 - mingetty on /dev/console. This is incorrect behaviour! Please modify
    2.23 - such setups to run mingetty on /dev/xen/cons.]
    2.24 -
    2.25   Additionally, if you wish to allow root logins via the virtual
    2.26   console, then 'xen/cons' must be added to the trusted tty list in
    2.27   /etc/securetty. On some systems you *may* also need to modify the
    2.28 @@ -48,12 +49,12 @@ Logging in via virtual console
    2.29  Virtual console for other domains
    2.30  ---------------------------------
    2.31   Every guest OS has a virtual console that is accessible via
    2.32 - 'console=xencons0' at boot time, or mingetty running on
    2.33 - /dev/xen/cons. However, domains other than domain 0 do not have access
    2.34 - to the physical serial line. Instead, their console data is sent to
    2.35 - and from a control daemon running in domain 0. When properly
    2.36 - installed, this daemon can be started from the init scripts (e.g.,
    2.37 - rc.local):
    2.38 + 'console=tty0' at boot time (or 'console=xencons0' for domain 0), and
    2.39 + mingetty running on /dev/tty1 (or /dev/xen/cons for domain 0).
    2.40 + However, domains other than domain 0 do not have access to the
    2.41 + physical serial line. Instead, their console data is sent to and from
    2.42 + a control daemon running in domain 0. When properly installed, this
    2.43 + daemon can be started from the init scripts (e.g., rc.local):
    2.44    # /usr/sbin/xend start
    2.45  
    2.46   Alternatively, Redhat- and LSB-compatible Linux installations can use
     3.1 --- a/docs/Xen-HOWTO.txt	Wed Jun 02 14:04:13 2004 +0000
     3.2 +++ b/docs/Xen-HOWTO.txt	Wed Jun 02 22:54:02 2004 +0000
     3.3 @@ -276,18 +276,13 @@ terminal session. This module is also in
     3.4  from a copy in tools/misc/xencons.  An alternative to manually running
     3.5  a terminal client is to specify '-c' to xc_dom_create.py, or add
     3.6  'auto_console=True' to the defaults file. This will cause
     3.7 -xc_dom_create.py to automatically become teh console terminal after
     3.8 +xc_dom_create.py to automatically become the console terminal after
     3.9  starting the domain.
    3.10  
    3.11 -Boot-time output can be directed to this 'virtual console' by
    3.12 -specifying 'console=xencons0' as a boot parameter. It is also possible
    3.13 -to log in via the virtual console. To do this, you must run a mingetty
    3.14 -on the virtual console, which you can achieve as follows:
    3.15 - # mkdir -p /dev/xen
    3.16 - # mknod /dev/xen/cons c 4 123
    3.17 - # echo "c:2345:respawn:/sbin/mingetty --noclear xen/cons" >>/etc/inittab
    3.18 -If you wish to permit root logins via the virtual console then you must
    3.19 -also add 'xen/cons' to the list of trusted ttys in /etc/securetty.
    3.20 +Boot-time output will be directed to this console by default, because
    3.21 +the console name is tty0. It is also possible to log in via the
    3.22 +virtual console --- once again, your normal startup scripts will work
    3.23 +as normal (e.g., by running mingetty on tty1-7).
    3.24  
    3.25  
    3.26  Manage Running Domains
     4.1 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c	Wed Jun 02 14:04:13 2004 +0000
     4.2 +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/console/console.c	Wed Jun 02 22:54:02 2004 +0000
     4.3 @@ -30,7 +30,13 @@
     4.4  #include <asm/hypervisor-ifs/event_channel.h>
     4.5  #include <asm/ctrl_if.h>
     4.6  
     4.7 -#define XEN_TTY_MINOR 123
     4.8 +/*
     4.9 + * NB. /dev/xencons[0-9]+ are only exported by domain 0.
    4.10 + * All other domains use the normal /dev/tty[0-9]+ device nodes.
    4.11 + * Only /dev/tty1 is currently hooked up to real I/O -- all others are
    4.12 + * dummies to suppress warnings from standard distro startip scripts.
    4.13 + */
    4.14 +#define XENCONS_TTY_MINOR   123
    4.15  
    4.16  /* The kernel and user-land drivers share a common transmit buffer. */
    4.17  #define WBUF_SIZE     4096
    4.18 @@ -93,22 +99,34 @@ static void kcons_write_dom0(
    4.19  
    4.20  static kdev_t kcons_device(struct console *c)
    4.21  {
    4.22 -    /*
    4.23 -     * This is the magic that binds our "struct console" to our
    4.24 -     * "tty_struct", defined below.
    4.25 -     */
    4.26 -    return MKDEV(TTY_MAJOR, XEN_TTY_MINOR);
    4.27 +    return MKDEV(TTY_MAJOR, 1);
    4.28 +}
    4.29 +
    4.30 +static kdev_t kcons_device_dom0(struct console *c)
    4.31 +{
    4.32 +    return MKDEV(TTY_MAJOR, XENCONS_TTY_MINOR);
    4.33  }
    4.34  
    4.35  static struct console kcons_info = {
    4.36 -    name:    "xencons",
    4.37 -    device:  kcons_device,
    4.38      flags:   CON_PRINTBUFFER,
    4.39      index:   -1,
    4.40  };
    4.41  
    4.42  void xen_console_init(void)
    4.43  {
    4.44 +    if ( start_info.flags & SIF_INITDOMAIN )
    4.45 +    {
    4.46 +        strcpy(kcons_info.name, "xencons");
    4.47 +        kcons_info.device = kcons_device_dom0;
    4.48 +        kcons_info.write  = kcons_write_dom0;
    4.49 +    }
    4.50 +    else
    4.51 +    {
    4.52 +        strcpy(kcons_info.name, "tty");
    4.53 +        kcons_info.device = kcons_device;
    4.54 +        kcons_info.write  = kcons_write;
    4.55 +    }
    4.56 +
    4.57      kcons_info.write = 
    4.58          (start_info.flags & SIF_INITDOMAIN) ? kcons_write_dom0 : kcons_write;
    4.59      register_console(&kcons_info);
    4.60 @@ -177,9 +195,9 @@ void xencons_force_flush(void)
    4.61  
    4.62  static struct tty_driver xencons_driver;
    4.63  static int xencons_refcount;
    4.64 -static struct tty_struct *xencons_table[1];
    4.65 -static struct termios *xencons_termios[1];
    4.66 -static struct termios *xencons_termios_locked[1];
    4.67 +static struct tty_struct *xencons_table[MAX_NR_CONSOLES];
    4.68 +static struct termios *xencons_termios[MAX_NR_CONSOLES];
    4.69 +static struct termios *xencons_termios_locked[MAX_NR_CONSOLES];
    4.70  static struct tty_struct *xencons_tty;
    4.71  static int xencons_priv_irq;
    4.72  static char x_char;
    4.73 @@ -323,6 +341,10 @@ static int xencons_chars_in_buffer(struc
    4.74  static void xencons_send_xchar(struct tty_struct *tty, char ch)
    4.75  {
    4.76      unsigned long flags;
    4.77 +
    4.78 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
    4.79 +        return;
    4.80 +
    4.81      spin_lock_irqsave(&xencons_lock, flags);
    4.82      x_char = ch;
    4.83      __xencons_tx_flush();
    4.84 @@ -331,12 +353,18 @@ static void xencons_send_xchar(struct tt
    4.85  
    4.86  static void xencons_throttle(struct tty_struct *tty)
    4.87  {
    4.88 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
    4.89 +        return;
    4.90 +
    4.91      if ( I_IXOFF(tty) )
    4.92          xencons_send_xchar(tty, STOP_CHAR(tty));
    4.93  }
    4.94  
    4.95  static void xencons_unthrottle(struct tty_struct *tty)
    4.96  {
    4.97 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
    4.98 +        return;
    4.99 +
   4.100      if ( I_IXOFF(tty) )
   4.101      {
   4.102          if ( x_char != 0 )
   4.103 @@ -349,6 +377,10 @@ static void xencons_unthrottle(struct tt
   4.104  static void xencons_flush_buffer(struct tty_struct *tty)
   4.105  {
   4.106      unsigned long flags;
   4.107 +
   4.108 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
   4.109 +        return;
   4.110 +
   4.111      spin_lock_irqsave(&xencons_lock, flags);
   4.112      wc = wp = 0;
   4.113      spin_unlock_irqrestore(&xencons_lock, flags);
   4.114 @@ -372,6 +404,9 @@ static int xencons_write(struct tty_stru
   4.115      if ( from_user && verify_area(VERIFY_READ, buf, count) )
   4.116          return -EINVAL;
   4.117  
   4.118 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
   4.119 +        return count;
   4.120 +
   4.121      spin_lock_irqsave(&xencons_lock, flags);
   4.122  
   4.123      for ( i = 0; i < count; i++ )
   4.124 @@ -396,6 +431,10 @@ static int xencons_write(struct tty_stru
   4.125  static void xencons_put_char(struct tty_struct *tty, u_char ch)
   4.126  {
   4.127      unsigned long flags;
   4.128 +
   4.129 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
   4.130 +        return;
   4.131 +
   4.132      spin_lock_irqsave(&xencons_lock, flags);
   4.133      (void)__xencons_put_char(ch);
   4.134      spin_unlock_irqrestore(&xencons_lock, flags);
   4.135 @@ -404,6 +443,10 @@ static void xencons_put_char(struct tty_
   4.136  static void xencons_flush_chars(struct tty_struct *tty)
   4.137  {
   4.138      unsigned long flags;
   4.139 +
   4.140 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
   4.141 +        return;
   4.142 +
   4.143      spin_lock_irqsave(&xencons_lock, flags);
   4.144      __xencons_tx_flush();
   4.145      spin_unlock_irqrestore(&xencons_lock, flags);    
   4.146 @@ -413,6 +456,9 @@ static void xencons_wait_until_sent(stru
   4.147  {
   4.148      unsigned long orig_jiffies = jiffies;
   4.149  
   4.150 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
   4.151 +        return;
   4.152 +
   4.153      while ( tty->driver.chars_in_buffer(tty) )
   4.154      {
   4.155          set_current_state(TASK_INTERRUPTIBLE);
   4.156 @@ -431,6 +477,9 @@ static int xencons_open(struct tty_struc
   4.157      int line;
   4.158      unsigned long flags;
   4.159  
   4.160 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
   4.161 +        return 0;
   4.162 +
   4.163      MOD_INC_USE_COUNT;
   4.164      line = MINOR(tty->device) - tty->driver.minor_start;
   4.165      if ( line != 0 )
   4.166 @@ -453,6 +502,9 @@ static void xencons_close(struct tty_str
   4.167  {
   4.168      unsigned long flags;
   4.169  
   4.170 +    if ( MINOR(tty->device) != xencons_driver.minor_start )
   4.171 +        return;
   4.172 +
   4.173      if ( tty->count == 1 )
   4.174      {
   4.175          tty->closing = 1;
   4.176 @@ -474,10 +526,8 @@ static int __init xencons_init(void)
   4.177  {
   4.178      memset(&xencons_driver, 0, sizeof(struct tty_driver));
   4.179      xencons_driver.magic           = TTY_DRIVER_MAGIC;
   4.180 -    xencons_driver.name            = "xencons";
   4.181      xencons_driver.major           = TTY_MAJOR;
   4.182 -    xencons_driver.minor_start     = XEN_TTY_MINOR;
   4.183 -    xencons_driver.num             = 1;
   4.184 +    xencons_driver.num             = MAX_NR_CONSOLES;
   4.185      xencons_driver.type            = TTY_DRIVER_TYPE_SERIAL;
   4.186      xencons_driver.subtype         = SERIAL_TYPE_NORMAL;
   4.187      xencons_driver.init_termios    = tty_std_termios;
   4.188 @@ -488,6 +538,17 @@ static int __init xencons_init(void)
   4.189      xencons_driver.termios         = xencons_termios;
   4.190      xencons_driver.termios_locked  = xencons_termios_locked;
   4.191  
   4.192 +    if ( start_info.flags & SIF_INITDOMAIN )
   4.193 +    {
   4.194 +        xencons_driver.name        = "xencons";
   4.195 +        xencons_driver.minor_start = XENCONS_TTY_MINOR;
   4.196 +    }
   4.197 +    else
   4.198 +    {
   4.199 +        xencons_driver.name        = "tty";
   4.200 +        xencons_driver.minor_start = 1;
   4.201 +    }
   4.202 +
   4.203      xencons_driver.open            = xencons_open;
   4.204      xencons_driver.close           = xencons_close;
   4.205      xencons_driver.write           = xencons_write;