#[solved WITH DIFFICULTY] How to share filesystem between guest and host VM using QEMU

79 messages · Page 1 of 1 (latest)

nimble scaffold
#

Host: Fedora
Guest: In this case it's Kali, but I'd like to know the process for any of the popular Linux distros.

First of all, what is the correct way to refer to qemu / libvirt / virt-manager / kvm? I understand that libvirt is the core package, qemu is the interface to that package, and virt-manager is the GUI of QEMU. But is there a catch-all term if I'm referring to this bundle of packages?

I have searched this question and I came close but I had an issue. Note: I want to share files, not just one way, but both ways.

I followed these instructions: https://cialu.net/qemu-kvm-on-ubuntu-and-sharing-files-between-host-and-guests/. Problem started when I ran $ sudo chown libvirt-qemu /home/your-username/vmshare, the user does not exist. Apparently I need to add a user named libvirt-qemu? How do I do this.

Also, in the following command, it refers to "9p":

$ sudo mount -t 9p -o trans=virtio,version=9p2000.L /vmshare /home/guest-username/vmshare

virtio-9p is one of the listed options under filesystem, but it's not the default (default is virtiofs). When I selected it, I got permission errors, which I assume was because I didn't complete the prior step.

#

apparently 9p is old and superseded completely by virtiofs

gloomy dock
gloomy dock
nimble scaffold
nimble scaffold
#

I'm using silverblue by the way

nimble scaffold
gloomy dock
nimble scaffold
gloomy dock
nimble scaffold
#

or hugepages?

#

a google search of hugepages fedora came up with nothing in regard to the documentation

gloomy dock
nimble scaffold
#

So what's my next option here?

gloomy dock
nimble scaffold
#

I found something that says

``If the guest has 9p support (like Linux, or of course, Plan 9) and virtio, try adding the following switch.

-virtfs local,path=/path/to/share,mount_tag=host0,security_model=passthrough,id=host0``

gloomy dock
#

If there are any errors, would you mind posting them?

nimble scaffold
#

That was the error.

#

I typed it out word for word.

gloomy dock
nimble scaffold
#

error writing /etc/systctl.d/40-hugepage.conf: no such file or directory

gloomy dock
nimble scaffold
nimble scaffold
nimble scaffold
gloomy dock
nimble scaffold
#

does that matter? can I just insert that text in the 99 file instead?

#

in that file it says

``# sysctl settings are defined through files in

/usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.

Vendors settings live in /usr/lib/sysctl.d/.

To override a whole file, create a new file with the same in

/etc/sysctl.d/ and put new settings there. To override

only specific settings, add a file with a lexically later

name in /etc/sysctl.d/ and put new settings there.

For more information, see sysctl.conf(5) and sysctl.d(5).

``

gloomy dock
#

Please consider trying the following command if you are comfortable with it

echo 'vm.nr_hugepages = nr_hugepages' | sudo tee /etc/sysctl.d/40-hugepage.conf

If you decide to run the above command, please do so without any modifications except nr_hugepages. If the command fails, please post the original error.

nimble scaffold
gloomy dock
#

nr_hugepages is a placeholder that should be replaced with your preferred value.

nimble scaffold
gloomy dock
nimble scaffold
#

what exactly is my preferred value

gloomy dock
gloomy dock
#

And

To determine the number of hugepages needed check the size of the hugepages:

$ grep Hugepagesize /proc/meminfo

#

The number of hugepages is memory size of virtual machine / Hugepagesize

nimble scaffold
#

do I run # echo 550 > /proc/sys/vm/nr_hugepages?

#

I'm going to run

echo 'vm.nr_hugepages = 2048' | sudo tee /etc/sysctl.d/40-hugepage.conf

gloomy dock
nimble scaffold
#

I don't even know what I just did or how that's supposed to get me to share files between host and guest

#

``# virsh edit name_of_virtual_machine

<domain>
...
<memoryBacking>
<hugepages/>
</memoryBacking>
...
<cpu ...>
<numa>
<cell memory='memory size of virtual machine' unit='KiB' memAccess='shared'/>
</numa>
</cpu>
...
<devices>
...
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs'/>
<source dir='path to source folder on host'/>
<target dir='mount_tag'/>
</filesystem>
...
</devices>
</domain>
``

look if I have to do this and all the next steps, this is way too complicated. It should NOT be this difficult to share files.

#

I have no clue what any of this means, i'm way out of my depth, and in order to do something really simple I have to do all of this? no thanks

#

I don't even know if those steps are relevant to my situation

gloomy dock
nimble scaffold
#

file sharing should be one of the most basic things you should be able to do

#

Even sharing clipboard has proven to be impossible

#

i've gone down many rabbit holes on that one

#

at least in virtualbox I was able to share my clipboard

#

hate the company but they at least do that right

gloomy dock
#

I mean you no disrespect, but the steps here are very clear.

gloomy dock
#

LibVirt is very flexible and has many features, but the complexity of configuration is one of the consequences of this flexibility.

nimble scaffold
#

And what good are the steps if there's 300 of them and you don't even know if it's solving the problem you have.

gloomy dock
nimble scaffold
nimble scaffold
#

[apparently impossible?] How to share filesystem between guest and host VM using QEMU

nimble scaffold
#

I managed to find a way to do it.

I simply went to the virt-manager GUI and used the following options

driver: virtiofs
source path: /var/home/user/vmshare (my home folder is mounted in var because I'm using Fedora Silverblue)
target path: vmshare

in guest terminal, as root, I ran

mount -t virtiofs vmshare vmshare

first vmshare is the target-path (it's just a reference, not a mount path), second is the mount directory.

#

I hope this information becomes more accessible to others. This was impossible to find.

#

documentation from libvirt got 90% correct but needed tweaks.