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 <daehyeok@gmail.com>
This commit is contained in:
Daehyeok Mun 2016-01-23 22:27:28 -07:00
parent 6588968fb5
commit 24eab71d4c
1 changed files with 11 additions and 5 deletions

View File

@ -247,10 +247,7 @@ func (d *Driver) PreCreateCheck() error {
// IsVTXDisabledInTheVM checks if VT-X is disabled in the started vm. // IsVTXDisabledInTheVM checks if VT-X is disabled in the started vm.
func (d *Driver) IsVTXDisabledInTheVM() (bool, error) { func (d *Driver) IsVTXDisabledInTheVM() (bool, error) {
logPath := filepath.Join(d.ResolveStorePath(d.MachineName), "Logs", "VBox.log") lines, err := d.readVBoxLog()
log.Debugf("Checking vm logs: %s", logPath)
lines, err := d.logsReader.Read(logPath)
if err != nil { if err != nil {
return true, err return true, err
} }
@ -492,7 +489,9 @@ func (d *Driver) Start() error {
} }
if err := d.vbm("startvm", d.MachineName, "--type", "headless"); err != nil { 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) return fmt.Errorf("Unable to start the VM: %s", err)
} }
case state.Paused: case state.Paused:
@ -838,3 +837,10 @@ func detectVBoxManageCmdInPath() string {
} }
return cmd 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)
}