qemu

package
v0.0.0-...-d005ad2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package qemu is suitable for running QEMU-based integration tests.

The environment variable `UROOT_QEMU` overrides the path to QEMU and the first few arguments (defaults to "qemu"). For example, I use:

UROOT_QEMU='qemu-system-x86_64 -L . -m 4096 -enable-kvm'

For CI, this environment variable is set in `.circleci/images/integration/Dockerfile`.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeout = 7 * time.Second

DefaultTimeout for `Expect` and `ExpectRE` functions.

View Source
var TimeoutMultiplier = 2.0

TimeoutMultiplier increases all timeouts proportionally. Useful when running QEMU on a slow machine.

Functions

This section is empty.

Types

type Network

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

func NewNetwork

func NewNetwork() *Network

type Options

type Options struct {
	// Path to the bzImage kernel
	Kernel string

	// Path to the initramfs.
	Initramfs string

	// Extra kernel arguments.
	KernelArgs string

	// SharedDir is a directory that will be mountable inside the VM as
	// /dev/sda1.
	SharedDir string

	// ExtraArgs are additional QEMU arguments.
	ExtraArgs []string

	// Where to send serial output.
	SerialOutput io.WriteCloser

	// Timeout is the expect timeout.
	Timeout time.Duration

	// Network to expose inside the VM.
	Network *Network
}

Options is filled and pass to `Start()`.

func (*Options) Start

func (o *Options) Start() (*VM, error)

Start a QEMU VM.

type VM

type VM struct {
	Options *Options
	// contains filtered or unexported fields
}

VM is a running QEMU virtual machine.

func (*VM) Close

func (v *VM) Close()

Close stops QEMU.

func (*VM) Cmdline

func (v *VM) Cmdline() []string

func (*VM) CmdlineQuoted

func (v *VM) CmdlineQuoted() string

CmdlineQuoted quotes any of QEMU's command line arguments containing a space so it is easy to copy-n-paste into a shell for debugging.

func (*VM) Expect

func (v *VM) Expect(search string) error

Expect returns an error if the given string is not found in vEMU's serial output within `DefaultTimeout`.

func (*VM) ExpectRE

func (v *VM) ExpectRE(pattern *regexp.Regexp) (string, error)

ExpectRE returns an error if the given regular expression is not found in vEMU's serial output within `DefaultTimeout`. The matched string is returned.

func (*VM) ExpectRETimeout

func (v *VM) ExpectRETimeout(pattern *regexp.Regexp, timeout time.Duration) (string, error)

ExpectRETimeout returns an error if the given regular expression is not found in vEMU's serial output within the given timeout. The matched string is returned.

func (*VM) ExpectTimeout

func (v *VM) ExpectTimeout(search string, timeout time.Duration) error

ExpectTimeout returns an error if the given string is not found in vEMU's serial output within the given timeout.

func (*VM) Send

func (v *VM) Send(in string)

Send sends a string to QEMU's serial.

func (*VM) TimeoutOr

func (v *VM) TimeoutOr() time.Duration

Jump to

Keyboard shortcuts

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