Windows – How to set up samba sharing with libvirtd

libvirtsambawindows

I'm using QEmu with a Windows 7 guest on my (Arch) Linux system. I'd like to use the samba to share a directory on my host system with the Windows guest. I can do this from the terminal with a command like:

qemu-system-x86_64 /path/to/windows7.img -enable-kvm -net nic -net user,smb=/path/to/shared/directory -m 1024

But I've got libvirtd set up now, and I'd like to be able to start Windows 7 with virt-manager. I'm a complete novice with libvirtd, and I'm having trouble navigating the documentation. I think I need to set up a "network filesystem pool" (which I read about in the libvirt documentation), but I don't understand if I can do this through virt-manager or if I need to do it on the command line, or where I need to add the XML described in that link.

I've looked for examples, but haven't found anything. I've found various forum posts with people asking questions on how to do this, so I suspect I'm not the only one struggling with this!

Best Answer

It seems like libvirt does not support the -net user,smb command of qemu (I guess due to incompatibilities with other hypervisors). A possible workaround is to directly pass through the parameter to the qemu-kvm command.

To do so, you first need to add the XML namespace http://libvirt.org/schemas/domain/qemu/1.0 to your domain. Then you can use the <commandline> tag of that namespace:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
    ...
    <qemu:commandline>
        <qemu:arg value='-net'/>
        <qemu:arg value='user,smb=/path/to/shared/directory'/>
    </qemu:commandline>
</domain>

You can easily edit the XML configuration by running

# virsh edit <vm-name>
Related Question