I am trying to use a folder that I have mounted with samba/cifs as a pool for libvirt images.
I have set the virt_use_samba selinux parameter with sudo setsebool virt_use_samba 1 to allow libvirt to use samba. It works loading ISOs from a samba share, but unfortunately not disk images.
I have mounted the samba share with uid=0,gid=0,file_mode=0755,dir_mode=0755 in the /etc/fstab so that it gets mounted as root. I have also tried to mount it as my own user uid=1000 and gid=1000 which did not work either.
I am getting the following error from virt-manager trying to start a virtual machine:
Unable to complete install: 'internal error: QEMU unexpectedly closed the monitor (vm='almalinux9'): 2025-05-01T18:07:08.856208Z qemu-system-x86_64: -blockdev {"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage","backing":null}: Could not open '/mnt/share/images/test.qcow2': Permission denied'
That does seem a bit worrying. (But I donβt really know much about SELinux and Samba shares so Iβm going on instinct really.)
I wonder whether the restorecon actually worked. Iβm not sure that you can apply extended file attributes on CIFS, which might be a problem with updating labels.
Can you try ls -alZ /mnt/share/images ? With the Z flag, youβll explicitly see what label your qcow file has.
I thought that libvirtd runs as root user by default but apparently that is not enough. I went into the /etc/libvirt/qemu.conf and specified user = root. Then a quick sudo systemctl daemon-reload and a sudo systemctl restart libvirtd and now I can boot virtual machines from images on the samba share.