I require access to a host serial port (/dev/ttyS0) on a virtual machine. I have installed VMs with virt-install and virt-manager and encountered the same (or at least very similar) problems in each case. The current discussion assumes virt-manager.
The host machine is Debian 6.0.6, the VM is Ubuntu server 12.04, virt-manager is version 0.8.4, libvirtd is version 0.8.3, and the hypervisor is KVM (qemu:///system).
Upon creation of the VM and installation of Ubuntu, the VM starts and works fine. If I create a serial port with virt-manager->Edit->Virtual Machine Details->Add Hardware (Device Type: dev, Source Path: /dev/ttyS0) and restart the VM, I get an error
Error starting domain: internal error Process exited while reading console log output: char device redirected to /dev/pts/2
chardev: opening backend "tty" failed
Before I added this serial port, the VM started without error. If I add the serial port, I get the error. If I use virt-manager to remove the serial port, the VM starts without error.
On the host, /dev/ttyS0 is owned by root, the group is dialout, and the permissions are 660. libvirt-qemu is a member of dialout.
If I change the permissions of /dev/ttS0 to 666, the VM starts up without complaint. I don't quite know why this is true, I assume libvirtd runs as root because I ran virt-install with sudo. Even if that reasoning is false, the libvirt-qemu user being a member of dialout group should work. However, I don't know which user libvirtd really runs as for qemu:///system. Is it root or libvirt-qemu or me or something else?
I have done some searching on this forum and haven't found an answer. Google searches find similar problems that are blamed on AppArmor or SELinux, but I am using neither. The online documentation seems sparse, and I have not found a solution at libvirt.org.
My questions are:
1) How can the VM get access to the host's /dev/ttyS0?
2) Why does changing permissions of /dev/ttyS0 to 666 allow the VM to start with out an error related to tty? Whose permissions is the VM running with, and in which group?
3) I assume that I am making an obvious mistake, so the real question is: what obvious mistake am I making