~james/core

core/spindle/engines/microvm/runner.go -rw-r--r-- 617 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//go:build linux

package microvm

import (
	"context"
	"fmt"
	"log/slog"
)

type Runner interface {
	// check the host has what this backend needs for spec.
	Validate(spec ImageSpec, enableKVM bool) error
	Start(ctx context.Context, cfg VMConfig, volumePaths map[string]string, logger *slog.Logger) (VMHandle, error)
}

func runnerFor(runnerType string) (Runner, error) {
	switch runnerType {
	case "qemu", "":
		return qemuRunner{}, nil
	case "firecracker":
		return nil, fmt.Errorf("runner type %q not implemented yet", runnerType)
	default:
		return nil, fmt.Errorf("unsupported runner type %q", runnerType)
	}
}