I am tearing my hair out trying to solve this permissions problem where files created by the guest cannot be accessed on the host.
Setup:
I have an Ubuntu 20.04 host and a Ubuntu 20.04 guest running through KVM. I have a shared mount setup in mapped mode. The host directory is /home/user/VMs/shared/syncthing/
accessible through the guest vm at /hostmount
. I am mounting from within the guest with sudo mount -t 9p -o trans=virtio,version=9p2000.L /hostmount /hostmount
. The guest VM is launched using virt-manager under the regular account user
.
Current Status:
- The host can create files int the share which can be read and modified by the guest.
- The guest can create files in the share but they cannot be read or modified by the host user.
If I to a touch /hostmount/test.file
from inside the guest as regular user user
, on the host side I see the following permissions for ls –l test.file
:
-rw------- 1 libvirt-qemu kvm 0 Feb 4 02:51 /home/user/VMs/shared/syncthing/test.file
Desired Status:
Of course, I could chown
the file after creation, but how do I either:
- Force the guest VM to create files as
user
on host - Grant
user
on host access to files created by guest vm (libvirt-qemu
on host)
I have tried the suggestions from this answer. They work on pre-existing files but don't work for when the guest creates new files.