From fea4b504d8deaa5448203aae13bdb6ec3e6d33d9 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 24 Jan 2019 18:38:56 +0100 Subject: vm/vmimpl: produce better error in WaitForSSH Currently we squash VerboseError which leads to too lengthy build error titles. Handle verbose error more carefully. --- vm/gce/gce.go | 2 +- vm/qemu/qemu.go | 2 +- vm/vmimpl/util.go | 2 +- vm/vmimpl/vmimpl.go | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'vm') diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 6f4c9f567..3e18cf8f4 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -169,7 +169,7 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) { if outputErr != nil { output = []byte(fmt.Sprintf("failed to get boot output: %v", outputErr)) } - return nil, vmimpl.BootError{Title: err.Error(), Output: output} + return nil, vmimpl.MakeBootError(err, output) } ok = true inst := &instance{ diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index c466a1f56..b10668080 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -392,7 +392,7 @@ func (inst *instance) Boot() error { inst.sshkey, inst.sshuser, inst.os, inst.port); err != nil { bootOutputStop <- true <-bootOutputStop - return vmimpl.BootError{Title: err.Error(), Output: bootOutput} + return vmimpl.MakeBootError(err, bootOutput) } bootOutputStop <- true return nil diff --git a/vm/vmimpl/util.go b/vm/vmimpl/util.go index 08034450f..616ccb3ac 100644 --- a/vm/vmimpl/util.go +++ b/vm/vmimpl/util.go @@ -42,7 +42,7 @@ func WaitForSSH(debug bool, timeout time.Duration, addr, sshKey, sshUser, OS str return nil } if time.Since(startTime) > timeout { - return fmt.Errorf("can't ssh into the instance: %v", err) + return &osutil.VerboseError{"can't ssh into the instance", []byte(err.Error())} } } } diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index e5efe19c2..f83d39d57 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -17,6 +17,7 @@ import ( "time" "github.com/google/syzkaller/pkg/log" + "github.com/google/syzkaller/pkg/osutil" ) // Pool represents a set of test machines (VMs, physical devices, etc) of particular type. @@ -76,6 +77,15 @@ type BootError struct { Output []byte } +func MakeBootError(err error, output []byte) error { + switch err1 := err.(type) { + case *osutil.VerboseError: + return BootError{err1.Title, append(err1.Output, output...)} + default: + return BootError{err.Error(), output} + } +} + func (err BootError) Error() string { return fmt.Sprintf("%v\n%s", err.Title, err.Output) } -- cgit mrf-deployment