Recently I found myself in front of a strange problem that prevented me from creating new virtual machines with libvirt on KVM. Everytime I tried to create a virtual machine, I got a message similar to this:
Error: internal error Process exited while reading console log output: chardev: opening backend "pty" failed: Permission denied
Interestingly, directly after a reboot of the host, the same guest configuration would simply work. I did some searches in the internet and found, that there only view other people had this same problem, but I could not find a solution.
After tracing libvirtd and pestering some of my colleagues, I found that it actually could not access /dev/pts correctly. It turned out, that some change root environment also mounted /dev/pts although not with the right mount parameters. This had the effect, that the original /dev/pts also was remounted with the wrong mounting parameters.
So, to solve this issue, you need to
- find who is mounting /dev/pts in a wrong way and correct it
- remount /dev/pts correctly
The remount can be done with the following command:
mount -n -t devpts -o remount,mode=0620,gid=5 devpts /dev/pts
After this, libvirtd will be able again to access the device and work as desired.