Sha256: d1be4790a578de47571c4c167822d06f20bcde3c22c134b96a5e4291dc4b6f39

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

require "vagrant/util/retryable"

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

        def self.mount_p9_shared_folder(machine, folders, options)
          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 = name.dup

            mount_opts="-o trans=virtio"
            mount_opts += ",access=#{options[:owner]}" if options[:owner]
            mount_opts += ",version=#{options[:version]}" if options[:version]
            mount_opts += ",#{opts[:mount_options]}" if opts[:mount_options]

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-libvirt-0.0.20 lib/vagrant-libvirt/cap/mount_p9.rb
vagrant-libvirt-0.0.19 lib/vagrant-libvirt/cap/mount_p9.rb
vagrant-libvirt-0.0.18 lib/vagrant-libvirt/cap/mount_p9.rb
vagrant-libvirt-0.0.17 lib/vagrant-libvirt/cap/mount_p9.rb
vagrant-libvirt-0.0.16 lib/vagrant-libvirt/cap/mount_p9.rb