chardev: opening backend "pty" failed

Bug #607636 reported by Daniel Adolfsson
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libvirt (Ubuntu)
Invalid
Undecided
Unassigned
Natty
Invalid
Undecided
Unassigned
lxc (Ubuntu)
Fix Released
High
Serge Hallyn
Natty
Fix Released
High
Stéphane Graber

Bug Description

I'm unable to start qemu virtual machine because of the following error:

error: Failed to start domain test
error: internal error unable to start guest: chardev: opening backend "pty" failed

The reason I'm posting this on libvirtd, is because I'm able to run the exact same command (as printed in the log file) manually - and it works. I believe qemu bails because openpty() fails - as a direct result of chown() failing.

Both qemu and libvirtd is running as root - and apparmor is not active.

This could be a capabilies issue.

(from strace)
[pid 3058] getuid() = 0
....
[pid 3058] chown("/dev/pts/3", 0, 5) = -1 EPERM (Operation not permitted)

(from /proc/[pid of libvirtd]/status)
Uid: 0 0 0 0
Gid: 0 0 0 0
CapPrm: ffffffffffffffff
CapEff: ffffffffffffffff
CapBnd: ffffffffffffffff

(from /proc/[pid of qemu]/status)
Uid: 0 0 0 0
Gid: 0 0 0 0
CapPrm: fffffffc00000000
CapEff: fffffffc00000000
CapBnd: fffffffc00000000

(ls -la /dev/pts)
drwxr-xr-x 2 root root 0 2010-04-19 09:30 .
c--------- 1 root root 5, 2 2010-07-19 13:55 ptmx

(mount)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,mode=620,mode=620)

(qemu-log)
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin /usr/bin/kvm -S -M pc-0.12 -enable-kvm -m 512 -smp 1 -name ferret -uuid 1e2e6382-904d-11df-9ea9-0040d0c0493e -nographic -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/ferret.monitor,server,nowait -monitor chardev:monitor -boot c -drive file=/dev/mapper/vg0-lv3,if=virtio,index=0,boot=on -net nic,macaddr=52:54:00:43:4a:33,vlan=0,model=virtio,name=virtio.0 -net tap,ifname=tap0,script=/bin/true,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0 -parallel none -usb

Any ideas?

Revision history for this message
Daniel Adolfsson (daniel-adolfsson) wrote :

Problem solved, I think.

/dev/pts was wrongly mounted as:
none on /dev/pts type devpts (rw,mode=620,mode=620)

... when it should be:
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)

This could now be an initramfs issue - I installed dropbear recently and it starts up udev and various other initramfs-scripts.

This is not an libvirt bug.. never was ;)

So where does the bug belong now?

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I'm not sure where the bug is. If you can determine what file caused it to be mounted this way, you can use 'dpkg -S <file>' to determine what package did this. Marking Invalid for now. Feel free to reopen and change to the package causing the error when you determine the cause.

Changed in libvirt (Ubuntu):
status: New → Invalid
Revision history for this message
Martin Pool (mbp) wrote :

I hit the same problem after installing and trying to use lxc. It was previously working properly on the same host machine. Could it be that lxc changes the mount options on the host's /dev/pts? (I'm not sure that was precisely the cause though.)

Revision history for this message
Daniel Adolfsson (daniel-adolfsson) wrote :

What's the status of your apparmor? Do you have it active?

I'm not certain it was the mount options on /dev/pts that was the problem, but it could be.

Does it work if you remount the directory?

Revision history for this message
Norberto Bensa (nbensa) wrote :

Hello,

I had qemu-kvm working flawless and then I installed lxc.

I can reproduce this bug *always* in maverick doing this:

start lxc domain
start kvm guest

$ virsh start kvm-windsurf
chardev: opening backend "pty" failed

> Does it work if you remount the directory?

$ sudo mount -o remount /dev/pts
$ virsh start kvm-windsurf
Se ha iniciado el dominio kvm-windsurf

(more or less: domain kvm-windsurf started)

So yes. It's a workaround for now.

Thanks!

Chuck Short (zulcss)
Changed in lxc (Ubuntu):
status: New → Invalid
Revision history for this message
Stéphane Graber (stgraber) wrote :

Tested with Serge and confirmed to be a bug in LXC's Ubuntu template.

The generated "fstab" contains:
devpts /var/lib/lxc/drupal01/rootfs/dev/pts devpts defaults 0 0

Which shouldn't be present.
That line is causing /dev/pts on the "host" to be mounted with the wrong flags everytime one calls lxc-start on a container that has the above line in its fstab.

The workaround as mentioned before is to run: mount -o remount /dev/pts
and the temporary fix is to remove the line above from the container's fstab.

Here's a quick test I made to reproduce the issue:
root@castiana:~# grep pts /proc/mounts
none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
root@castiana:~# lxc-start -n weblive01 -d
root@castiana:~# lxc-start -n drupal01 -d
root@castiana:~# grep pts /proc/mounts
none /dev/pts devpts rw,nosuid,noexec,relatime,mode=600,ptmxmode=000 0 0

The full strace can be found at: http://paste.ubuntu.com/604151/
and a "grep pts" on that same trace at: http://paste.ubuntu.com/604152/

Changed in lxc (Ubuntu):
status: Invalid → Triaged
importance: Undecided → High
assignee: nobody → Serge Hallyn (serge-hallyn)
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :
Changed in lxc (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 0.7.4-0ubuntu8

---------------
lxc (0.7.4-0ubuntu8) oneiric; urgency=low

  * debian/patches/0009-templates-dont-use-devpts-in-fstab: remove devpts
    entry from $confdir/container/fstab, as it is not needed, and can
    cause the host devpts mount options to change, because it happens
    before lxc has done a mount -o newinstance. (LP: #607636)
 -- Serge Hallyn <email address hidden> Fri, 06 May 2011 12:08:07 -0500

Changed in lxc (Ubuntu):
status: In Progress → Fix Released
Changed in libvirt (Ubuntu Natty):
status: New → Invalid
Changed in lxc (Ubuntu Natty):
status: New → Triaged
importance: Undecided → High
milestone: none → natty-updates
assignee: nobody → Stéphane Graber (stgraber)
Changed in lxc (Ubuntu Natty):
status: Triaged → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted lxc into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

tags: added: verification-needed
Revision history for this message
Norberto Bensa (nbensa) wrote :

Hi!

I just installed the proposed package and it seems to work (I created a lucid container). Starting kvm domains (with virsh start) after the lxc container, works too.

Thank you!

$ dpkg -l | grep lxc
ii lxc 0.7.4-0ubuntu7.1 Linux containers userspace tools

$ sudo lxc-create -f dana.conf -n chromeos -t lucid
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/lucid/rootfs-amd64 ...
Copy /var/cache/lxc/lucid/rootfs-amd64 to /var/lib/lxc/chromeos/rootfs ...
Copying rootfs to /var/lib/lxc/chromeos/rootfs ...Generating locales...
  es_AR.UTF-8... done
Generation complete.
 Removing any system startup links for /etc/init.d/ondemand ...
   /etc/rc2.d/S99ondemand
   /etc/rc3.d/S99ondemand
   /etc/rc4.d/S99ondemand
   /etc/rc5.d/S99ondemand
Please change root-password !
'lucid' template installed
'chromeos' created

$ sudo lxc-start -dn chromeos

$ sudo lxc-console -n chromeos

Type <Ctrl+a q> to exit the console

Ubuntu 10.04 LTS chromeos tty1

chromeos login: root
Password:
Linux chromeos 2.6.38-9-generic #43-Ubuntu SMP Thu Apr 28 15:23:06 UTC 2011 x86_64 GNU/Linux
Ubuntu 10.04 LTS

Welcome to Ubuntu!
 * Documentation: https://help.ubuntu.com/

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@chromeos:~#

$ virsh start kvm-peck
Se ha iniciado el dominio kvm-peck

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 0.7.4-0ubuntu7.1

---------------
lxc (0.7.4-0ubuntu7.1) natty-proposed; urgency=low

  [ Serge Hallyn ]
  * debian/patches/0009-templates-dont-use-devpts-in-fstab: remove devpts
    entry from $confdir/container/fstab, as it is not needed, and can
    cause the host devpts mount options to change, because it happens
    before lxc has done a mount -o newinstance. (LP: #607636)
 -- Stephane Graber <email address hidden> Mon, 16 May 2011 15:31:29 -0400

Changed in lxc (Ubuntu Natty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.