special console handling
Clint Byrum
clint at ubuntu.com
Tue Jan 18 22:08:17 UTC 2011
On Sat, 2011-01-15 at 00:50 +0000, Scott James Remnant wrote:
> On Fri, Jan 14, 2011 at 11:43 PM, Clint Byrum <clint at ubuntu.com> wrote:
> > As I read it, the kernel has been patched to provide kernel arguments as
> > environment variables if they are specified as foo=bar. So
> > console=ttyS0,38400 would end up as an environment varialble "console"
> > with the value of "ttyS0,38400", for init only.
> >
> I'm not actually sure the kernel passes $console in this way, I think
> it's one of the ones it uses for himself and never reveals.
>
I don't know when this was added, but in 2.6.35 at least, if
CONFIG_INIT_PASS_ALL_PARAMS is set, then everything is passed to init.
> Let's step back a moment, what are the possible console= variables?
> Can multiple console= variables be specified, what happens then? Is
> the first or last used?
>
According to the kernel's Documentation/serial-console.txt:
--- copied from serial-console.txt ---
It is possible to specify multiple devices for console output. You can
define a new kernel command line option to select which device(s) to
use for console output.
The format of this option is:
console=device,options
device: tty0 for the foreground virtual console
ttyX for any other virtual console
ttySx for a serial port
lp0 for the first parallel port
ttyUSB0 for the first USB serial device
options: depend on the driver. For the serial port this
defines the baudrate/parity/bits/flow control of
the port, in the format BBBBPNF, where BBBB is the
speed, P is parity (n/o/e), N is number of bits,
and F is flow control ('r' for RTS). Default is
9600n8. The maximum baudrate is 115200.
You can specify multiple console= options on the kernel command line.
Output will appear on all of them. The last device will be used when
you open /dev/console. So, for example:
console=ttyS1,9600 console=tty0
--- end copy ---
So, unless upstart is also going to replace getty, I'm not sure as to
how this information should be given to upstart jobs, other than as an
environment variable with the "last" console in it. Maybe something like
"$UPSTART_CONSOLE"?
One thing that has me scratching my head is why we even need this
information to be specified. The port is configured by the kernel, and
as such, we should be able to read its current mode and just leave it
alone. If we want to return it to this state later, lets save it off at
first-boot..
pre-start script
if [ -f /var/run/save.console ] ; then
stty `cat /var/run/save.console` < /dev/console
else
stty --save < /dev/console > /var/run/save.console
fi
end script
Right?
More information about the upstart-devel
mailing list