From bfe20a223f3164344dc4a6ba4b21db63ee6ceea7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 25 Mar 2012 10:00:27 -0700 Subject: [PATCH] Fail fast if the VM fails to boot properly. [GH-825] --- CHANGELOG.md | 2 ++ lib/vagrant/action/vm/boot.rb | 5 +++++ lib/vagrant/errors.rb | 5 +++++ templates/locales/en.yml | 5 +++++ 4 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f938e70fc..d83265e7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ that are potentially listening on that port as well. [GH-821] - Multiple VM names can be specified for the various commands now. For example: `vagrant up web db service`. [GH-795] + - More robust error handling if a VM fails to boot. The error message + is much clearer now. [GH-825] ## 1.0.1 (March 11, 2012) diff --git a/lib/vagrant/action/vm/boot.rb b/lib/vagrant/action/vm/boot.rb index 349934a8d..6a2ce7d35 100644 --- a/lib/vagrant/action/vm/boot.rb +++ b/lib/vagrant/action/vm/boot.rb @@ -35,6 +35,11 @@ module Vagrant # get shown return true if @env[:interrupted] + # If the VM is not starting or running, something went wrong + # and we need to show a useful error. + state = @env[:vm].state + raise Errors::VMFailedToRun if state != :starting && state != :running + sleep 2 if !@env["vagrant.test"] end diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index e234d76f8..4b11d3433 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -393,6 +393,11 @@ module Vagrant error_key(:failed_to_boot, "vagrant.actions.vm.boot") end + class VMFailedToRun < VagrantError + status_code(77) + error_key(:failed_to_run, "vagrant.actions.vm.boot") + end + class VMGuestError < VagrantError status_code(39) error_namespace("vagrant.errors.guest") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index f4bb64860..a1a898d12 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -331,6 +331,11 @@ en: failed_to_boot: |- Failed to connect to VM via SSH. Please verify the VM successfully booted by looking at the VirtualBox GUI. + failed_to_run: |- + The VM failed to remain in the "running" state while attempting to boot. + This is normally caused by a misconfiguration or host system incompatibilities. + Please open the VirtualBox GUI and attempt to boot the virtual machine + manually to get a more informative error message. bridged_networking: available: |- Available bridged network interfaces: