`qemu:///session` chokes on long homedirs
Software environment
- Operating system: Ubuntu 22.04.02
- Architecture: x86_64
- kernel version: 5.15.0-69-generic
- libvirt version: 8.0.0
- Hypervisor and version: qemu 6.2+dfsg-2ubuntu6.7
Description of problem
On my system, users using qemu:///session
cannot set up VMs. virt-install
always says
UNIX socket path %s too long
This is because on Linux the maximum length of a FIFO path is 107, which is rather short, and because libvirt seems to be using absolute paths, and because my system has its homedirs in an unusually long location.
Steps to reproduce
Get an install disk:
root@joplin:~# (cd /tmp/ && curl -O https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/x86_64/alpine-extended-3.14.0-x86_64.iso)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 588M 100 588M 0 0 108M 0 0:00:05 0:00:05 --:--:-- 111M
Make a user with a long (but not crazily long) homedir:
root@joplin:~# useradd -s /bin/bash -m -d /var/lib/this-is-a-long-dir -G kvm szambo
Login and try to run a VM:
szambo@joplin:~$ pwd
/var/lib/this-is-a-long-dir
szambo@joplin:~$ export LIBVIRT_DEFAULT_URI="qemu:///session"
szambo@joplin:~$ virt-install --name alpine-is-my-favourite-distro --cdrom /tmp/alpine-extended-3.14.0-x86_64.iso --disk size=20,format=qcow2 --memory 4096 --noautoconsole
Starting install...
Allocating 'alpine-is-my-favourite-distro.qcow2' | 0 B 00:00:00 ...
Removing disk 'alpine-is-my-favourite-distro.qcow2' | 0 B 00:00:00
ERROR internal error: UNIX socket path '/var/lib/this-is-a-long-dir/.config/libvirt/qemu/channel/target/domain-1-alpine-is-my-favouri/org.qemu.guest_agent.0' too long
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///session start alpine-is-my-favourite-distro
otherwise, please restart your installation.
To doubly-prove it, it fails even if it's just a single very long folder name, it doesn't have to do with the depth of the path:
root@joplin:~# useradd -s /bin/bash -m -d /var/this-is-a-really-really-really-long-dir-for-szambo2 -G kvm szambo2
szambo2@joplin:~$ pwd
/var/this-is-a-really-really-really-long-dir-for-szambo2
szambo2@joplin:~$ export LIBVIRT_DEFAULT_URI="qemu:///session"
szambo2@joplin:~$ virt-install --name alpine-is-my-favourite-distro --cdrom /tmp/alpine-extended-3.14.0-x86_64.iso --disk size=20,format=qcow2 --memory 4096 --noautoconsole
Starting install...
Allocating 'alpine-is-my-favourite-distro.qcow2' | 0 B 00:00:00 ...
Removing disk 'alpine-is-my-favourite-distro.qcow2' | 0 B 00:00:00
ERROR internal error: UNIX socket path '/var/this-is-a-really-really-really-long-dir-for-szambo2/.config/libvirt/qemu/channel/target/domain-1-alpine-is-my-favouri/org.qemu.guest_agent.0' too long
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///session start alpine-is-my-favourite-distro
otherwise, please restart your installation.
And with an even longer homedir is breaks in a different way
This one might even count as a separate bug.
root@joplin:~# useradd -s /bin/bash -m -d /var/lib/this-is-a-really-really-really-long-dir-for-szambo3 -G kvm szambo3
szambo3@joplin:~$ pwd
/var/lib/this-is-a-really-really-really-long-dir-for-szambo3
szambo3@joplin:~$ export LIBVIRT_DEFAULT_URI="qemu:///session"
szambo3@joplin:~$ virt-install --name alpine-is-my-favourite-distro --cdrom /tmp/alpine-extended-3.14.0-x86_64.iso --disk size=20,format=qcow2 --memory 4096 --noautoconsole
ERROR Host does not support any virtualization options
Impact
I initially discovered this because we're using SSSD for single-sign-on. All of my users are networked, and they get put in a subdir of /home:
u123456@joplin:~$ pwd
/home/WAVES.EXAMPLE.ORG/u123456
p115628@joplin:~$ virt-install --cdrom /tmp/alpine-extended-3.14.0-x86_64.iso --disk size=20,format=qcow2 --memory 4096 --noautoconsole
Using default --name alpinelinux3.14
Starting install...
Allocating 'disk.qcow2' | 0 B 00:00:00 ...
Removing disk 'disk.qcow2' | 0 B 00:00:00
ERROR internal error: UNIX socket path '/home/WAVES.EXAMPLE.ORG/u123456/.config/libvirt/qemu/channel/target/domain-11-alpinelinux3.14/org.qemu.guest_agent.0' too long
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///session start alpinelinux3.14
otherwise, please restart your installation.
Because of this error, none of my users can use VMs.
(I could grant them access to the shared qemu:///system
storage, but I want better sandboxing and quotaing than that)