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.
  • a more OS agnostic question: superuser.com/questions/628169/… Commented Mar 9, 2018 at 13:48
  • 1
    @CiroSantilli包子露宪六四事件法轮功 That question is tagged with Linux where -virtfs works great (see also this question), but I am not aware of a 9p driver for Windows.
    – Lekensteyn
    Commented Mar 11, 2018 at 15:44
  • yes, not saying it is a dupe or anything, just related. Commented Mar 11, 2018 at 15:48
  • fyi all host networking is by default accessible in the guest under IP
    – phil294
    Commented Nov 19, 2021 at 6:43

3 Answers 3


QEMU's built-in Samba service

The 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:

(Debian has backported the latter two patches to 2.1+dfsg-6 which is present in Jessie.)


You can export one folder as \\\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 operation

The 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 caveats

Executables (*.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):

read only=yes
guest ok=true
force user=peter
acl allow execute always = True
  • I used this option, I need both read-write access. I have restarted the qemu service and updated the conf accordingly. I don't see anything in network folders in the explorer in windows guest. Also how do I find the host IP (I assume that's in this case here? My guest IP for this NIC was @Lekensteyn - any ideas?
    – tsar2512
    Commented Oct 19, 2018 at 17:41
  • @tsar2512 Usually I go to Explorer, then use Map Network Drive to assign a letter to \\\qemu. Lately I have skipped that step and opened said path directly from the Run dialog.
    – Lekensteyn
    Commented Oct 21, 2018 at 9:44

In 2018 a simple way to share a folder between a Linux host & Windows virtual machine is to enable RDP in the Windows guest & connect to the vm with the Remmina Remote Desktop Client & enable a Shared Folder:

Remmina RDP settings

This creates a folder under This pc (shared folder on Linux hostname) & a \\tsclient\shared-folder-name network share inside the guest. You can also map a network drive:

Windows Guest folder shares

  • This solution does not require samba to be running.

  • Tested under libvirt / virt-manager but should work with any virtualization.

  • Interesting technique, File System Redirection appears to be a RDP feature. The xfreerdp /drive:shared-folder-name,/home/user/shared option should work as well. Source code references: Remmina configuration, FreeRDP library code.
    – Lekensteyn
    Commented Oct 11, 2018 at 15:22
  • 1
    Is this a safe solution without any dangers of potential attackers?
    – Dave
    Commented Sep 2, 2019 at 18:27
  • @Dave - nowadays I automatically start & stop a samba server & open / close firewall ports when the the vm starts / stops using libvirt hooks libvirt.org/hooks.html Commented Dec 5, 2022 at 9:57

I managed to make simple working setup that uses anonymous NFS export. It requires to enable "Services for NFS" in Windows guest and using regedit to set matching DWORD values AnonymousUid and AnonymousGid in Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default.

Then it can be mounted by command.com command mount -o anon \\\mnt\diskx\nfsshare Z:, where is Linux host's IP address and \mnt\diskx\nfsshare is the export path as defined in /etc/exports.

see detailed description with screenshots

  • Nice! But is not there any problem with encoding?
    – schweik
    Commented Jan 5 at 13:41
  • @schweik NFS will transfer all files exactly as-is: it will not do any encoding transforms. So in that respect, it's no different from any other way to access a Windows fileshare over the network. If you are referring to the different text file end-of-line convention or the use of UTF8 in text files in Linux vs. CP437/CP850/UTF-16 in Windows, that's mostly a matter of picking a good text editor and choosing the encoding according to the intended use of the file. But that's par for the course when dealing with dissimilar operating systems.
    – telcoM
    Commented Jan 10 at 7:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .