[systemd-devel] [PATCH resend] getty-generator: Enable getty on all active serial consoles.

Michael Marineau michael.marineau at coreos.com
Tue Sep 10 10:48:03 PDT 2013


On Tue, Sep 10, 2013 at 8:41 AM, Lennart Poettering
<lennart at poettering.net>wrote:

> On Wed, 28.08.13 13:12, Michael Marineau (michael.marineau at coreos.com)
> wrote:
>
> > This enables a getty on active kernel consoles even when they are not
> > the last one specified on the kernel command line and mapped to
> > /dev/console. Now the order "console=ttyS0 console=tty0" works in
> > addition to "console=tty0 console=ttyS0".
>
> Hmm, so when we added the generator initially we though about this and
> came to the conclusion that it might be risky to spawn gettys on all
> configured console outputs and we should limit the magic logic to the
> primary console only. The kernel already makes a distinction between the
> primary console, and all others (the latter only receive logs, but you
> cannot read from them via /dev/console iirc), and so we propagated that
> distinction into systemd, too.
>
> I can totally see that this is confusing though, as nobody remembers the
> right ordering...
>

And in my case there isn't a truly correct ordering either because I'm
creating filesystem images that need to boot on a wide variety of platforms
including QEMU which gives the user a VGA console most of the time but a
serial console when using the -nographic option. The bootloader doesn't
know the difference.


> Kay, do you have an opinion about this?
>
> > ---
> >  src/getty-generator/getty-generator.c | 37
> ++++++++++++++++++++++-------------
> >  1 file changed, 23 insertions(+), 14 deletions(-)
> >
> > diff --git a/src/getty-generator/getty-generator.c
> b/src/getty-generator/getty-generator.c
> > index 4b7a60a..6c93806 100644
> > --- a/src/getty-generator/getty-generator.c
> > +++ b/src/getty-generator/getty-generator.c
> > @@ -122,33 +122,42 @@ int main(int argc, char *argv[]) {
> >          }
> >
> >          if (read_one_line_file("/sys/class/tty/console/active",
> &active) >= 0) {
> > -                const char *tty;
> > -
> > -                tty = strrchr(active, ' ');
> > -                if (tty)
> > -                        tty ++;
> > -                else
> > -                        tty = active;
> > -
> > -                /* Automatically add in a serial getty on the kernel
> > -                 * console */
> > -                if (isempty(tty) || tty_is_vc(tty))
> > -                        free(active);
> > -                else {
> > +                char *w, *state;
> > +                size_t l;
> > +
> > +                /* Automatically add in a serial getty on all active
> > +                 * kernel consoles */
> > +                FOREACH_WORD(w, l, active, state) {
> > +                        char *tty;
> >                          int k;
> >
> > +                        tty = strndup(w, l);
> > +                        if (!tty) {
> > +                            log_oom();
> > +                            free(active);
> > +                            r = EXIT_FAILURE;
> > +                            goto finish;
> > +                        }
> > +
> > +                        if (isempty(tty) || tty_is_vc(tty)) {
> > +                                free(tty);
> > +                                continue;
> > +                        }
> > +
> >                          /* We assume that gettys on virtual terminals
> are
> >                           * started via manual configuration and do this
> magic
> >                           * only for non-VC terminals. */
> >
> >                          k = add_serial_getty(tty);
> > -                        free(active);
> >
> >                          if (k < 0) {
> > +                                free(tty);
> > +                                free(active);
> >                                  r = EXIT_FAILURE;
> >                                  goto finish;
> >                          }
> >                  }
> > +                free(active);
> >          }
> >
> >          /* Automatically add in a serial getty on the first
>
>
> Lennart
>
> --
> Lennart Poettering - Red Hat, Inc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130910/7e6b46b0/attachment.html>


More information about the systemd-devel mailing list