# File lib/vagrant-libvirt/cap/synced_folder.rb, line 32
      def prepare(machine, folders, _opts)
        raise Vagrant::Errors::Error('No libvirt connection') if machine.provider.driver.connection.nil?
        @conn = machine.provider.driver.connection.client

        begin
          # loop through folders
          folders.each do |id, folder_opts|
            folder_opts.merge!(target: id,
                               accessmode: 'passthrough',
                               mount: true,
                               readonly: nil) { |_k, ov, _nv| ov }

            mount_tag = Digest::MD5.new.update(folder_opts[:hostpath]).to_s[0, 31]
            folder_opts[:mount_tag] = mount_tag

            machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}"

            #xml = to_xml('filesystem', folder_opts)
            xml = Nokogiri::XML::Builder.new do |xml|
              xml.filesystem(type: 'mount', accessmode: folder_opts[:accessmode]) do
                xml.driver(type: 'path', wrpolicy: 'immediate')
                xml.source(dir: folder_opts[:hostpath])
                xml.target(dir: mount_tag)
                xml.readonly unless folder_opts[:readonly].nil?
              end
            end.to_xml(
              save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
                         Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
                         Nokogiri::XML::Node::SaveOptions::FORMAT
            )
            # puts "<<<<< XML:\n #{xml}\n >>>>>"
            @conn.lookup_domain_by_uuid(machine.id).attach_device(xml, 0)
          end
        rescue => e
          machine.ui.error("could not attach device because: #{e}")
          raise VagrantPlugins::ProviderLibvirt::Errors::AttachDeviceError,
                error_message: e.message
        end
      end