builder/qemu: catch early exits of qemu

This commit is contained in:
Mitchell Hashimoto 2013-11-05 22:03:43 -08:00
parent 300897c116
commit 5ededd527a
1 changed files with 11 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import (
"strings"
"sync"
"syscall"
"time"
"unicode"
)
@ -116,6 +117,16 @@ func (d *QemuDriver) Qemu(qemuArgs ...string) error {
d.vmEndCh = nil
}()
// Wait at least a couple seconds for an early fail from Qemu so
// we can report that.
select {
case exit := <-endCh:
if exit != 0 {
return fmt.Errorf("Qemu failed to start. Please run with logs to get more info.")
}
case <-time.After(2 * time.Second):
}
// Setup our state so we know we are running
d.vmCmd = cmd
d.vmEndCh = endCh