[libvirt] [PATCH] LXC: don't doubly link /dev/console

Richard Weinberger richard.weinberger at gmail.com
Mon May 5 19:36:06 UTC 2014


On Mon, May 5, 2014 at 5:14 PM, Dwight Engen <dwight.engen at oracle.com> wrote:
> When a console is configured, /dev/console and /dev/tty1 are created as
> symlinks to the same underlying pts. This causes problems since a
> separate getty will be spawned for /dev/console and /dev/tty1, but they
> are each controlling the same device.

Which init spawns a getty on /dev/console _and_ /dev/tty1?
This is odd.

> This patch makes it so that /dev/console is the sole symlink to the first
> console, /dev/tty1 to the second, /dev/tty2 to the third and so on.
>
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
> ---
>  src/lxc/lxc_container.c | 34 ++++++++++++++++++----------------
>  1 file changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index fd8ab16..dcc6b17 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -1034,23 +1034,25 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
>      }
>
>      for (i = 0; i < nttyPaths; i++) {
> -        char *tty;
> -        if (virAsprintf(&tty, "/dev/tty%zu", i+1) < 0)
> -            return -1;
> -        if (symlink(ttyPaths[i], tty) < 0) {
> -            virReportSystemError(errno,
> -                                 _("Failed to symlink %s to %s"),
> -                                 ttyPaths[i], tty);
> +        if (i == 0) {
> +            if (symlink(ttyPaths[i], "/dev/console") < 0) {
> +                virReportSystemError(errno,
> +                                     _("Failed to symlink %s to /dev/console"),
> +                                     ttyPaths[i]);
> +                return -1;
> +            }
> +        } else {
> +            char *tty;
> +            if (virAsprintf(&tty, "/dev/tty%zu", i) < 0)
> +                return -1;
> +            if (symlink(ttyPaths[i], tty) < 0) {
> +                virReportSystemError(errno,
> +                                     _("Failed to symlink %s to %s"),
> +                                     ttyPaths[i], tty);
> +                VIR_FREE(tty);
> +                return -1;
> +            }
>              VIR_FREE(tty);
> -            return -1;
> -        }
> -        VIR_FREE(tty);
> -        if (i == 0 &&
> -            symlink(ttyPaths[i], "/dev/console") < 0) {
> -            virReportSystemError(errno,
> -                                 _("Failed to symlink %s to /dev/console"),
> -                                 ttyPaths[i]);
> -            return -1;
>          }
>      }
>      return 0;
> --
> 1.9.0
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list



-- 
Thanks,
//richard




More information about the libvir-list mailing list