On Fri, Nov 9, 2012 at 10:52 PM, Serge Hallyn <serge.hallyn@canonical.com> wrote:
Just a few things to help you look around:Quoting unicell (unicell@gmail.com):
> On Fri, Nov 9, 2012 at 12:09 AM, unicell <unicell@gmail.com> wrote:
>
> > Hi,
> >
> > I'm trying to manage LXC instances through OpenStack, which use libvirt as
> > a virtualization driver layer. After launching LXC instance, I simply could
> > not attach to the console.
> >
> > virsh # list
> > Id Name State
> > ----------------------------------
> > 14366 instance-00000078 running
> >
> > virsh # console 14366
> > Connected to domain instance-00000078
> > Escape character is ^]
> >
> >
> > And it keeps stuck here.
> >
> > Initially I thought it could be a cgroup device config issue, and tried to
> > "echo ‘c 5:1 rwm'
> > >/cgroup/devices/libvirt/lxc/instance-00000078/devices.allow“, to add
> > /dev/console access right to the container. But it does not work, console
> > stilll not working.
> >
> > Before the cgroup tweaking, devices.list are as follows
> >
> > [root@localhost libvirt]# cat
> > /cgroup/devices/libvirt/lxc/instance-0000007a/devices.list
> >
> > c 1:3 rwm
> > c 1:5 rwm
> > c 1:7 rwm
> > c 1:8 rwm
> > c 1:9 rwm
> > c 5:0 rwm
> > c 5:2 rwm
> > c 136:* rwm
> >
> >
> > I'm not quite sure what kind of issue could possibly cause this console
> > access issue. Cause I'm now using two different guest OS templates on two
Both lxc and libvirt-lxc provide consoles by creating a pty on the host
and bind-mounting that onto /dev/ttyN in the guest before starting init.
Ubuntu on the host passes 'container=lxc' (or 'container=libvirt') to
the container, which tells ubuntu in the container to not do some things
(look for 'container' in /etc/init/*; also things like mountall accept
that they should not do some things in containers).
You can investigate /dev/ttyN and /dev/console in your container by
looking at the pid of init in the container, and looking at
/proc/$pid/root/dev/{console,tty*}
That *should* show 136:* devices, but I assume that in the cases where
it is not working it will show 4:* for ttyN. If you look at
cat /proc/$pid/root/proc/1/mounts
I expect you'll see a /dev is mounted in the container. Which hides the
bind mounts which (libvirt-)lxc has set up.
-serge
console working case (started by lxc-start)--root@localhost:/var/lib/lxc/CN/rootfs/etc/init# cat /proc/10018/root/proc/1/mountsrootfs / rootfs rw 0 0/dev/mapper/lxcvg-lxcimages / ext3 rw,relatime,errors=remount-ro,user_xattr,acl,barrier=1,data=ordered 0 0proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0sysfs /sys sysfs rw,relatime 0 0devpts /dev/lxc/console devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0devpts /dev/lxc/tty1 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0devpts /dev/lxc/tty2 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0devpts /dev/lxc/tty3 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0devpts /dev/lxc/tty4 devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=666 0 0devpts /dev/ptmx devpts rw,relatime,mode=600,ptmxmode=666 0 0none /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0none /sys/fs/fuse/connections fusectl rw,relatime 0 0none /sys/kernel/debug debugfs rw,relatime 0 0none /sys/kernel/security securityfs rw,relatime 0 0none /run tmpfs rw,nosuid,noexec,relatime,size=378636k,mode=755 0 0none /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0none /run/shm tmpfs rw,nosuid,nodev,relatime 0 0root@localhost:/var/lib/lxc/CN/rootfs/etc/init# ls -l /proc/10018/root/dev/{console,tty*}lrwxrwxrwx 1 root root 11 Nov 9 23:55 /proc/10018/root/dev/console -> lxc/consolecrw-rw-rw- 1 root tty 5, 0 Oct 23 20:40 /proc/10018/root/dev/ttycrw------- 1 root tty 4, 0 Oct 23 20:01 /proc/10018/root/dev/tty0lrwxrwxrwx 1 root root 8 Nov 9 23:55 /proc/10018/root/dev/tty1 -> lxc/tty1lrwxrwxrwx 1 root root 8 Nov 9 23:55 /proc/10018/root/dev/tty2 -> lxc/tty2lrwxrwxrwx 1 root root 8 Nov 9 23:55 /proc/10018/root/dev/tty3 -> lxc/tty3lrwxrwxrwx 1 root root 8 Nov 9 23:55 /proc/10018/root/dev/tty4 -> lxc/tty4crw------- 1 root tty 4, 5 Oct 23 20:01 /proc/10018/root/dev/tty5crw------- 1 root tty 4, 6 Oct 23 20:01 /proc/10018/root/dev/tty6crw------- 1 root tty 4, 7 Oct 23 20:01 /proc/10018/root/dev/tty7crw------- 1 root tty 4, 8 Oct 23 20:01 /proc/10018/root/dev/tty8crw------- 1 root tty 4, 9 Oct 23 20:01 /proc/10018/root/dev/tty9console *NOT* working case (started by libvirt)--[root@localhost instances]# cat /proc/2086/root/proc/1/mountsrootfs / rootfs rw 0 0devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=666 0 0/dev/nbd14 / ext3 rw,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered 0 0devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=666 0 0devfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0<-- * /dev is mounted here *proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0proc /proc/sys proc ro,relatime 0 0sysfs /sys sysfs ro,relatime 0 0/dev/sda2 /selinux ext4 ro,relatime,barrier=1,data=ordered 0 0devpts /dev/ptmx devpts rw,relatime,gid=5,mode=620,ptmxmode=666 0 0[root@localhost instances]# ls -l /proc/2086/root/dev/{console,tty*}lrwxrwxrwx 1 root root 10 Nov 9 23:53 /proc/2086/root/dev/console -> /dev/pts/0lrwxrwxrwx 1 root root 10 Nov 9 23:53 /proc/2086/root/dev/tty1 -> /dev/pts/0