From 24eab71d4ce685571f5e09c5366769ecec2f6688 Mon Sep 17 00:00:00 2001 From: Daehyeok Mun Date: Sat, 23 Jan 2016 22:27:28 -0700 Subject: [PATCH] retutn last vbox log instead of error state code return last line in the vbox log file instead of error state code when virtualbox vm start faile Signed-off-by: Daehyeok Mun --- drivers/virtualbox/virtualbox.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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) +}