Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] qemu - shared folder without networking ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
sdauth
Guru
Guru


Joined: 19 Sep 2018
Posts: 569
Location: Ásgarðr

PostPosted: Sun Dec 17, 2023 7:41 pm    Post subject: [SOLVED] qemu - shared folder without networking ? Reply with quote

Hi,
I have a win10 vm and would like to share a folder (/mnt/data/winshare) without having to enable any networking on the vm.
My vm is started with '-nic none' option, so basically I would like to replicate what virtualbox can easily do but with qemu. What are my options ?

Thanks!


Last edited by sdauth on Tue Dec 19, 2023 10:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
blu3bird
Retired Dev
Retired Dev


Joined: 04 Oct 2003
Posts: 614
Location: Munich, Germany

PostPosted: Sun Dec 17, 2023 8:03 pm    Post subject: Reply with quote

virtiofs works okayish though permission can be a pain in the butt.

Personally, I'd go for a host-only network and just use samba.
_________________
Black Holes are created when God divides by zero!
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3140

PostPosted: Mon Dec 18, 2023 6:22 pm    Post subject: Reply with quote

There is 9P in kernel.
Qemu is said to be capable of exposing a host's directory to the guest as a 9p device. I've never used it though, for one-time stuff I'd just use a file as a block device because I already know how to use it.
Back to top
View user's profile Send private message
sdauth
Guru
Guru


Joined: 19 Sep 2018
Posts: 569
Location: Ásgarðr

PostPosted: Tue Dec 19, 2023 12:22 am    Post subject: Reply with quote

Hi,
So I tried virtfiofsd, not straightforward to setup, arch wiki was helpful.

On my qemu command line, I added the following :

Code:
-object memory-backend-memfd,id=mem,size=16G,share=on \
-numa node,memdev=mem \
-chardev socket,id=char0,path=/mnt/vm/win10/win10-virtfs.sock \
-device vhost-user-fs-pci,chardev=char0,tag=winshare \


Before starting the vm, you need to start virtiofsd with the vm socket and dir to share :

Code:
/usr/libexec/virtiofsd --socket-path=/mnt/vm/win10/win10-virtfs.sock --shared-dir /mnt/data/winshare --cache always


Some warning, error, I don't know yet how to solve this. (I start virtiofsd as user)

Code:
2023-12-18T23:46:53Z WARN  virtiofsd::limits Failure when trying to set the limit to 1000000, the hard limit (4096) of open file descriptors is used instead.
2023-12-18T23:46:53Z WARN  virtiofsd::sandbox Couldn't set the process uid as root: -1
2023-12-18T23:46:53Z WARN  virtiofsd::sandbox Couldn't set the process gid as root: -1
2023-12-18T23:46:53Z INFO  virtiofsd Waiting for vhost-user socket connection...
2023-12-18T23:46:54Z INFO  virtiofsd Client connected, servicing requests
Warning: Cannot announce submounts, client does not support it
2023-12-18T23:57:51Z ERROR virtiofsd::passthrough::credentials failed to change uid back to root: Invalid argument (os error 22)
2023-12-18T23:57:51Z ERROR virtiofsd::passthrough::credentials failed to change gid back to root: Invalid argument (os error 22)
2023-12-19T00:03:12Z INFO  virtiofsd Client disconnected, shutting down



Nonetheless, the share works fine. I copied, deleted files without issue.

On the windows side, you need to install latest WinFsp & virtio-win (See: https://virtio-fs.gitlab.io/howto-windows.html )
After reboot, go in "Services" and make sure that virtiofs service is set to start automatically.

Also, I tried with a win7 vm but unfortunately it doesn't work.

Thanks for the suggestion blu3bird!

@szatox, isn't 9p only Linux though ? I'll give a try to file as block device later, this could be even better than virtiofsd for my use case...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum