diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index d66e35a019..af6ffc365b 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -247,10 +247,7 @@ func (d *Driver) PreCreateCheck() error { // IsVTXDisabledInTheVM checks if VT-X is disabled in the started vm. func (d *Driver) IsVTXDisabledInTheVM() (bool, error) { - logPath := filepath.Join(d.ResolveStorePath(d.MachineName), "Logs", "VBox.log") - log.Debugf("Checking vm logs: %s", logPath) - - lines, err := d.logsReader.Read(logPath) + lines, err := d.readVBoxLog() if err != nil { return true, err } @@ -492,7 +489,9 @@ func (d *Driver) Start() error { } if err := d.vbm("startvm", d.MachineName, "--type", "headless"); err != nil { - // TODO: We could capture the last lines of the vbox log + if lines, readErr := d.readVBoxLog(); readErr == nil && len(lines) > 0 { + return fmt.Errorf("Unable to start the VM: %s\nDetails: %s", err, lines[len(lines)-1]) + } return fmt.Errorf("Unable to start the VM: %s", err) } case state.Paused: @@ -838,3 +837,10 @@ func detectVBoxManageCmdInPath() string { } return cmd } + +func (d *Driver) readVBoxLog() ([]string, error) { + logPath := filepath.Join(d.ResolveStorePath(d.MachineName), "Logs", "VBox.log") + log.Debugf("Checking vm logs: %s", logPath) + + return d.logsReader.Read(logPath) +}