2

I am running a VM on a Linux host using qemu+kvm and libvirt, the guest system is CentOS 7. I wish to share a folder between the two such that host:/some/dir becomes accessible as guest:/some/other/dir.

I wish to minimise effort and cannot re-compile the kernel on either side. I experimented with plan9 but cannot get it to run (the p9 dkms module won't compile on the CentOS 7 guest).

There must be a better way? Performance is secondary as it does not work at all right now.

Ned64
  • 8,486
  • 9
  • 48
  • 86

2 Answers2

1

Just set up sshfs/samba/nfs/etc, it's easier and it just works

EDIT: The point here is, just use a regular file share between the host and the VM, there is absolutely no need to go into dirty untested hacks like plan9.

dyasny
  • 1,136
  • 6
  • 8
  • I'm not entirely sure it doesn't answer the question, but it should probably be edited to provide a more complete answer. – Julie Pelletier Aug 15 '16 at 15:58
  • This does provide an answer, the o/p wanted a way to share a directory between the VM and the host. I'm not sure full instructions on how to set up a file share or every sort imaginable will be feasible in this context, the point of the answer is to just say "use a regular file share". – dyasny Aug 15 '16 at 16:14
  • Thanks, this could be a solution (but isn't, yet). I already have Samba running but services on the host should not be accessible by the guest. Maybe `qemu`'s built-in Samba server could be an option? I searched but could not find a way to enable it using `libvirt`/`virsh`'s XML config file. – Ned64 Aug 16 '16 at 07:19
  • Built in samba server in QEMU? Since when? – dyasny Aug 16 '16 at 13:07
  • @dyasny My source: http://unix.stackexchange.com/questions/165554/shared-folder-between-qemu-windows-guest-and-linux-host but there is no XML config file equivalent, and I could not generate one so far. Documentation is hard to come by. – Ned64 Aug 16 '16 at 16:00
  • PS: The `qemu(1)` man page also has the `-net` `smb=dir` option, but how do I enter this into `libvirt`'s XML config file? – Ned64 Aug 16 '16 at 16:50
  • 1
    Well, this is pretty unusual, I've no idea why they would bloat the code with this nonsense. However, if you want to insert arbitrary qemu commands into the XML, there's a way to do that: https://libvirt.org/drvqemu.html#qemucommand – dyasny Aug 16 '16 at 18:36
0

For Centos 8 or later, you can use virtiofs to realize that: https://libvirt.org/kbase/virtiofs.html

H Han
  • 71
  • 4
  • Thanks, I'll look into that. The guest in question is CentOS 7 but I will revisit this issue when upgrading. – Ned64 Apr 30 '22 at 12:04