special console handling

James Hunt james.hunt at canonical.com
Wed Jan 26 11:57:57 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 18/01/11 22:08, Clint Byrum 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.
Not everything seemingly: testing on natty (2.6.37-12) and passing the
following params on the kernel command-line:

    console=ttyS0 console=tty console=ttyUSB0,115200n8r

# tr '\0' '\n' < /proc/1/environ|grep -i console
console=ttyUSB0
#

So, obviously the kernel couldn't pass 3 values with the same name into
inits environment, but it has only passed *part* of the last of the two
of the valid "console=" params I specified. Checked that initramfs gets
the same result. Doing a bit of poking around, it looks like the serial
driver may be modifying the special "console=" param before it is set in
inits environment.

Looks like we'll need to parse /proc/cmdline for the time being or get
the kernel tweaked :|

> 
>> Let's step back a moment, what are the possible console= variables?
Lots of possible values: see:

http://www.kernel.org/doc/Documentation/kernel-parameters.txt
http://www.kernel.org/doc/Documentation/serial-console.txt

>> 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?
> 
> 

James.
- --
James Hunt
____________________________________
Ubuntu Foundations Team, Canonical.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1ADEIACgkQYBWEaHcQG9fIKACdGMeyOoCjgWNDC81cuaKUS/8C
BTsAnRM4ZZJ55lCAfEszIVg5B6ysDLiv
=P2Rw
-----END PGP SIGNATURE-----



More information about the upstart-devel mailing list