12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/vagrant-libvirt/cap/mount_virtiofs.rb', line 12
def self.mount_virtiofs_shared_folder(machine, folders)
folders.each do |_name, opts|
expanded_guest_path = machine.guest.capability(
:shell_expand_guest_path, opts[:guestpath]
)
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
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
|