From 62e357ffcd757520f84d583630668bcd984f93ed Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 20 Sep 2013 17:50:29 -0700 Subject: [PATCH] guests/linux: only successful mount if exit status 0 --- CHANGELOG.md | 2 ++ .../guests/linux/cap/mount_virtualbox_shared_folder.rb | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5b2b8f45..08222f199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ BUG FIXES: in the installer context. [GH-2231] - core: Clear `DYLD_LIBRARY_PATH` on Mac if the subprocess is executing a setuid or setgid script. [GH-2243] + - guests/linux: Don't raise exception right away if mounting fails, allow + retries. [GH-2234] - hosts/arch: Vagrant won't crash on Arch anymore. [GH-2233] ## 1.3.3 (September 18, 2013) diff --git a/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb b/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb index 5532c8799..c547c680b 100644 --- a/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb @@ -28,17 +28,19 @@ module VagrantPlugins success = true mount_commands.each do |command| - machine.communicate.sudo(command) do |type, data| - success = false if type == :stderr && data =~ /No such device/i + no_such_device = false + status = machine.communicate.sudo(command, error_check: false) do |type, data| + no_such_device = true if type == :stderr && data =~ /No such device/i end + success = status == 0 && !no_such_device break if success end break if success attempts += 1 - raise Vagrant::Errors::LinuxMountFailed, :command => mount_command + raise Vagrant::Errors::LinuxMountFailed, :command => mount_commands.join("\n") sleep 2 end