vm

package
v0.0.0-...-ef766cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 31 Imported by: 156

Documentation

Overview

Package vm provides an abstract test machine (VM, physical machine, etc) interface for the rest of the system. For convenience test machines are subsequently collectively called VMs. Package wraps vmimpl package interface with some common functionality and higher-level interface.

Index

Constants

View Source
const (
	// The program is allowed to exit after timeout.
	ExitTimeout = ExitCondition(1 << iota)
	// The program is allowed to exit with no errors.
	ExitNormal
	// The program is allowed to exit with errors.
	ExitError
)

Variables

View Source
var (
	Shutdown   = vmimpl.Shutdown
	ErrTimeout = vmimpl.ErrTimeout
)

Functions

func AllowsOvercommit

func AllowsOvercommit(typ string) bool

AllowsOvercommit returns if the instance type allows overcommit of instances (i.e. creation of instances out-of-thin-air). Overcommit is used during image and patch testing in syz-ci when it just asks for more than specified in config instances. Generally virtual machines (qemu, gce) support overcommit, while physical machines (adb, isolated) do not. Strictly speaking, we should never use overcommit and use only what's specified in config, because we override resource limits specified in config (e.g. can OOM). But it works and makes lots of things much simpler.

func ShutdownCtx

func ShutdownCtx() context.Context

func WithBeforeContext

func WithBeforeContext(beforeContext int) func(*RunOptions)

func WithEarlyFinishCb

func WithEarlyFinishCb(cb func()) func(*RunOptions)

func WithExitCondition

func WithExitCondition(exitCondition ExitCondition) func(*RunOptions)

func WithInjectExecuting

func WithInjectExecuting(injectExecuting <-chan bool) func(*RunOptions)

Types

type BootErrorer

type BootErrorer interface {
	BootError() (string, []byte)
}

type Dispatcher

type Dispatcher = dispatcher.Pool[*Instance]

func NewDispatcher

func NewDispatcher(pool *Pool, def dispatcher.Runner[*Instance]) *Dispatcher

type ExitCondition

type ExitCondition int

type InfraErrorer

type InfraErrorer interface {
	InfraError() (string, []byte)
}

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

func (*Instance) Close

func (inst *Instance) Close() error

func (*Instance) Copy

func (inst *Instance) Copy(hostSrc string) (string, error)

func (*Instance) Forward

func (inst *Instance) Forward(port int) (string, error)

func (*Instance) Index

func (inst *Instance) Index() int

func (*Instance) Info

func (inst *Instance) Info() ([]byte, error)

func (*Instance) Run

func (inst *Instance) Run(ctx context.Context, reporter *report.Reporter, command string, opts ...func(*RunOptions)) (
	[]byte, []*report.Report, error)

Run runs cmd inside of the VM (think of ssh cmd) and monitors command execution and the kernel console output. It detects kernel oopses in output, lost connections, hangs, etc. Returns command+kernel output and a non-symbolized crash report (nil if no error happens).

func (*Instance) RunSnapshot

func (inst *Instance) RunSnapshot(input []byte) (result, output []byte, err error)

RunSnapshot runs one input in snapshotting mode. Input is copied into the VM in an implementation defined way and is interpreted by executor. Result is the result provided by the executor. Output is the kernel console output during execution of the input.

func (*Instance) SetupSnapshot

func (inst *Instance) SetupSnapshot(input []byte) error

SetupSnapshot must be called once before calling RunSnapshot. Input is copied into the VM in an implementation defined way and is interpreted by executor.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func Create

func Create(cfg *mgrconfig.Config, debug bool) (*Pool, error)

Create creates a VM pool that can be used to create individual VMs.

func (*Pool) Close

func (pool *Pool) Close() error

TODO: Integration or end-to-end testing is needed.

https://github.com/google/syzkaller/pull/3269#discussion_r967650801

func (*Pool) Count

func (pool *Pool) Count() int

func (*Pool) Create

func (pool *Pool) Create(ctx context.Context, index int) (*Instance, error)

type RunOptions

type RunOptions struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package cuttlefish allows to use Cuttlefish Android emulators hosted on Google Compute Engine (GCE) virtual machines as VMs.
Package cuttlefish allows to use Cuttlefish Android emulators hosted on Google Compute Engine (GCE) virtual machines as VMs.
Package gce allows to use Google Compute Engine (GCE) virtual machines as VMs.
Package gce allows to use Google Compute Engine (GCE) virtual machines as VMs.
Package gvisor provides support for gVisor, user-space kernel, testing.
Package gvisor provides support for gVisor, user-space kernel, testing.
Package proxyapp package implements the experimental plugins support.
Package proxyapp package implements the experimental plugins support.
Package vmimpl provides an abstract test machine (VM, physical machine, etc) interface for the rest of the system.
Package vmimpl provides an abstract test machine (VM, physical machine, etc) interface for the rest of the system.
Package vmm provides VMs based on OpenBSD vmm virtualization.
Package vmm provides VMs based on OpenBSD vmm virtualization.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL