This post introduced how to share linux folder to Windows guest VM

How

  1. Install samba (QEMU bring it up automatically actually according to ArchWiki)

  2. Add xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' to root <domain> node

  3. Add child XML node

     <qemu:commandline>
         <qemu:arg value='-net'/>
         <qemu:arg value='user,smb=/path/to/shared/directory'/>
     </qemu:commandline>
    
  4. Poweroff VM (DON’T restart)

  5. Poweron it

  6. ps -ef | grep qemu should show the -net user,smb=.... argument now

  7. Open samba share from windows

  8. Ref: https://unix.stackexchange.com/questions/188301/how-to-set-up-samba-sharing-with-libvirtd

Troubleshooting

smbd not start (Fixed in QEMU 2.x): Debian Bug tracker - samba4 does not work with qemu
ACL issue: https://ask.fedoraproject.org/t/unable-to-share-folder-with-virt-manager-qemu/2580/17
QEMU smb option: https://qemu.weilnetz.de/doc/qemu-doc.html#Network-options

Note

I didn’t succeed to make smbd auto-start with qemu process till the end, so I use regular /etc/samba/smb.conf to start a standalone samba server which managed by systemd to make this work.

Other way

webdav: Sharing a folder a windows guest under virt-manager