Sha256: da18df107bc45a8e52837eb6363c0bd0b4ac705964b6025c5121c875eb9bb990

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'digest/md5'
require 'vagrant/util/retryable'

module VagrantPlugins
  module ProviderLibvirt
    module Cap
      class MountVirtioFS
        extend Vagrant::Util::Retryable

        def self.mount_virtiofs_shared_folder(machine, folders)
          folders.each do |_name, opts|
            # Expand the guest path so we can handle things like "~/vagrant"
            expanded_guest_path = machine.guest.capability(
              :shell_expand_guest_path, opts[:guestpath]
            )

            # Do the actual creating and mounting
            machine.communicate.sudo("mkdir -p #{expanded_guest_path}")

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

            mount_opts = "-o #{opts[:mount_opts]}" if opts[:mount_opts]

            mount_command = "mount -t virtiofs #{mount_opts} '#{mount_tag}' #{expanded_guest_path}"
            retryable(on: Vagrant::Errors::LinuxMountFailed,
                      tries: 5,
                      sleep: 3) do
              machine.communicate.sudo(mount_command,
                                       error_class: Vagrant::Errors::LinuxMountFailed)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-libvirt-0.5.3 lib/vagrant-libvirt/cap/mount_virtiofs.rb
vagrant-libvirt-0.5.2 lib/vagrant-libvirt/cap/mount_virtiofs.rb
vagrant-libvirt-0.5.1 lib/vagrant-libvirt/cap/mount_virtiofs.rb
vagrant-libvirt-0.5.0 lib/vagrant-libvirt/cap/mount_virtiofs.rb