Shared folders not working on kvm

I followed the instructions on the wiki to install kvm and whonix on a fedora host. Everything seems to work fine but for some reason the shared folder is not working. I will note that in my virt-manager settings, there’s no option to select the “mode” so I can’t set it to ‘mapped’ as the documentation describes. How can I fix this?

Choose virtio-9p as driver if you want mapped access mode.

1 Like

Hi, using virtio-9p crashes my vm and returns the following error message:

Error starting domain: internal error: qemu unexpectedly closed the monitor: 2023-06-03T06:11:16.190563Z qemu-system-x86_64: -device {"driver":"virtio-9p-pci","id":"fs0","fsdev":"fsdev-fs0","mount_tag":"shared","bus":"pci.0","addr":"0x8"}: cannot initialize fsdev 'fsdev-fs0': failed to open '/home/[user]/shared': Permission denied

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 108, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
    ret = fn(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1402, in startup
    self._backend.create()
  File "/usr/lib64/python3.11/site-packages/libvirt.py", line 1373, in create
    raise libvirtError('virDomainCreate() failed')
libvirt.libvirtError: internal error: qemu unexpectedly closed the monitor: 2023-06-03T06:11:16.190563Z qemu-system-x86_64: -device {"driver":"virtio-9p-pci","id":"fs0","fsdev":"fsdev-fs0","mount_tag":"shared","bus":"pci.0","addr":"0x8"}: cannot initialize fsdev 'fsdev-fs0': failed to open '/home/[user]/shared': Permission denied

It means that QEMU doesn’t have adequate access to your host shared directory. It is most likely not an issue with either QEMU, nor is it an issue with Whonix.

As for the resolution to this problem, there are some, if I am right in my assessment that this is a SELinux issue:

  • disable SELinux - this is may be the easiest solution to avoid problems in the future if you value convenience over security. It’s not what I recommend, but you know your use case better than I do.
  • try setting SELinux to permissive mode and see if that helps alleviate the potential additional adjustments you have to make. Also, something I do not recommend.
  • set proper permissions to your host shared directory. This is what I do recommend.
1 Like

Thank you for the advice. It did turn out to be an SElinux issue. I followed the instructions on the same page for that and it works fine in virtio-9p mode.