Bug#683117: lxc-create -t debian creates unusable setup
July 28th, 2012 - 05:40 pm ET by Sebastian Schmidt | Report spam
This is a multi-part MIME message sent by reportbug.
MIME-Version: 1.0
Package: lxc
Version: 0.8.0~rc1-8
Severity: important
Tags: patch
Hash: SHA1
Hi,
when creating an lxc container with the debian template the setup
generated is not working:
# lxc-create -n foo -t debian
[Hitting Return several times]
# lxc-start -n foo
Mount failed for selinuxfs on /selinux: Operation not permitted
INIT: version 2.88 booting
[...]
Starting OpenBSD Secure Shell server: sshdCould not load host key:
/etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
.
In another console:
# lxc-console -n foo
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a
itself
And nothing happens because getty can't acquire any tty (because none is
there):
# ls -l /var/lib/lxc/foo/rootfs/dev/tty*
crw-rw-rw- 1 root root 5, 0 Jul 28 15:40 /var/lib/lxc/foo/rootfs/dev/tty
#
Running lxc-start with -l DEBUG -o /dev/stderr reveals:
lxc-start 1343507262.616 INFO lxc_conf - console has been setup
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/3'->'/usr/lib/i386-linux-gnu/lxc/dev/tty1'
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/10'->'/usr/lib/i386-linux-gnu/lxc/dev/tty2
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/12'->'/usr/lib/i386-linux-gnu/lxc/dev/tty3
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/13'->'/usr/lib/i386-linux-gnu/lxc/dev/tty4
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/14'->'/usr/lib/i386-linux-gnu/lxc/dev/tty5
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/15'->'/usr/lib/i386-linux-gnu/lxc/dev/tty6
lxc-start 1343507262.616 INFO lxc_conf - 6 tty(s) has been setup
mount failes because of ENOENT. There are three possible solutions I can
think of:
a) In setup_tty() in the else branch call creat() like it is done in
the 'if (ttydir)' branch.
b) touch or mknod $rootfs/dev/tty[1-6] in the template
c) Set lxc.devttydir in the config.
a) seems the most elegant solution to me although it requires patching
upstream code. Maybe this can be forwarded to upstream anyway. c) should
be the least invasive one.
I have attached a patch for a) and one for c).
TIA, HTH, HAND,
Sebastian
MIME-Version: 1.0
diff -Nru lxc-0.8.0~rc1/debian/patches/13-lxc-create-tty-mountpoint.patch lxc-0.8.0~rc1.ttycreat/debian/patches/13-lxc-create-tty-mountpoint.patch
lxc-0.8.0~rc1/debian/patches/13-lxc-create-tty-mountpoint.patch 1970-01-01 01:00:00.000000000 +0100
+++ lxc-0.8.0~rc1.ttycreat/debian/patches/13-lxc-create-tty-mountpoint.patch 2012-07-28 22:45:15.248840054 +0200
@@ -0,0 +1,17 @@
+Author: Sebastian Schmidt <yath@yath.de>
+Description: create mountpoint for tty bind mounts
+
+ lxc-0.8.0~rc1.orig/src/lxc/conf.c
++++ lxc-0.8.0~rc1/src/lxc/conf.c
+@@ -563,6 +563,11 @@ static int setup_tty(const struct lxc_ro
+ return -1;
+ }
+ } else {
++ ret = creat(path, 0660);
++ if (ret==-1 && errno != EEXIST) {
++ SYSERROR("error creating %s", path);
++ return -1;
++ }
+ if (mount(pty_info->name, path, "none", MS_BIND, 0)) {
+ WARN("failed to mount '%s'->'%s'",
+ pty_info->name, path);
diff -Nru lxc-0.8.0~rc1/debian/patches/series lxc-0.8.0~rc1.ttycreat/debian/patches/series
lxc-0.8.0~rc1/debian/patches/series 2012-06-29 23:14:41.000000000 +0200
+++ lxc-0.8.0~rc1.ttycreat/debian/patches/series 2012-07-28 22:45:15.248840054 +0200
@@ -10,3 +10,4 @@
10-lxc-clone-trap-name.patch
11-lxc-console-escape.patch
12-lxc-create-rootfs.patch
+13-lxc-create-tty-mountpoint.patch
MIME-Version: 1.0
diff -Nru lxc-0.8.0~rc1/debian/local/lxc-debconf lxc-0.8.0~rc1.devttypath/debian/local/lxc-debconf
lxc-0.8.0~rc1/debian/local/lxc-debconf 2012-06-30 14:06:33.000000000 +0200
+++ lxc-0.8.0~rc1.devttypath/debian/local/lxc-debconf 2012-07-28 22:52:04.858871194 +0200
@@ -576,6 +576,7 @@
cat >> "${_PATH}/config" << EOF
#lxc.console = /var/log/lxc/${_NAME}.console
lxc.tty = 6
+lxc.devttydir = lxc
lxc.pts = 1024
## Capabilities
To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
MIME-Version: 1.0
Package: lxc
Version: 0.8.0~rc1-8
Severity: important
Tags: patch
Hash: SHA1
Hi,
when creating an lxc container with the debian template the setup
generated is not working:
# lxc-create -n foo -t debian
[Hitting Return several times]
# lxc-start -n foo
Mount failed for selinuxfs on /selinux: Operation not permitted
INIT: version 2.88 booting
[...]
Starting OpenBSD Secure Shell server: sshdCould not load host key:
/etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
.
In another console:
# lxc-console -n foo
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a
itself
And nothing happens because getty can't acquire any tty (because none is
there):
# ls -l /var/lib/lxc/foo/rootfs/dev/tty*
crw-rw-rw- 1 root root 5, 0 Jul 28 15:40 /var/lib/lxc/foo/rootfs/dev/tty
#
Running lxc-start with -l DEBUG -o /dev/stderr reveals:
lxc-start 1343507262.616 INFO lxc_conf - console has been setup
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/3'->'/usr/lib/i386-linux-gnu/lxc/dev/tty1'
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/10'->'/usr/lib/i386-linux-gnu/lxc/dev/tty2
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/12'->'/usr/lib/i386-linux-gnu/lxc/dev/tty3
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/13'->'/usr/lib/i386-linux-gnu/lxc/dev/tty4
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/14'->'/usr/lib/i386-linux-gnu/lxc/dev/tty5
lxc-start 1343507262.616 WARN lxc_conf - failed to mount '/dev/pts/15'->'/usr/lib/i386-linux-gnu/lxc/dev/tty6
lxc-start 1343507262.616 INFO lxc_conf - 6 tty(s) has been setup
mount failes because of ENOENT. There are three possible solutions I can
think of:
a) In setup_tty() in the else branch call creat() like it is done in
the 'if (ttydir)' branch.
b) touch or mknod $rootfs/dev/tty[1-6] in the template
c) Set lxc.devttydir in the config.
a) seems the most elegant solution to me although it requires patching
upstream code. Maybe this can be forwarded to upstream anyway. c) should
be the least invasive one.
I have attached a patch for a) and one for c).
TIA, HTH, HAND,
Sebastian
MIME-Version: 1.0
diff -Nru lxc-0.8.0~rc1/debian/patches/13-lxc-create-tty-mountpoint.patch lxc-0.8.0~rc1.ttycreat/debian/patches/13-lxc-create-tty-mountpoint.patch
lxc-0.8.0~rc1/debian/patches/13-lxc-create-tty-mountpoint.patch 1970-01-01 01:00:00.000000000 +0100
+++ lxc-0.8.0~rc1.ttycreat/debian/patches/13-lxc-create-tty-mountpoint.patch 2012-07-28 22:45:15.248840054 +0200
@@ -0,0 +1,17 @@
+Author: Sebastian Schmidt <yath@yath.de>
+Description: create mountpoint for tty bind mounts
+
+ lxc-0.8.0~rc1.orig/src/lxc/conf.c
++++ lxc-0.8.0~rc1/src/lxc/conf.c
+@@ -563,6 +563,11 @@ static int setup_tty(const struct lxc_ro
+ return -1;
+ }
+ } else {
++ ret = creat(path, 0660);
++ if (ret==-1 && errno != EEXIST) {
++ SYSERROR("error creating %s", path);
++ return -1;
++ }
+ if (mount(pty_info->name, path, "none", MS_BIND, 0)) {
+ WARN("failed to mount '%s'->'%s'",
+ pty_info->name, path);
diff -Nru lxc-0.8.0~rc1/debian/patches/series lxc-0.8.0~rc1.ttycreat/debian/patches/series
lxc-0.8.0~rc1/debian/patches/series 2012-06-29 23:14:41.000000000 +0200
+++ lxc-0.8.0~rc1.ttycreat/debian/patches/series 2012-07-28 22:45:15.248840054 +0200
@@ -10,3 +10,4 @@
10-lxc-clone-trap-name.patch
11-lxc-console-escape.patch
12-lxc-create-rootfs.patch
+13-lxc-create-tty-mountpoint.patch
MIME-Version: 1.0
diff -Nru lxc-0.8.0~rc1/debian/local/lxc-debconf lxc-0.8.0~rc1.devttypath/debian/local/lxc-debconf
lxc-0.8.0~rc1/debian/local/lxc-debconf 2012-06-30 14:06:33.000000000 +0200
+++ lxc-0.8.0~rc1.devttypath/debian/local/lxc-debconf 2012-07-28 22:52:04.858871194 +0200
@@ -576,6 +576,7 @@
cat >> "${_PATH}/config" << EOF
#lxc.console = /var/log/lxc/${_NAME}.console
lxc.tty = 6
+lxc.devttydir = lxc
lxc.pts = 1024
## Capabilities
To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Similar topics
Make your own search
Tags
Create a new topic
Follow the discussion
1 reply
Make a reply
June 19th, 2013 - 1:39 AM ET
Join now


Replies