In the past I have used Virtual Box which has very good support for sharing a folder on the host with a Windows guest. I am looking for similar functionality for QEMU.The documentation suggests to expose a Samba server running somewhere in the network, or use the -net user,smb=/path/to/folder to start a samba server.I had no luck with the -net user,smb option of QEMU. All it does is starting smbd (which conflicts with another service running locally due to a port conflict). Suffice to say, this is unusable, especially with multiple guests in mind. (For Linux, -virtfs (Plan 9) can be used for easy folder sharing.)Other problems with Samba is that it is not limited to folder sharing, it also does printer sharing, user mapping and whatsnot. All I need is to share one (or more?) folders with the Windows guest.Does there exist an alternative folder sharing method for QEMU that works with a Windows guest?Or is there a way to configure Samba to restrict itself to a very limited set of features and integrate it into QEMU? It should:Not everyone in the network should be able to access the folder.local users included (if feasible).Not provide other functionality (printer sharing).Use case: expose a git directory to Windows, compile it in Windows and use Linux for analysis.Have an acceptable speed, Windows uses virtio-scsi and virtio-net.Be able to share a folder from a Linux host with a Windows 7 guest.
Shared folder between QEMU Windows guest and Linux host
windows;samba;qemu;file sharing
QEMU's built-in Samba serviceThe not-functioning -net user,smb option was caused by an incompatibility with newer Samba versions (>= 4). This is fixed in QEMU v2.2.0 and newer with these changes:b87b8a8 slirp/smb: Move ncalrpc directory to tmp (since v2.1.0)44d8d2b net/slirp: specify logbase for smbd (since v2.2.0)7912d04 slirp/smbd: modify/set several parameters in generated smbd.conf (since v2.2.0, disables printer too)(Debian has backported the latter two patches to 2.1+dfsg-6 which is present in Jessie.)UsageYou can export one folder as \\10.0.2.4\qemu when using User networking:qemu-system-x86_64 \    -net user,smb=/absolute/path/to/folder \    -net nic,model=virtio \    ...When QEMU is successfully started with these options, a new /tmp/qemu-smb.*-*/ directory will be created containing a smb.conf. If you are fast enough, then this file could be modified to make paths read-only or export more folders.Mode of operationThe samba daemon is executed whenever ports 139 or 445 get accessed over a user network. Communication happens via standard input/output/error of the smbd process. This is the reason why newer daemons failed, it would write its error message to the pipe instead of protocol messages.Due to this method of operation, the daemon will not listen on host ports, and therefore will only be accessible to the guest. So other clients in the network and even local users cannot gain access to folders using this daemon.Since QEMU v2.2.0 printer sharing is completely disabled through the samba configuration, so another worry is gone here.The speed depends on the network adapter, so it is recommended to use the virtio netkvm driver under Windows.Also note that the daemon is executed by its absolute path (typically /usr/sbin/smbd) as specified at compile time (using the --smbd option). Whenever you need to try a new binary or interpose smbd, you will need to modify the file at that path.Other caveatsExecutables (*.exe) must be executable on the host (chmod +x FILE) for the guest to have execute permissions. To allow execution of any file, add the acl allow execute always = True option to a share.Example read-only smb.conf configuration which allows execution of any file (based on QEMU v2.2.0):...[qemu]path=/home/peter/windowsread only=yesguest ok=trueforce user=peteracl allow execute always = True