syzkaller: github.com/google/syzkaller/vm/vmimpl Index | Files

package vmimpl

import "github.com/google/syzkaller/vm/vmimpl"

Package vmimpl 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. The package also provides various utility functions for VM implementations.

Index

Package Files

console.go console_linux_amd64.go freebsd.go merger.go openbsd.go util.go vmimpl.go

Variables

var (
    // Close to interrupt all pending operations in all VMs.
    Shutdown   = make(chan struct{})
    ErrTimeout = errors.New("timeout")

    Types = make(map[string]Type)
)

func DiagnoseFreeBSD Uses

func DiagnoseFreeBSD(w io.Writer) bool

DiagnoseFreeBSD sends the debug commands to the given writer which is expected to be connected to a panicked FreeBSD kernel. If kernel just hanged, we've lost connection or detected some non-panic error, console still shows normal login prompt.

func DiagnoseOpenBSD Uses

func DiagnoseOpenBSD(w io.Writer) bool

DiagnoseOpenBSD sends the debug commands to the given writer which is expected to be connected to a paniced openbsd kernel. If kernel just hanged, we've lost connection or detected some non-panic error, console still shows normal login prompt.

func MakeBootError Uses

func MakeBootError(err error, output []byte) error

func Multiplex Uses

func Multiplex(cmd *exec.Cmd, merger *OutputMerger, console io.Closer, timeout time.Duration,
    stop, closed <-chan bool, debug bool) (<-chan []byte, <-chan error, error)

func OpenAdbConsole Uses

func OpenAdbConsole(bin, dev string) (rc io.ReadCloser, err error)

OpenAdbConsole provides fallback console output using 'adb shell dmesg -w'.

func OpenConsole Uses

func OpenConsole(con string) (rc io.ReadCloser, err error)

Tested on Suzy-Q and BeagleBone.

func OpenRemoteConsole Uses

func OpenRemoteConsole(bin string, args ...string) (rc io.ReadCloser, err error)

Open dmesg remotely

func RandomPort Uses

func RandomPort() int

func Register Uses

func Register(typ string, ctor ctorFunc, allowsOvercommit bool)

Register registers a new VM type within the package.

func SCPArgs Uses

func SCPArgs(debug bool, sshKey string, port int) []string

func SSHArgs Uses

func SSHArgs(debug bool, sshKey string, port int) []string

func SleepInterruptible Uses

func SleepInterruptible(d time.Duration) bool

Sleep for d. If shutdown is in progress, return false prematurely.

func UnusedTCPPort Uses

func UnusedTCPPort() int

func WaitForSSH Uses

func WaitForSSH(debug bool, timeout time.Duration, addr, sshKey, sshUser, OS string, port int, stop chan error) error

type BootError Uses

type BootError struct {
    Title  string
    Output []byte
}

BootError is returned by Pool.Create when VM does not boot.

func (BootError) BootError Uses

func (err BootError) BootError() (string, []byte)

func (BootError) Error Uses

func (err BootError) Error() string

type Env Uses

type Env struct {
    // Unique name
    // Can be used for VM name collision resolution if several pools share global name space.
    Name    string
    OS      string // target OS
    Arch    string // target arch
    Workdir string
    Image   string
    SSHKey  string
    SSHUser string
    Debug   bool
    Config  []byte // json-serialized VM-type-specific config
}

Env contains global constant parameters for a pool of VMs.

type Instance Uses

type Instance interface {
    // Copy copies a hostSrc file into VM and returns file name in VM.
    Copy(hostSrc string) (string, error)

    // Forward sets up forwarding from within VM to the given tcp
    // port on the host and returns the address to use in VM.
    Forward(port int) (string, error)

    // Run runs cmd inside of the VM (think of ssh cmd).
    // outc receives combined cmd and kernel console output.
    // errc receives either command Wait return error or vmimpl.ErrTimeout.
    // Command is terminated after timeout. Send on the stop chan can be used to terminate it earlier.
    Run(timeout time.Duration, stop <-chan bool, command string) (outc <-chan []byte, errc <-chan error, err error)

    // Diagnose retrieves additional debugging info from the VM (e.g. by
    // sending some sys-rq's or SIGABORT'ing a Go program).
    //
    // Optionally returns (some or all) of the info directly. If wait ==
    // true, the caller must wait for the VM to output info directly to its
    // log.
    Diagnose() (diagnosis []byte, wait bool)

    // Close stops and destroys the VM.
    Close()
}

Instance represents a single VM.

type MergerError Uses

type MergerError struct {
    Name string
    R    io.ReadCloser
    Err  error
}

func (MergerError) Error Uses

func (err MergerError) Error() string

type OutputMerger Uses

type OutputMerger struct {
    Output chan []byte
    Err    chan error
    // contains filtered or unexported fields
}

func NewOutputMerger Uses

func NewOutputMerger(tee io.Writer) *OutputMerger

func (*OutputMerger) Add Uses

func (merger *OutputMerger) Add(name string, r io.ReadCloser)

func (*OutputMerger) AddDecoder Uses

func (merger *OutputMerger) AddDecoder(name string, r io.ReadCloser,
    decoder func(data []byte) (start, size int, decoded []byte))

func (*OutputMerger) Wait Uses

func (merger *OutputMerger) Wait()

type Pool Uses

type Pool interface {
    // Count returns total number of VMs in the pool.
    Count() int

    // Create creates and boots a new VM instance.
    Create(workdir string, index int) (Instance, error)
}

Pool represents a set of test machines (VMs, physical devices, etc) of particular type.

type Type Uses

type Type struct {
    Ctor       ctorFunc
    Overcommit bool
}

Package vmimpl imports 14 packages (graph) and is imported by 17 packages. Updated 2019-12-10. Refresh now. Tools for package owners.