From 117beff05c4507112c6f4aadbff055994306fa43 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 8 May 2023 12:04:29 +0200 Subject: vm: separate boot time and infrastructure errors It's not correct to mix them since they point to fundamentally different issues: 1) Boot time errors are caused by a problematic kernel image and can only be resolved by using another kernel version or config. 2) Infrastructure errors are temporary, so we can just try again some time later. Reserve the existing BootError for (1) errors and let all other VM handling errors refer to (2). To make it possible to attach more output to the infra error, introduce the VerboseInfraError type. --- vm/vmimpl/vmimpl.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'vm/vmimpl') diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index 10de2ffed..9dbd61a92 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -85,6 +85,8 @@ type Env struct { } // BootError is returned by Pool.Create when VM does not boot. +// It should not be used for VMM intfrastructure errors, i.e. for problems not related +// to the tested kernel itself. type BootError struct { Title string Output []byte @@ -107,6 +109,21 @@ func (err BootError) BootError() (string, []byte) { return err.Title, err.Output } +// By default, all Pool.Create() errors are related to infrastructure problems. +// InfraError is to be used when we want to also attach output to the title. +type InfraError struct { + Title string + Output []byte +} + +func (err InfraError) Error() string { + return fmt.Sprintf("%v\n%s", err.Title, err.Output) +} + +func (err InfraError) InfraError() (string, []byte) { + return err.Title, err.Output +} + // Register registers a new VM type within the package. func Register(typ string, ctor ctorFunc, allowsOvercommit bool) { Types[typ] = Type{ -- cgit mrf-deployment