From 5153aeaffd096514c1f2652c69cd0fc0d298b1d3 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 29 Nov 2017 13:23:42 +0100 Subject: syz-ci: test images before using them Boot and minimally test images before declaring them as good and switching to using them. If image build/boot/test fails, upload report about this to dashboard. --- vm/gce/gce.go | 2 +- vm/qemu/qemu.go | 4 ++-- vm/vm.go | 9 ++++++++- vm/vmimpl/vmimpl.go | 10 ++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) (limited to 'vm') diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 96cc14e79..792982560 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -364,7 +364,7 @@ func (pool *Pool) waitInstanceBoot(name, ip, sshKey, sshUser, gceKey string) err if err != nil { output = []byte(fmt.Sprintf("failed to get boot output: %v", err)) } - return fmt.Errorf("can't ssh into the instance\n\n%s", output) + return vmimpl.BootError{"can't ssh into the instance", output} } func (pool *Pool) getSerialPortOutput(name, gceKey string) ([]byte, error) { diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 679dcf25e..e3f33554a 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -373,13 +373,13 @@ func (inst *instance) Boot() error { time.Sleep(time.Second) // wait for any pending output bootOutputStop <- true <-bootOutputStop - return fmt.Errorf("qemu stopped:\n%v\n", string(bootOutput)) + return vmimpl.BootError{"qemu stopped", bootOutput} default: } if time.Since(start) > 10*time.Minute { bootOutputStop <- true <-bootOutputStop - return fmt.Errorf("ssh server did not start:\n%v\n", string(bootOutput)) + return vmimpl.BootError{"ssh server did not start", bootOutput} } } bootOutputStop <- true diff --git a/vm/vm.go b/vm/vm.go index b59c0d223..48b68d597 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -37,13 +37,20 @@ type Instance struct { index int } -type Env vmimpl.Env +type ( + Env vmimpl.Env + BootError vmimpl.BootError +) var ( Shutdown = vmimpl.Shutdown TimeoutErr = vmimpl.TimeoutErr ) +func (err BootError) Error() string { + return fmt.Sprintf("%v\n%s", err.Title, err.Output) +} + func Create(typ string, env *Env) (*Pool, error) { impl, err := vmimpl.Create(typ, (*vmimpl.Env)(env)) if err != nil { diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index 617f9bc0f..81f798d26 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -56,6 +56,16 @@ type Env struct { Config []byte // json-serialized VM-type-specific config } +// BootError is returned by Pool.Create when VM does not boot. +type BootError struct { + Title string + Output []byte +} + +func (err BootError) Error() string { + return fmt.Sprintf("%v\n%s", err.Title, err.Output) +} + // Create creates a VM type that can be used to create individual VMs. func Create(typ string, env *Env) (Pool, error) { ctor := ctors[typ] -- cgit mrf-deployment