Ubuntu

map serial port throws "chardev: opening backend "tty" failed"

Reported by Otto Berger on 2010-05-10
56
This bug affects 9 people
Affects Status Importance Assigned to Milestone
libvirt
Unknown
Unknown
libvirt (Ubuntu)
Low
Jamie Strandboge
Lucid
Low
Unassigned
Maverick
Low
Jamie Strandboge

Bug Description

after updating from karmic to lucid, starting a virtual machine with a serial port throws an error and failed to start. if i remove the serial port (/dev/ttyS14) the machine start successfully...

log entry:
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-0.11 -enable-kvm -m 2048 -smp 1,sockets=1,cores=1,threads=1 -name web2 -uuid 17c99639-2299-ce13-c1b6-c7a627dd181e -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/web2.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -drive file=/dev/vmdata/web2,if=none,id=drive-virtio-disk0,boot=on -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:68:45:ab,bus=pci.0,addr=0x5 -net tap,fd=39,vlan=0,name=hostnet0 -chardev tty,id=serial0,path=/dev/ttyS14 -device isa-serial,chardev=serial0 -usb -vnc 127.0.0.1:0 -k de -vga cirrus -device ES1370,id=sound0,bus=pci.0,addr=0x6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
chardev: opening backend "tty" failed

Angel Abad (angelabad) on 2010-05-17
Changed in libvirt (Ubuntu):
status: New → Confirmed
Angel Abad (angelabad) wrote :

Hi Otto! Could attach virtual machine configuration?

Thanks

Changed in libvirt (Ubuntu):
status: Confirmed → Incomplete
Otto Berger (otto-bergerdata) wrote :

Hi, here is the xml:

<domain type='kvm'>
  <name>web2</name>
  <uuid>17c99639-2299-ce13-c1b6-c7a627dd181e</uuid>
  <memory>2097152</memory>
  <currentMemory>2097152</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.11'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='block' device='disk'>
      <source dev='/dev/vmdata/web2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <interface type='bridge'>
      <mac address='52:54:00:68:45:ab'/>
      <source bridge='br305'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </interface>
    <serial type='dev'>
      <source path='/dev/ttyS14'/>
      <target port='0'/>
    </serial>
    <console type='dev'>
      <source path='/dev/ttyS14'/>
      <target port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='de'/>
    <sound model='es1370'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </sound>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
  </devices>
</domain>

Angel Abad (angelabad) on 2010-05-17
Changed in libvirt (Ubuntu):
status: Incomplete → Confirmed
erl (erl-listas) wrote :

Hi Angel.

As you suggested to me in d-u-s i post this in launchpad.
Adding a parallel port, type device and source to /dev/parport0 throw the same error.

The xml definition:
<domain type='kvm'>
<name>vm-debian</name>
<uuid>711a217a-bd0c-003a-53b3-03d2828c743c</uuid>
<description>Maquina virtual con Debian</description>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64' machine='pc-0.12'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/vd-debian.qcow2'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:f7:81:2a'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<parallel type='dev'>
<source path='/dev/parport0'/>
<target port='0'/>
</parallel>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' keymap='es'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
</devices>
</domain>

I can attach the log and debugin messages if it is necessary.

I don't run any version of Ubuntu but Debian Squeeze.

erl (erl-listas) wrote :

Testing with another virtual machine at diferent computer, same configuration this is the log:

LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin HOME=/ QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-0.12 -enable-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -name vm0 -uuid 44f38697-90a8-04b2-27e5-abd3a9f3c29d -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/vm0.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -drive file=/var/lib/libvirt/images/vdisk0.qcow2,if=none,id=drive-virtio-disk0,boot=on,format=qcow2 -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:2a:8d:ae,bus=pci.0,addr=0x5 -net tap,fd=36,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -chardev tty,id=parallel0,path=/dev/parport0 -device isa-parallel,chardev=parallel0 -usb -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k es -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
char device redirected to /dev/pts/4
chardev: opening backend "tty" failed

Angel Abad (angelabad) on 2010-05-19
Changed in libvirt:
importance: Undecided → Unknown
status: New → Unknown
Changed in libvirt (Ubuntu):
importance: Undecided → Low
Emanuelis (emanuelis) wrote :

Same here

Fjodor (sune-molgaard) wrote :

I request that the importance be heightened, as this also affects installation of new VMs, effectively making that impossible. I'd say that approaches a major fault...

Otto Berger (otto-bergerdata) wrote :

i second that. it makes lucid currently unusable for us.

Guenther Montag (g-montag) wrote :

There seems to be a problem with the apparmor profile of libvirt (see bug #54579). After adding the line

/dev/ttyS* rw,

to /etc/apparmor.d/abstractions/libvirt-qemu and reloading the profile it worked for me.

Jamie Strandboge (jdstrand) wrote :

Guenther, did you have AppArmor denials in your kern.log?

Can people try adding this to /etc/apparmor.d/abstractions/libvirt-qemu:
  owner /dev/ttyS* rw,

If that doesn't work, can you try:
  /dev/ttyS* rw,

Changed in libvirt (Ubuntu):
assignee: nobody → Jamie Strandboge (jdstrand)
status: Confirmed → Incomplete
Guenther Montag (g-montag) wrote :

Jamie, yes I have messages in kern.log:

Jun 8 08:55:01 srv4 kernel: [1100074.508951] type=1503 audit(1275980101.566:71): operation="open" pid=9648 parent=1 profile="libvirt-a4352cb3-c2b3-133a-4867-86c55a89709b" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/dev/ttyS0"

Changed in libvirt (Ubuntu):
status: Incomplete → Triaged
Changed in libvirt (Ubuntu Lucid):
status: New → Triaged
importance: Undecided → Low
assignee: nobody → Jamie Strandboge (jdstrand)
milestone: none → lucid-updates
tags: added: apparmor
Jamie Strandboge (jdstrand) wrote :

It looks like there has been some recent upstream work on this for SELinux. I will be taking a look at that for an update to AppArmor.

I have a similar bug, but I'm not sure if it's identical or unrelated..

The error I receive from libvirt is about the pty instead of tty.

ie:

Jul 15 16:11:56 arya libvirtd: 16:11:56.746: error : qemudWaitForMonitor:1536 : internal error unable to start guest: chardev: opening backend "pty" failed

However I don't have any notices in /var/log/kern.log about apparmor.

What do you think?

franz-unix (franz-unix) wrote :

First sorry for the bad english. I have a similar problem with Ubuntu Lucid 10.04 amd64 Desktop edition using KVM.
Any virtual machine with a serial port (host device /dev/ttyS0) configured fails to start. Removing the serial port the VM works very well.
I use virt manager for the creation and management of the virtual machines .

This is the configuration file of the VM running Ubuntu Lucid 10.04 amd64 (like the host) but server edition

<domain type='kvm'>
  <name>deluge</name>
  <uuid>d8ada746-0538-089e-1215-0a1188977c81</uuid>
  <memory>262144</memory>
  <currentMemory>262144</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source dev='/dev/lvmforkvm/deluge'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>
    <interface type='bridge'>
      <mac address='00:54:00:35:b8:12'/>
      <source bridge='br0'/>
      <model type='virtio'/>
    </interface>
    <serial type='dev'>
      <source path='/dev/ttyS0'/>
      <target port='0'/>
    </serial>
    <console type='dev'>
      <source path='/dev/ttyS0'/>
      <target port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
  </devices>
</domain>

And this is the error message that virt manager shows

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/engine.py", line 588, in run_domain
    vm.startup()
  File "/usr/share/virt-manager/virtManager/domain.py", line 150, in startup
    self._backend.create()
  File "/usr/lib/python2.6/dist-packages/libvirt.py", line 300, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: monitor socket did not show up.: Connection refused

I agree with Fjodor, the importance should be heightened. Without serial port virtualization a lot of functionalities could be lost. For example i need the serial port for the installation of a fax server (hylafax) that is using a modem connected to the host's physical serial port (/dev/ttyS0).
If you need to do some tests I can do that

Changed in libvirt (Ubuntu Maverick):
status: Triaged → In Progress
Changed in libvirt (Ubuntu Lucid):
assignee: Jamie Strandboge (jdstrand) → nobody
Launchpad Janitor (janitor) wrote :
Download full text (4.7 KiB)

This bug was fixed in the package libvirt - 0.8.3-1ubuntu1

---------------
libvirt (0.8.3-1ubuntu1) maverick; urgency=low

  * Merge from debian unstable with security fixes
  * Fixes:
    - LP: #588369
    - LP: #585964
  * Remaining changes:
    - debian/control:
      + Build-Depends on qemu-kvm, not qemu
      + Build-Depends on open-iscsi-utils, not open-iscsi
      + Build-Depends on libxml2-utils
      + Build-Depends on libapparmor-dev and Suggests apparmor
      + Bump bridge-utils, dnsmasq-base, netcat-openbsd, and iptables
        to Depends of libvirt-bin
      + Drop lvm2, qemu-kvm and qemu to Suggests
      + We call libxen-dev libxen3-dev, so change all references
      + Rename Vcs-* to XS-Debian-Vcs-*
    - debian/libvirt-bin.postinst:
      + rename the libvirt group to libvirtd
      + add each admin user to the libvirtd group
      + reload apparmor profiles
    - debian/libvirt-bin.postrm:
      + rename the libvirt group to libvirtd
      + remove apparmor symlinks on purge
    - debian/README.Debian: add AppArmor section based on the upstream
      documentation
    - debian/rules:
      + update DEB_DH_INSTALLINIT_ARGS for upstart
      + add DEB_MAKE_CHECK_TARGET := check
      + use --with-apparmor
      + copy apparmor and apport hook to debian/tmp
    - add debian/libvirt-bin.upstart
    - debian/libvirt-bin.dirs: add /etc/apparmor.d/abstractions,
      /etc/apparmor.d/disable, /etc/apparmor.d/force-complain,
      /etc/apparmor.d/libvirt, /etc/cron.daily and
      /usr/share/apport/package-hooks
    - add debian/libvirt-bin.cron.daily
    - add debian/libvirt-bin.apport
    - debian/libvirt-bin.install: install apparmor profiles, abstractions
      and apport hook
    - debian/apparmor:
      - add TEMPLATE
      - add libvirt-qemu abstraction
      - add usr.lib.libvirt.virt-aa-helper
      - add usr.sbin.libvirtd
    - debian/patches/series:
      + don't apply 0002-qemu-disable-network.diff.patch
      + don't apply 0005-Terminate-nc-on-EOF.patch. Use
        9009-autodetect-nc-params.patch instead
      + 9000-delayed_iff_up_bridge.patch (refreshed)
      + 9001-dont_clobber_existing_bridges.patch
      + 9002-better_default_uri_virsh.patch (refreshed)
      + 9003-better-default-arch.patch (refreshsed)
      + 9004-libvirtd-group-name.patch
      + 9005-increase-unix-socket-timeout.patch (refreshed)
      + 9006-default-config-test-case.patch
      + 9007-fix-daemon-conf-ftbfs.patch (updated)
      + 9008-run-as-root-by-default.patch (refreshed)
      + 9009-autodetect-nc-params.patch (refreshed)
      + 9010-dont-disable-ipv6.patch (refreshsed)
      + 9011-move-ebtables-script.patch (refreshed)
  * Dropped the following patches included/fixed upstream:
    - 9012-fix-nodeinfotest-ftbfs.patch
    - 9013-apparmor-lp457716.patch
  * Disable virtualbox support since virtualbox-ose is not in main
    - debian/control: remove virtualbox-ose build dependency
    - debian/rules: use --without-vbox
  * debian/patches/9012-apparmor-dont-ignore-open.patch: fix logic when
    using virDomainDiskDefForeachPath() and add tests. This can be removed
    in 0.8.4.
  * debian/apparmor/usr.sbin.libvirtd: add capability fseti...

Read more...

Changed in libvirt (Ubuntu Maverick):
status: In Progress → Fix Released
CvB (cvb-kruemel) wrote :

It seems I have the same error (on Lucid 64bit). I get 'opening backend "tty" failed' in my virtual machine log, and I get a kernel message in my syslog:

Aug 25 17:50:18 gaia kernel: [ 9109.444187] type=1505 audit(1282751418.474:90): operation="profile_remove" pid=10366 name="libvirt-c2d4403f-0e69-38f4-7641-ef6459dfc8a8" namespace="root"

I tried to edit /etc/apparmor.d/abstractions/libvirt-qemu, but to no avail.

I see there is a fix, but not for Lucid (0.7.5-5ubuntu27.2 seems to be current there). Any hint for how I could get this fixed under Lucid would be most appreciated.

Bertrand JUGLAS (bertrand) wrote :

I've followed comment #9 so I've added the following line to the end of /etc/apparmor.d/abstractions/libvirt-qemu
owner /dev/ttyS* rw,

And now it works fine :)
Thank you for the fix ;)

Roman Yepishev (rye) wrote :

As I can see on my installation the following happens:

requested_mask="r::" denied_mask="r::"

but

virt-aa-helper.c:
    865 for (i = 0; i < ctl->def->nserials; i++)
    866 if (ctl->def->serials[i] && ctl->def->serials[i]->data.file.path)
    867 if (vah_add_file(&buf,
    868 ctl->def->serials[i]->data.file.path, "w") != 0)
    869 goto clean;
    870
    871 if (ctl->def->console && ctl->def->console->data.file.path)
    872 if (vah_add_file(&buf, ctl->def->console->data.file.path, "w") != 0)
    873 goto clean;

so apparmor profiles contain e.g. /dev/ttyS0 w, which allows writing to the file, but not reading :-/

Roman Yepishev (rye) wrote :

Since I am being bit by this every time libvirt update is issued I have put the libvirt binary with the patch attached to my ppa:rye/ppa archive.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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