From 1bd1bc7d21be9920a31f48d2e962dc74274d216f Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 26 Sep 2025 15:31:32 +0200 Subject: vm: use error wrapping to detect ssh connection errors This is a much cleaner logic than string matching. --- vm/qemu/qemu.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'vm/qemu') diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 6714703fe..55473a419 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "net" @@ -348,10 +349,8 @@ func (pool *Pool) Create(ctx context.Context, workdir string, index int) (vmimpl if err == nil { return inst, nil } - if strings.Contains(err.Error(), "can't ssh into the instance") { - // If there was a boot error, immediately return it. - // In this case, the string search below also matches against boot time output, - // and e.g. "Device or resource busy" is quite often in there. + if errors.Is(err, vmimpl.ErrCantSSH) { + // It is most likely a boot crash, just return the error as is. return nil, err } // Older qemu prints "could", newer -- "Could". -- cgit mrf-deployment