special console handling

Scott James Remnant scott at netsplit.com
Sat Jan 22 05:52:43 UTC 2011


On Tue, Jan 18, 2011 at 2:08 PM, Clint Byrum <clint at ubuntu.com> wrote:
> 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.
>
This only applies to parameters which are the bare words, not the
foo=bar forms (assuming you're talking about Andy's patch).  Unless of
course the patch went overboard.

>> 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"?
>
We could define a "console" state for each instance of the console=
parameter, with environment specifying the device and options?  Then:

    while console

Would spawn multiple instances automatically.

> 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?
>
We should probably strive for read-only filesystems working ;-)

Scott



More information about the upstart-devel mailing list