You are not logged in.

#1 2022-07-07 18:55:18

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Permission issues with 9p shared directories using libvirt-qemu (KVM)

I need to synchronize a file between the host and guest machines so I set up a 9p shared directory and everything works fine. I set permissions to 666 and give ownership of the file I want to synchronize to my host user, my host user can write it, my guest user can read but every file the guest writes to is owned by libvirt-qemu and permissions are set to 400 so my regular user cannot access it. Is there a way to change this behavior using the configs or workarounds?

Not sure if this belongs in Newbie Corner, but the alternatives didn't suit this question either.

EDIT: I switched from virtio-9p to virtiofs and I don't have this problem anymore. Not a fix, but it works.

Last edited by UnluckyNinja (2022-07-08 01:08:35)

Offline

#2 2022-07-07 19:49:14

anick
Member
Registered: 2022-07-07
Posts: 10

Re: Permission issues with 9p shared directories using libvirt-qemu (KVM)

Not sure, if this helps, but these options worked for me:

Host:

qemu-system-x86_64 \
    ... \
    -virtfs local,path=$HOME/some/host/path,mount_tag=SHARED_DIR_TAG,security_model=mapped-xattr

Guest:

mount -t 9p -o version=9p2000.L,trans=virtio,msize=131072 SHARED_DIR_TAG $HOME/some/guest/path

Offline

#3 2022-07-07 19:54:09

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Re: Permission issues with 9p shared directories using libvirt-qemu (KVM)

anick wrote:

Not sure, if this helps, but these options worked for me:

Host:

qemu-system-x86_64 \
    ... \
    -virtfs local,path=$HOME/some/host/path,mount_tag=SHARED_DIR_TAG,security_model=mapped-xattr

Guest:

mount -t 9p -o version=9p2000.L,trans=virtio,msize=131072 SHARED_DIR_TAG $HOME/some/guest/path

What is this SHARED_DIR_TAG? Can this be used in the guest fstab?
Is this SHARED_DIR_TAG the alias? Like "fs0"?

Edit: Nevermind, SHARED_DIR_TAG must be the target dir option in virt-manager.

Last edited by UnluckyNinja (2022-07-07 19:57:56)

Offline

#4 2022-07-07 20:06:45

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Re: Permission issues with 9p shared directories using libvirt-qemu (KVM)

anick wrote:

Not sure, if this helps, but these options worked for me:

Host:

qemu-system-x86_64 \
    ... \
    -virtfs local,path=$HOME/some/host/path,mount_tag=SHARED_DIR_TAG,security_model=mapped-xattr

Guest:

mount -t 9p -o version=9p2000.L,trans=virtio,msize=131072 SHARED_DIR_TAG $HOME/some/guest/path

Tried it, but files created in the guest machine are still owned by libvirt-qemu.

Offline

#5 2022-07-07 20:07:36

anick
Member
Registered: 2022-07-07
Posts: 10

Re: Permission issues with 9p shared directories using libvirt-qemu (KVM)

What is this SHARED_DIR_TAG?

It's just a name you are free to choose.

I'm using qemu-system-x86_64 directly, without virt-manager.

I guess you could access the files, if you add your username to the group 'libvirt-qemu'. (Workaround)

Last edited by anick (2022-07-07 20:13:23)

Offline

#6 2022-07-08 00:48:31

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Re: Permission issues with 9p shared directories using libvirt-qemu (KVM)

anick wrote:

What is this SHARED_DIR_TAG?

I guess you could access the files, if you add your username to the group 'libvirt-qemu'. (Workaround)

I thought about this but files generated by the guest machine do not have read or write access for group, only for the owner.

Offline

Board footer

Powered by FluxBB